Add context to content-server assets download error

This commit is contained in:
chris
2020-08-05 14:47:19 -04:00
committed by Chris Marshall
parent 13d35f17f1
commit f8559befca
6 changed files with 15 additions and 12 deletions

View File

@ -9,7 +9,7 @@ q3: gen
gen: ## Generate and embed templates
@go run tools/genstatic.go public public
VERSION ?= v1.0.1
VERSION ?= v1.0.2
IMAGE ?= docker.io/criticalstack/quake:$(VERSION)
.PHONY: build

View File

@ -21,9 +21,10 @@ var opts struct {
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "content",
Short: "q3 content server",
SilenceUsage: true,
Use: "content",
Short: "q3 content server",
SilenceErrors: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) (err error) {
if !filepath.IsAbs(opts.AssetsDir) {
opts.AssetsDir, err = filepath.Abs(opts.AssetsDir)

View File

@ -15,7 +15,7 @@ var global struct {
Verbosity int
}
func NewRootCommand() *cobra.Command {
func main() {
cmd := &cobra.Command{
Use: "q3",
Short: "",
@ -28,11 +28,8 @@ func NewRootCommand() *cobra.Command {
)
cmd.PersistentFlags().CountVarP(&global.Verbosity, "verbose", "v", "log output verbosity")
return cmd
}
func main() {
if err := NewRootCommand().Execute(); err != nil {
if err := cmd.Execute(); err != nil {
log.Fatal(err)
}
}

View File

@ -19,7 +19,7 @@ spec:
- --config=/config/config.yaml
- --content-server=http://localhost:9090
- --agree-eula
image: docker.io/criticalstack/quake:v1.0.1
image: docker.io/criticalstack/quake:v1.0.2
name: server
ports:
- containerPort: 8080
@ -37,7 +37,7 @@ spec:
- q3
- content
- --seed-content-url=http://content.quakejs.com
image: docker.io/criticalstack/quake:v1.0.1
image: docker.io/criticalstack/quake:v1.0.2
name: content-server
ports:
- containerPort: 9090

View File

@ -14,6 +14,7 @@ import (
"strings"
httputil "github.com/criticalstack/quake-kube/internal/util/net/http"
"github.com/pkg/errors"
)
func CopyAssets(u *url.URL, dir string) error {
@ -60,7 +61,7 @@ func getManifest(url string) ([]*File, error) {
files := make([]*File, 0)
if err := json.Unmarshal(data, &files); err != nil {
return nil, err
return nil, errors.Wrapf(err, "cannot unmarshal %s/assets/manifest.json", url)
}
return files, nil
}

View File

@ -18,6 +18,10 @@ func GetBody(url string) ([]byte, error) {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.Errorf("cannot get url %q: %v", url, http.StatusText(resp.StatusCode))
}
return ioutil.ReadAll(resp.Body)
}