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 gen: ## Generate and embed templates
@go run tools/genstatic.go public public @go run tools/genstatic.go public public
VERSION ?= v1.0.1 VERSION ?= v1.0.2
IMAGE ?= docker.io/criticalstack/quake:$(VERSION) IMAGE ?= docker.io/criticalstack/quake:$(VERSION)
.PHONY: build .PHONY: build

View File

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

View File

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

View File

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

View File

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

View File

@ -18,6 +18,10 @@ func GetBody(url string) ([]byte, error) {
} }
defer resp.Body.Close() 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) return ioutil.ReadAll(resp.Body)
} }