aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/go/go.mod2
-rw-r--r--client/go/go.sum2
-rw-r--r--client/go/internal/cli/cmd/api_key.go4
-rw-r--r--client/go/internal/cli/cmd/cert.go8
-rw-r--r--client/go/internal/cli/cmd/config_test.go2
-rw-r--r--client/go/internal/cli/cmd/destroy.go12
-rw-r--r--client/go/internal/cli/cmd/destroy_test.go2
-rw-r--r--client/go/internal/cli/cmd/log.go2
-rw-r--r--client/go/internal/cli/cmd/login.go4
-rw-r--r--client/go/internal/cli/cmd/logout.go4
-rw-r--r--client/go/internal/cli/cmd/prod.go10
-rw-r--r--client/go/internal/cli/cmd/prod_test.go3
-rw-r--r--client/go/internal/cli/cmd/root.go9
-rw-r--r--client/go/internal/cli/cmd/waiter.go2
-rw-r--r--client/go/internal/vespa/deploy.go2
-rw-r--r--client/go/internal/vespa/deploy_test.go1
16 files changed, 38 insertions, 31 deletions
diff --git a/client/go/go.mod b/client/go/go.mod
index 0d67283104f..d797017a810 100644
--- a/client/go/go.mod
+++ b/client/go/go.mod
@@ -17,7 +17,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/zalando/go-keyring v0.2.3
golang.org/x/net v0.14.0
- golang.org/x/sys v0.11.0
+ golang.org/x/sys v0.12.0
gopkg.in/yaml.v3 v3.0.1
)
diff --git a/client/go/go.sum b/client/go/go.sum
index fbe0fa1207e..4bea3accfae 100644
--- a/client/go/go.sum
+++ b/client/go/go.sum
@@ -74,6 +74,8 @@ golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
+golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
diff --git a/client/go/internal/cli/cmd/api_key.go b/client/go/internal/cli/cmd/api_key.go
index 8b3780ab82b..7c187aa5da7 100644
--- a/client/go/internal/cli/cmd/api_key.go
+++ b/client/go/internal/cli/cmd/api_key.go
@@ -54,11 +54,11 @@ Read more in https://cloud.vespa.ai/en/security/guide`,
}
func doApiKey(cli *CLI, overwriteKey bool, args []string) error {
- app, err := cli.config.application()
+ targetType, err := cli.targetType(true)
if err != nil {
return err
}
- targetType, err := cli.targetType()
+ app, err := cli.config.application()
if err != nil {
return err
}
diff --git a/client/go/internal/cli/cmd/cert.go b/client/go/internal/cli/cmd/cert.go
index 7fbb357d1db..5c1ed04ab4e 100644
--- a/client/go/internal/cli/cmd/cert.go
+++ b/client/go/internal/cli/cmd/cert.go
@@ -95,11 +95,11 @@ $ vespa auth cert add -a my-tenant.my-app.my-instance path/to/application/packag
}
func doCert(cli *CLI, overwriteCertificate, skipApplicationPackage bool, args []string) error {
- app, err := cli.config.application()
+ targetType, err := cli.targetType(true)
if err != nil {
return err
}
- targetType, err := cli.targetType()
+ app, err := cli.config.application()
if err != nil {
return err
}
@@ -141,11 +141,11 @@ func doCert(cli *CLI, overwriteCertificate, skipApplicationPackage bool, args []
}
func doCertAdd(cli *CLI, overwriteCertificate bool, args []string) error {
- pkg, err := cli.applicationPackageFrom(args, false)
+ target, err := cli.target(targetOptions{cloudExclusive: true})
if err != nil {
return err
}
- target, err := cli.target(targetOptions{})
+ pkg, err := cli.applicationPackageFrom(args, false)
if err != nil {
return err
}
diff --git a/client/go/internal/cli/cmd/config_test.go b/client/go/internal/cli/cmd/config_test.go
index b00be38d021..7a4035f54a3 100644
--- a/client/go/internal/cli/cmd/config_test.go
+++ b/client/go/internal/cli/cmd/config_test.go
@@ -272,7 +272,7 @@ func TestConfigTargetResolving(t *testing.T) {
}
func assertTargetType(t *testing.T, expected string, cli *CLI) {
- targetType, err := cli.targetType()
+ targetType, err := cli.targetType(false)
require.Nil(t, err)
assert.Equal(t, expected, targetType.name)
}
diff --git a/client/go/internal/cli/cmd/destroy.go b/client/go/internal/cli/cmd/destroy.go
index ca69f21a9b4..38d93f49675 100644
--- a/client/go/internal/cli/cmd/destroy.go
+++ b/client/go/internal/cli/cmd/destroy.go
@@ -36,18 +36,14 @@ $ vespa destroy --force`,
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
- target, err := cli.target(targetOptions{})
+ target, err := cli.target(targetOptions{cloudExclusive: true})
if err != nil {
return err
}
description := target.Deployment().String()
- if !target.IsCloud() {
- return errHint(fmt.Errorf("cannot remove deployment, only supported for Vespa Cloud"))
- } else {
- env := target.Deployment().Zone.Environment
- if env != "dev" && env != "perf" {
- return errHint(fmt.Errorf("cannot remove production %s", description), "See https://cloud.vespa.ai/en/deleting-applications")
- }
+ env := target.Deployment().Zone.Environment
+ if env != "dev" && env != "perf" {
+ return errHint(fmt.Errorf("cannot remove production %s", description), "See https://cloud.vespa.ai/en/deleting-applications")
}
ok := force
if !ok {
diff --git a/client/go/internal/cli/cmd/destroy_test.go b/client/go/internal/cli/cmd/destroy_test.go
index b23e524e0ab..44610576d7e 100644
--- a/client/go/internal/cli/cmd/destroy_test.go
+++ b/client/go/internal/cli/cmd/destroy_test.go
@@ -56,5 +56,5 @@ func TestDestroy(t *testing.T) {
require.Nil(t, cli.Run("config", "set", "target", "local"))
require.Nil(t, cli.Run("config", "set", "application", "foo.bar.baz"))
require.NotNil(t, cli.Run("destroy", "-z", "prod.aws-us-east-1c"))
- assert.Equal(t, "Error: cannot remove deployment, only supported for Vespa Cloud\n", stderr.String())
+ assert.Equal(t, "Error: unsupported target local: this command only supports targets cloud and hosted\n", stderr.String())
}
diff --git a/client/go/internal/cli/cmd/log.go b/client/go/internal/cli/cmd/log.go
index fa07e33538c..8d3f3f4f384 100644
--- a/client/go/internal/cli/cmd/log.go
+++ b/client/go/internal/cli/cmd/log.go
@@ -34,7 +34,7 @@ $ vespa log --follow`,
SilenceUsage: true,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
- target, err := cli.target(targetOptions{logLevel: levelArg})
+ target, err := cli.target(targetOptions{logLevel: levelArg, cloudExclusive: true})
if err != nil {
return err
}
diff --git a/client/go/internal/cli/cmd/login.go b/client/go/internal/cli/cmd/login.go
index baf35ce7954..d6eb8207b7f 100644
--- a/client/go/internal/cli/cmd/login.go
+++ b/client/go/internal/cli/cmd/login.go
@@ -20,13 +20,13 @@ func newLoginCmd(cli *CLI) *cobra.Command {
return &cobra.Command{
Use: "login",
Args: cobra.NoArgs,
- Short: "Authenticate the Vespa CLI",
+ Short: "Authenticate Vespa CLI with Vespa Cloud",
Example: "$ vespa auth login",
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
- targetType, err := cli.targetType()
+ targetType, err := cli.targetType(true)
if err != nil {
return err
}
diff --git a/client/go/internal/cli/cmd/logout.go b/client/go/internal/cli/cmd/logout.go
index 93f7cb6270f..204513145aa 100644
--- a/client/go/internal/cli/cmd/logout.go
+++ b/client/go/internal/cli/cmd/logout.go
@@ -9,12 +9,12 @@ func newLogoutCmd(cli *CLI) *cobra.Command {
return &cobra.Command{
Use: "logout",
Args: cobra.NoArgs,
- Short: "Log out of Vespa Cli",
+ Short: "Sign out of Vespa Cloud",
Example: "$ vespa auth logout",
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
- targetType, err := cli.targetType()
+ targetType, err := cli.targetType(true)
if err != nil {
return err
}
diff --git a/client/go/internal/cli/cmd/prod.go b/client/go/internal/cli/cmd/prod.go
index 79a6907eef2..1a2f88311b6 100644
--- a/client/go/internal/cli/cmd/prod.go
+++ b/client/go/internal/cli/cmd/prod.go
@@ -53,6 +53,10 @@ https://cloud.vespa.ai/en/reference/deployment`,
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
+ target, err := cli.target(targetOptions{noCertificate: true, cloudExclusive: true})
+ if err != nil {
+ return err
+ }
pkg, err := cli.applicationPackageFrom(args, false)
if err != nil {
return err
@@ -70,10 +74,6 @@ https://cloud.vespa.ai/en/reference/deployment`,
if err != nil {
return fmt.Errorf("a services.xml declaring your cluster(s) must exist: %w", err)
}
- target, err := cli.target(targetOptions{noCertificate: true})
- if err != nil {
- return err
- }
fmt.Fprint(cli.Stdout, "This will modify any existing ", color.YellowString("deployment.xml"), " and ", color.YellowString("services.xml"),
"!\nBefore modification a backup of the original file will be created.\n\n")
@@ -135,7 +135,7 @@ https://cloud.vespa.ai/en/reference/vespa-cloud-api#submission-properties
Example: `$ mvn package # when adding custom Java components
$ vespa prod deploy`,
RunE: func(cmd *cobra.Command, args []string) error {
- target, err := cli.target(targetOptions{noCertificate: true})
+ target, err := cli.target(targetOptions{noCertificate: true, cloudExclusive: true})
if err != nil {
return err
}
diff --git a/client/go/internal/cli/cmd/prod_test.go b/client/go/internal/cli/cmd/prod_test.go
index a01056b7178..944f09b3d42 100644
--- a/client/go/internal/cli/cmd/prod_test.go
+++ b/client/go/internal/cli/cmd/prod_test.go
@@ -44,6 +44,9 @@ func TestProdInit(t *testing.T) {
cli, _, _ := newTestCLI(t)
cli.Stdin = &buf
+ assert.Nil(t, cli.Run("config", "set", "target", "cloud"))
+ assert.Nil(t, cli.Run("config", "set", "application", "foo.bar"))
+ assert.Nil(t, cli.Run("auth", "api-key"))
assert.Nil(t, cli.Run("prod", "init", pkgDir))
// Verify contents
diff --git a/client/go/internal/cli/cmd/root.go b/client/go/internal/cli/cmd/root.go
index 69fd88c1b2b..c3a3db0df57 100644
--- a/client/go/internal/cli/cmd/root.go
+++ b/client/go/internal/cli/cmd/root.go
@@ -74,6 +74,8 @@ type targetOptions struct {
logLevel string
// noCertificate declares that no client certificate should be required when using this target.
noCertificate bool
+ // cloudExclusive specifies whether to only allow Vespa Cloud and Hosted Vespa targets
+ cloudExclusive bool
}
type targetType struct {
@@ -349,7 +351,7 @@ func (c *CLI) waiter(once bool, timeout time.Duration) *Waiter {
// target creates a target according the configuration of this CLI and given opts.
func (c *CLI) target(opts targetOptions) (vespa.Target, error) {
- targetType, err := c.targetType()
+ targetType, err := c.targetType(opts.cloudExclusive)
if err != nil {
return nil, err
}
@@ -374,7 +376,7 @@ func (c *CLI) target(opts targetOptions) (vespa.Target, error) {
}
// targetType resolves the real target type and its custom URL (if any)
-func (c *CLI) targetType() (targetType, error) {
+func (c *CLI) targetType(cloud bool) (targetType, error) {
v, err := c.config.targetOrURL()
if err != nil {
return targetType{}, err
@@ -387,6 +389,9 @@ func (c *CLI) targetType() (targetType, error) {
return targetType{}, err
}
}
+ if cloud && tt.name != vespa.TargetCloud && tt.name != vespa.TargetHosted {
+ return targetType{}, fmt.Errorf("unsupported target %s: this command only supports targets %s and %s", tt.name, vespa.TargetCloud, vespa.TargetHosted)
+ }
return tt, nil
}
diff --git a/client/go/internal/cli/cmd/waiter.go b/client/go/internal/cli/cmd/waiter.go
index 40d1d76518e..34a10ccce33 100644
--- a/client/go/internal/cli/cmd/waiter.go
+++ b/client/go/internal/cli/cmd/waiter.go
@@ -35,7 +35,7 @@ func (w *Waiter) DeployService(target vespa.Target) (*vespa.Service, error) {
// Service returns the service identified by cluster ID, available on target.
func (w *Waiter) Service(target vespa.Target, cluster string) (*vespa.Service, error) {
- targetType, err := w.cli.targetType()
+ targetType, err := w.cli.targetType(false)
if err != nil {
return nil, err
}
diff --git a/client/go/internal/vespa/deploy.go b/client/go/internal/vespa/deploy.go
index 1bfaf641243..d42c65cef1e 100644
--- a/client/go/internal/vespa/deploy.go
+++ b/client/go/internal/vespa/deploy.go
@@ -263,7 +263,7 @@ func Submit(opts DeploymentOptions, submission Submission) error {
return err
}
submitURL := opts.Target.Deployment().System.SubmitURL(opts.Target.Deployment())
- u, err := opts.url(submitURL)
+ u, err := url.Parse(submitURL)
if err != nil {
return err
}
diff --git a/client/go/internal/vespa/deploy_test.go b/client/go/internal/vespa/deploy_test.go
index 9addf81138a..693d4527624 100644
--- a/client/go/internal/vespa/deploy_test.go
+++ b/client/go/internal/vespa/deploy_test.go
@@ -99,6 +99,7 @@ func TestSubmit(t *testing.T) {
SourceURL: "https://github.com/foo/repo",
}))
require.Nil(t, httpClient.LastRequest.ParseMultipartForm(1<<20))
+ assert.Equal(t, "https://api-ctl.vespa-cloud.com:4443/application/v4/tenant/t1/application/a1/submit", httpClient.LastRequest.URL.String())
assert.Equal(t,
"{\"risk\":1,\"commit\":\"sha\",\"description\":\"broken garbage\",\"authorEmail\":\"foo@example.com\",\"sourceUrl\":\"https://github.com/foo/repo\"}",
httpClient.LastRequest.FormValue("submitOptions"))