summaryrefslogtreecommitdiffstats
path: root/client/go/cmd/curl.go
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-02-28 12:58:08 +0100
committerMartin Polden <mpolden@mpolden.no>2022-02-28 14:36:58 +0100
commitac3b7c8ec070e36b958ac38bdc275e80e1e81cd7 (patch)
treed226c3fc4c9412a8dd881862d659c0bbac637cbf /client/go/cmd/curl.go
parente2a943aabd29424df63daaef4121e6f8a0d4a96c (diff)
Support hosted Vespa in Vespa CLI
Diffstat (limited to 'client/go/cmd/curl.go')
-rw-r--r--client/go/cmd/curl.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/client/go/cmd/curl.go b/client/go/cmd/curl.go
index b66780780ed..1ede2cccae3 100644
--- a/client/go/cmd/curl.go
+++ b/client/go/cmd/curl.go
@@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/vespa-engine/vespa/client/go/auth0"
"github.com/vespa-engine/vespa/client/go/curl"
+ "github.com/vespa-engine/vespa/client/go/vespa"
)
var curlDryRun bool
@@ -61,8 +62,8 @@ $ vespa curl -- -v --data-urlencode "yql=select * from music where album contain
if err != nil {
return err
}
- if t.Type() == "cloud" {
- if err := addCloudAuth0Authentication(cfg, c); err != nil {
+ if t.Type() == vespa.TargetCloud {
+ if err := addCloudAuth0Authentication(t.Deployment().System, cfg, c); err != nil {
return err
}
}
@@ -92,17 +93,17 @@ $ vespa curl -- -v --data-urlencode "yql=select * from music where album contain
},
}
-func addCloudAuth0Authentication(cfg *Config, c *curl.Command) error {
- a, err := auth0.GetAuth0(cfg.AuthConfigPath(), getSystemName(), getApiURL())
+func addCloudAuth0Authentication(system vespa.System, cfg *Config, c *curl.Command) error {
+ a, err := auth0.GetAuth0(cfg.AuthConfigPath(), system.Name, system.URL)
if err != nil {
return err
}
- system, err := a.PrepareSystem(auth0.ContextWithCancel())
+ authSystem, err := a.PrepareSystem(auth0.ContextWithCancel())
if err != nil {
return err
}
- c.Header("Authorization", "Bearer "+system.AccessToken)
+ c.Header("Authorization", "Bearer "+authSystem.AccessToken)
return nil
}