summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-08-31 09:48:58 +0200
committerJon Bratseth <bratseth@gmail.com>2021-08-31 09:48:58 +0200
commit7f4537e1cad5ce9b0e1031697af3680cd348a8e0 (patch)
tree43e2b18770b67842a29fddfaf1b55ce0b3497466 /client
parentd14d32e58b3d4e1ec5e98c85d65282ba62d622f9 (diff)
Output tweaks
Diffstat (limited to 'client')
-rw-r--r--client/go/cmd/deploy.go6
-rw-r--r--client/go/cmd/document.go13
-rw-r--r--client/go/cmd/document_test.go6
-rw-r--r--client/go/cmd/query.go4
4 files changed, 14 insertions, 15 deletions
diff --git a/client/go/cmd/deploy.go b/client/go/cmd/deploy.go
index 94fb985d575..9c867241d52 100644
--- a/client/go/cmd/deploy.go
+++ b/client/go/cmd/deploy.go
@@ -77,9 +77,9 @@ var prepareCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
resolvedSrc, err := vespa.Prepare(vespa.Deployment{ApplicationSource: applicationSource(args)})
if err == nil {
- log.Printf("Prepared %s successfully", color.Cyan(resolvedSrc))
+ log.Print(color.Green("Success: "), "Prepared ", color.Cyan(resolvedSrc))
} else {
- log.Print(color.Red("Error: "), err)
+ log.Print(color.Red("Error:"), err)
}
},
}
@@ -91,7 +91,7 @@ var activateCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
resolvedSrc, err := vespa.Activate(vespa.Deployment{ApplicationSource: applicationSource(args)})
if err == nil {
- log.Print(color.Green("Success: "), "activated ", color.Cyan(resolvedSrc))
+ log.Print(color.Green("Success: "), "Activated ", color.Cyan(resolvedSrc))
} else {
log.Print(color.Red("Error: "), err)
}
diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go
index 9f3754873ad..9aa50b60f56 100644
--- a/client/go/cmd/document.go
+++ b/client/go/cmd/document.go
@@ -12,7 +12,6 @@ import (
"net/http"
"net/url"
"os"
- "strings"
"time"
"github.com/spf13/cobra"
@@ -83,20 +82,20 @@ func post(documentId string, jsonFile string) {
if doc["put"] != nil {
documentId = doc["put"].(string) // document feeder format
} else {
- log.Print("No document id given neither as argument or as a 'put' key in the json file")
+ log.Print(color.Red("Error: "), "No document id given neither as argument or as a 'put' key in the json file")
return
}
}
documentPath, documentPathError := vespa.IdToURLPath(documentId)
if documentPathError != nil {
- log.Print("Invalid document id '", color.Red(documentId), "': ", documentPathError)
+ log.Print(color.Red("Error: "), "Invalid document id '", color.Red(documentId), "': ", documentPathError)
return
}
url, urlParseError := url.Parse(documentTarget() + "/document/v1/" + documentPath)
if urlParseError != nil {
- log.Print("Invalid request path: '", color.Red(documentTarget()+"/document/v1/"+documentPath), "': ", urlParseError)
+ log.Print(color.Red("Error: "), "Invalid request path: '", color.Red(documentTarget()+"/document/v1/"+documentPath), "': ", urlParseError)
return
}
@@ -109,7 +108,7 @@ func post(documentId string, jsonFile string) {
serviceDescription := "Container (document API)"
response, err := util.HttpDo(request, time.Second*60, serviceDescription)
if response == nil {
- log.Print("Request failed: ", color.Red(err))
+ log.Print(color.Red("Error: "), "Request failed:", err)
return
}
@@ -117,10 +116,10 @@ func post(documentId string, jsonFile string) {
if response.StatusCode == 200 {
log.Print(color.Green(documentId))
} else if response.StatusCode/100 == 4 {
- log.Printf("Invalid document (%s):", color.Red(response.Status))
+ log.Print(color.Red("Error: "), "Invalid document: ", response.Status, "\n\n")
log.Print(util.ReaderToJSON(response.Body))
} else {
- log.Printf("Error from %s at %s (%s):", color.Cyan(strings.ToLower(serviceDescription)), color.Cyan(request.URL.Host), color.Red(response.Status))
+ log.Print(color.Red("Error: "), serviceDescription, " at ", color.Cyan(request.URL.Host), ": ", response.Status, "\n\n")
log.Print(util.ReaderToJSON(response.Body))
}
}
diff --git a/client/go/cmd/document_test.go b/client/go/cmd/document_test.go
index 061c86e7725..7d6e107e3c2 100644
--- a/client/go/cmd/document_test.go
+++ b/client/go/cmd/document_test.go
@@ -33,7 +33,7 @@ func TestDocumentIdNotSpecified(t *testing.T) {
arguments := []string{"document", "post", "testdata/A-Head-Full-of-Dreams-Without-Id.json"}
client := &mockHttpClient{}
assert.Equal(t,
- "No document id given neither as argument or as a 'put' key in the json file\n",
+ "Error: No document id given neither as argument or as a 'put' key in the json file\n",
executeCommand(t, client, arguments, []string{}))
}
@@ -72,7 +72,7 @@ func assertDocumentPostShortForm(documentId string, jsonFile string, t *testing.
func assertDocumentError(t *testing.T, status int, errorMessage string) {
client := &mockHttpClient{nextStatus: status, nextBody: errorMessage}
assert.Equal(t,
- "Invalid document (Status "+strconv.Itoa(status)+"):\n"+errorMessage+"\n",
+ "Error: Invalid document: Status "+strconv.Itoa(status)+"\n\n"+errorMessage+"\n",
executeCommand(t, client, []string{"document", "post",
"id:mynamespace:music::a-head-full-of-dreams",
"testdata/A-Head-Full-of-Dreams.json"}, []string{}))
@@ -81,7 +81,7 @@ func assertDocumentError(t *testing.T, status int, errorMessage string) {
func assertDocumentServerError(t *testing.T, status int, errorMessage string) {
client := &mockHttpClient{nextStatus: status, nextBody: errorMessage}
assert.Equal(t,
- "Error from container (document api) at 127.0.0.1:8080 (Status "+strconv.Itoa(status)+"):\n"+errorMessage+"\n",
+ "Error: Container (document API) at 127.0.0.1:8080: Status "+strconv.Itoa(status)+"\n\n"+errorMessage+"\n",
executeCommand(t, client, []string{"document", "post",
"id:mynamespace:music::a-head-full-of-dreams",
"testdata/A-Head-Full-of-Dreams.json"}, []string{}))
diff --git a/client/go/cmd/query.go b/client/go/cmd/query.go
index 2c25168ca30..97ae416196d 100644
--- a/client/go/cmd/query.go
+++ b/client/go/cmd/query.go
@@ -56,10 +56,10 @@ func query(arguments []string) {
if response.StatusCode == 200 {
log.Print(util.ReaderToJSON(response.Body))
} else if response.StatusCode/100 == 4 {
- log.Print(color.Red("Error: "), "Invalid query: ", response.Status)
+ log.Print(color.Red("Error: "), "Invalid query: ", response.Status, "\n")
log.Print(util.ReaderToJSON(response.Body))
} else {
- log.Print(color.Red("Error: "), response.Status, " from container at ", color.Cyan(url.Host))
+ log.Print(color.Red("Error: "), response.Status, " from container at ", color.Cyan(url.Host), "\n")
log.Print(util.ReaderToJSON(response.Body))
}
}