diff options
author | Harald Musum <musum@yahooinc.com> | 2022-08-19 10:59:35 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-08-19 10:59:35 +0200 |
commit | 54c676642b9a17fb3d1d995e0c9592440e9bc460 (patch) | |
tree | 128b05a0d8e8db4dc3db91d2f9b5f1b389deefb8 /client | |
parent | f490b0591d0de1bcb0a714798716b56d3e9c8534 (diff) |
Handle response from prepare properly
Diffstat (limited to 'client')
-rw-r--r-- | client/go/cmd/deploy.go | 1 | ||||
-rw-r--r-- | client/go/cmd/deploy_test.go | 2 | ||||
-rw-r--r-- | client/go/vespa/deploy.go | 18 |
3 files changed, 19 insertions, 2 deletions
diff --git a/client/go/cmd/deploy.go b/client/go/cmd/deploy.go index e72667e49b6..012570c5471 100644 --- a/client/go/cmd/deploy.go +++ b/client/go/cmd/deploy.go @@ -132,6 +132,7 @@ func newPrepareCmd(cli *CLI) *cobra.Command { return fmt.Errorf("could not write session id: %w", err) } cli.printSuccess("Prepared ", color.CyanString(pkg.Path), " with session ", result.ID) + printPrepareLog(cli.Stderr, result) return nil }, } diff --git a/client/go/cmd/deploy_test.go b/client/go/cmd/deploy_test.go index fe3e0ca0467..236ae74f47e 100644 --- a/client/go/cmd/deploy_test.go +++ b/client/go/cmd/deploy_test.go @@ -121,7 +121,7 @@ func assertDeploy(applicationPackage string, arguments []string, t *testing.T) { func assertPrepare(applicationPackage string, arguments []string, t *testing.T) { t.Helper() client := &mock.HTTPClient{} - client.NextResponseString(200, `{"session-id":"42"}`) + client.NextResponseString(200, `{"session-id":"42","message":"Session 42 for tenant 'default' prepared.","log":[{"level":"WARNING","message":"Warning message 1","time": 1430134091319}]}`) cli, stdout, _ := newTestCLI(t) cli.httpClient = client assert.Nil(t, cli.Run(arguments...)) diff --git a/client/go/vespa/deploy.go b/client/go/vespa/deploy.go index ad4fc5f3022..0e086979d72 100644 --- a/client/go/vespa/deploy.go +++ b/client/go/vespa/deploy.go @@ -143,7 +143,23 @@ func Prepare(deployment DeploymentOptions) (PrepareResult, error) { if err := checkResponse(req, response, serviceDescription); err != nil { return PrepareResult{}, err } - return result, nil + var jsonResponse struct { + SessionID string `json:"session-id"` + Log []LogLinePrepareResponse `json:"log"` + } + jsonDec := json.NewDecoder(response.Body) + if err := jsonDec.Decode(&jsonResponse); err != nil { + return PrepareResult{}, err + } + var id int64 + id, err = strconv.ParseInt(jsonResponse.SessionID, 10, 64) + if err != nil { + return PrepareResult{}, err + } + return PrepareResult{ + ID: id, + LogLines: jsonResponse.Log, + }, err } // Activate deployment with sessionID from a past prepare |