summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorEirik Nygaard <eirik@ngrd.no>2022-02-16 13:44:11 +0100
committerEirik Nygaard <eirik@ngrd.no>2022-02-16 15:11:57 +0100
commitfe99325becd739afa9bb8bba6d92a97296a672d6 (patch)
tree69fd9e0bc883c088bfb4dd249ba5aaef4136c651 /client
parent47a3a79b0b254d4d4e1cde635d3f0437a9ba4dc0 (diff)
Fixes based on review feedback
Diffstat (limited to 'client')
-rw-r--r--client/go/cmd/curl.go12
-rw-r--r--client/go/cmd/curl_test.go4
2 files changed, 9 insertions, 7 deletions
diff --git a/client/go/cmd/curl.go b/client/go/cmd/curl.go
index 490a132ee89..47d0dcde95b 100644
--- a/client/go/cmd/curl.go
+++ b/client/go/cmd/curl.go
@@ -20,7 +20,7 @@ var curlService string
func init() {
rootCmd.AddCommand(curlCmd)
curlCmd.Flags().BoolVarP(&curlDryRun, "dry-run", "n", false, "Print the curl command that would be executed")
- curlCmd.Flags().StringVarP(&curlService, "service", "s", "query", "Which service to query")
+ curlCmd.Flags().StringVarP(&curlService, "service", "s", "query", "Which service to query. Must be \"deploy\", \"document\" or \"query\"")
}
var curlCmd = &cobra.Command{
@@ -59,21 +59,19 @@ $ vespa curl -- -v --data-urlencode "yql=select * from music where album contain
}
switch curlService {
case "deploy":
- if !vespa.Auth0AccessTokenEnabled() {
- return errors.New("accessing control plane using curl subcommand is only supported for Auth0 device flow")
- }
t, err := getTarget()
if err != nil {
return err
}
if t.Type() == "cloud" {
+ if !vespa.Auth0AccessTokenEnabled() {
+ return errors.New("accessing control plane using curl subcommand is only supported for Auth0 device flow")
+ }
if err := addCloudAuth0Authentication(cfg, c); err != nil {
return err
}
}
- case "document":
- fallthrough
- case "query":
+ case "document", "query":
privateKeyFile, err := cfg.PrivateKeyPath(app)
if err != nil {
return err
diff --git a/client/go/cmd/curl_test.go b/client/go/cmd/curl_test.go
index d5021e19cf2..e593f48a390 100644
--- a/client/go/cmd/curl_test.go
+++ b/client/go/cmd/curl_test.go
@@ -18,4 +18,8 @@ func TestCurl(t *testing.T) {
filepath.Join(homeDir, "t1.a1.i1", "data-plane-private-key.pem"),
filepath.Join(homeDir, "t1.a1.i1", "data-plane-public-cert.pem"))
assert.Equal(t, expected, out)
+
+ out, _ = execute(command{homeDir: homeDir, args: []string{"curl", "-s", "deploy", "-n", "/application/v4/tenant/foo"}}, t, httpClient)
+ expected = "curl https://127.0.0.1:19071/application/v4/tenant/foo\n"
+ assert.Equal(t, expected, out)
}