From 5585edfdbcd0a29b0febfc4b5bef0d1ea72b3a94 Mon Sep 17 00:00:00 2001 From: andreasjansson Date: Fri, 30 Apr 2021 13:50:51 -0700 Subject: [PATCH] Show auth errors on cog build Signed-off-by: andreasjansson --- pkg/client/upload.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/client/upload.go b/pkg/client/upload.go index ac5d990777..d3f3e16cfe 100644 --- a/pkg/client/upload.go +++ b/pkg/client/upload.go @@ -63,9 +63,8 @@ func (c *Client) UploadModel(repo *model.Repo, projectDir string) (*model.Model, go func() { err := uploadFile(req, "file", "model.zip", zipReader, bodyWriter) if err != nil { - console.Fatal(err.Error()) + console.Error(err.Error()) } - console.Info("Building model...") }() resp, err := client.Do(req) @@ -74,6 +73,16 @@ func (c *Client) UploadModel(repo *model.Repo, projectDir string) (*model.Model, } defer resp.Body.Close() + if resp.StatusCode == http.StatusNotFound { + return nil, fmt.Errorf("Repository does not exist: %s", repo.String()) + } + if resp.StatusCode == http.StatusUnauthorized { + return nil, fmt.Errorf("You are not authorized to write to repository %s. Did you run cog login?", repo.String()) + } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("Server returned HTTP status %d", resp.StatusCode) + } + var mod *model.Model reader := bufio.NewReader(resp.Body) for {