diff --git a/Makefile b/Makefile index 1aa7f2d..5778a5b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmd/q3/app/content/content.go b/cmd/q3/app/content/content.go index 0a3c765..ac29683 100644 --- a/cmd/q3/app/content/content.go +++ b/cmd/q3/app/content/content.go @@ -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) diff --git a/cmd/q3/main.go b/cmd/q3/main.go index 5a24ad7..7a740a6 100644 --- a/cmd/q3/main.go +++ b/cmd/q3/main.go @@ -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) } } diff --git a/example.yaml b/example.yaml index b388d17..e0ff9f7 100644 --- a/example.yaml +++ b/example.yaml @@ -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 diff --git a/internal/quake/content/download.go b/internal/quake/content/download.go index 447bd7a..77e8e4d 100644 --- a/internal/quake/content/download.go +++ b/internal/quake/content/download.go @@ -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 } diff --git a/internal/util/net/http/http.go b/internal/util/net/http/http.go index ecc4df5..7fb10da 100644 --- a/internal/util/net/http/http.go +++ b/internal/util/net/http/http.go @@ -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) }