summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2021-09-14 09:27:55 +0200
committerGitHub <noreply@github.com>2021-09-14 09:27:55 +0200
commit4d78471b4f4386f2d42736aea1f8b61374f92c00 (patch)
tree8acac774216a9618a093aa66204fd28050a3beec /client
parenta7447654f6ccbf01a197483d34244ddaaf58f74b (diff)
parenta480de790eb74744c5a03ddae8e55376d0758461 (diff)
Merge pull request #19108 from vespa-engine/mpolden/help-improvements
Minor help improvements
Diffstat (limited to 'client')
-rw-r--r--client/go/cmd/api_key.go6
-rw-r--r--client/go/cmd/cert.go6
-rw-r--r--client/go/cmd/curl.go7
-rw-r--r--client/go/cmd/document.go1
-rw-r--r--client/go/cmd/helpers.go21
5 files changed, 16 insertions, 25 deletions
diff --git a/client/go/cmd/api_key.go b/client/go/cmd/api_key.go
index 90cbdbc5bc1..a838f1a05c8 100644
--- a/client/go/cmd/api_key.go
+++ b/client/go/cmd/api_key.go
@@ -28,16 +28,12 @@ var apiKeyCmd = &cobra.Command{
DisableAutoGenTag: true,
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
- app, err := vespa.ApplicationFromString(getApplication())
- if err != nil {
- fatalErr(err, "Could not parse application")
- return
- }
cfg, err := LoadConfig()
if err != nil {
fatalErr(err, "Could not load config")
return
}
+ app := getApplication()
apiKeyFile := cfg.APIKeyPath(app.Tenant)
if util.PathExists(apiKeyFile) && !overwriteKey {
printErrHint(fmt.Errorf("File %s already exists", apiKeyFile), "Use -f to overwrite it")
diff --git a/client/go/cmd/cert.go b/client/go/cmd/cert.go
index 078c0704f9d..d53f47be1ae 100644
--- a/client/go/cmd/cert.go
+++ b/client/go/cmd/cert.go
@@ -28,11 +28,7 @@ var certCmd = &cobra.Command{
DisableAutoGenTag: true,
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
- app, err := vespa.ApplicationFromString(getApplication())
- if err != nil {
- fatalErr(err)
- return
- }
+ app := getApplication()
pkg, err := vespa.ApplicationPackageFrom(applicationSource(args))
if err != nil {
fatalErr(err)
diff --git a/client/go/cmd/curl.go b/client/go/cmd/curl.go
index 4d949b51e8f..f6b40e10f35 100644
--- a/client/go/cmd/curl.go
+++ b/client/go/cmd/curl.go
@@ -9,7 +9,6 @@ import (
"github.com/kballard/go-shellquote"
"github.com/spf13/cobra"
- "github.com/vespa-engine/vespa/client/go/vespa"
)
var curlDryRun bool
@@ -39,11 +38,7 @@ $ vespa curl -t local -- -v /search/?yql=query
fatalErr(err, "Could not load config")
return
}
- app, err := vespa.ApplicationFromString(getApplication())
- if err != nil {
- fatalErr(err)
- return
- }
+ app := getApplication()
privateKeyFile, err := cfg.PrivateKeyPath(app)
if err != nil {
fatalErr(err)
diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go
index d2552729aeb..78c6596f511 100644
--- a/client/go/cmd/document.go
+++ b/client/go/cmd/document.go
@@ -102,6 +102,7 @@ var documentGetCmd = &cobra.Command{
Short: "Gets a document",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
+ Example: `$ vespa document get id:mynamespace:music::a-head-full-of-dreams`,
Run: func(cmd *cobra.Command, args []string) {
printResult(vespa.Get(args[0], documentService()), true)
},
diff --git a/client/go/cmd/helpers.go b/client/go/cmd/helpers.go
index 14699abf40e..a541f2d363a 100644
--- a/client/go/cmd/helpers.go
+++ b/client/go/cmd/helpers.go
@@ -55,10 +55,7 @@ func deploymentFromArgs() vespa.Deployment {
if err != nil {
fatalErrHint(err, "Zone format is <env>.<region>")
}
- app, err := vespa.ApplicationFromString(getApplication())
- if err != nil {
- fatalErrHint(err, "Application format is <tenant>.<app>.<instance>")
- }
+ app := getApplication()
return vespa.Deployment{Application: app, Zone: zone}
}
@@ -69,17 +66,23 @@ func applicationSource(args []string) string {
return "."
}
-func getApplication() string {
+func getApplication() vespa.ApplicationID {
cfg, err := LoadConfig()
if err != nil {
fatalErr(err, "Could not load config")
- return ""
+ return vespa.ApplicationID{}
}
app, err := cfg.Get(applicationFlag)
if err != nil {
- fatalErr(err, "A valid application must be specified")
+ fatalErrHint(err, "No application specified. Try the --"+applicationFlag+" flag")
+ return vespa.ApplicationID{}
+ }
+ application, err := vespa.ApplicationFromString(app)
+ if err != nil {
+ fatalErrHint(err, "Application format is <tenant>.<app>.<instance>")
+ return vespa.ApplicationID{}
}
- return app
+ return application
}
func getTargetType() string {
@@ -142,7 +145,7 @@ func getTarget() vespa.Target {
}
kp, err := tls.LoadX509KeyPair(certificateFile, privateKeyFile)
if err != nil {
- fatalErr(err, "Could not read key pair")
+ fatalErrHint(err, "Deployment to cloud requires a certificate. Try 'vespa cert'")
}
return vespa.CloudTarget(deployment, kp, apiKey)
}