aboutsummaryrefslogtreecommitdiffstats
path: root/client/go
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2023-11-30 11:08:49 +0100
committerMartin Polden <mpolden@mpolden.no>2023-11-30 11:08:49 +0100
commitf41b3b749dd2f626779064a57b6650198a4cfb00 (patch)
treea0dab51b1cbbc47ab416ffcb6e5c9b4fb792ebaf /client/go
parent0a1f86f20af0eb57e4cb1381f2491f47a711b715 (diff)
Quote printed paths
Diffstat (limited to 'client/go')
-rw-r--r--client/go/internal/cli/cmd/api_key.go8
-rw-r--r--client/go/internal/cli/cmd/cert.go16
-rw-r--r--client/go/internal/cli/cmd/cert_test.go16
-rw-r--r--client/go/internal/cli/cmd/deploy.go6
-rw-r--r--client/go/internal/cli/cmd/deploy_test.go8
-rw-r--r--client/go/internal/cli/cmd/prod.go4
-rw-r--r--client/go/internal/cli/cmd/prod_test.go6
-rw-r--r--client/go/internal/vespa/application.go2
8 files changed, 33 insertions, 33 deletions
diff --git a/client/go/internal/cli/cmd/api_key.go b/client/go/internal/cli/cmd/api_key.go
index d882c527516..17da8d602e5 100644
--- a/client/go/internal/cli/cmd/api_key.go
+++ b/client/go/internal/cli/cmd/api_key.go
@@ -72,7 +72,7 @@ func doApiKey(cli *CLI, overwriteKey bool, args []string) error {
}
apiKeyFile := cli.config.apiKeyPath(app.Tenant)
if ioutil.Exists(apiKeyFile) && !overwriteKey {
- err := fmt.Errorf("refusing to overwrite %s", apiKeyFile)
+ err := fmt.Errorf("refusing to overwrite '%s'", apiKeyFile)
cli.printErr(err, "Use -f to overwrite it")
printPublicKey(system, apiKeyFile, app.Tenant)
return ErrCLI{error: err, quiet: true}
@@ -82,17 +82,17 @@ func doApiKey(cli *CLI, overwriteKey bool, args []string) error {
return fmt.Errorf("could not create api key: %w", err)
}
if err := os.WriteFile(apiKeyFile, apiKey, 0600); err == nil {
- cli.printSuccess("Developer private key written to ", apiKeyFile)
+ cli.printSuccess("Developer private key written to '", apiKeyFile, "'")
return printPublicKey(system, apiKeyFile, app.Tenant)
} else {
- return fmt.Errorf("failed to write: %s: %w", apiKeyFile, err)
+ return fmt.Errorf("failed to write: '%s': %w", apiKeyFile, err)
}
}
func printPublicKey(system vespa.System, apiKeyFile, tenant string) error {
pemKeyData, err := os.ReadFile(apiKeyFile)
if err != nil {
- return fmt.Errorf("failed to read: %s: %w", apiKeyFile, err)
+ return fmt.Errorf("failed to read: '%s': %w", apiKeyFile, err)
}
key, err := vespa.ECPrivateKeyFrom(pemKeyData)
if err != nil {
diff --git a/client/go/internal/cli/cmd/cert.go b/client/go/internal/cli/cmd/cert.go
index 3e18fafb815..14e4861cec3 100644
--- a/client/go/internal/cli/cmd/cert.go
+++ b/client/go/internal/cli/cmd/cert.go
@@ -123,10 +123,10 @@ func doCert(cli *CLI, overwriteCertificate, skipApplicationPackage bool, args []
if !overwriteCertificate {
hint := "Use -f flag to force overwriting"
if ioutil.Exists(privateKeyFile.path) {
- return errHint(fmt.Errorf("private key %s already exists", color.CyanString(privateKeyFile.path)), hint)
+ return errHint(fmt.Errorf("private key '%s' already exists", color.CyanString(privateKeyFile.path)), hint)
}
if ioutil.Exists(certificateFile.path) {
- return errHint(fmt.Errorf("certificate %s already exists", color.CyanString(certificateFile.path)), hint)
+ return errHint(fmt.Errorf("certificate '%s' already exists", color.CyanString(certificateFile.path)), hint)
}
}
@@ -140,8 +140,8 @@ func doCert(cli *CLI, overwriteCertificate, skipApplicationPackage bool, args []
if err := keyPair.WritePrivateKeyFile(privateKeyFile.path, overwriteCertificate); err != nil {
return fmt.Errorf("could not write private key: %w", err)
}
- cli.printSuccess("Certificate written to ", color.CyanString(certificateFile.path))
- cli.printSuccess("Private key written to ", color.CyanString(privateKeyFile.path))
+ cli.printSuccess("Certificate written to ", color.CyanString("'"+certificateFile.path+"'"))
+ cli.printSuccess("Private key written to ", color.CyanString("'"+privateKeyFile.path+"'"))
if !skipApplicationPackage {
return doCertAdd(cli, overwriteCertificate, args)
}
@@ -158,7 +158,7 @@ func doCertAdd(cli *CLI, overwriteCertificate bool, args []string) error {
return err
}
if pkg.HasCertificate() && !overwriteCertificate {
- return errHint(fmt.Errorf("application package %s already contains a certificate", pkg.Path), "Use -f flag to force overwriting")
+ return errHint(fmt.Errorf("application package '%s' already contains a certificate", pkg.Path), "Use -f flag to force overwriting")
}
return maybeCopyCertificate(true, false, cli, target, pkg)
}
@@ -166,13 +166,13 @@ func doCertAdd(cli *CLI, overwriteCertificate bool, args []string) error {
func maybeCopyCertificate(force, ignoreZip bool, cli *CLI, target vespa.Target, pkg vespa.ApplicationPackage) error {
if pkg.IsZip() {
if ignoreZip {
- cli.printWarning("Cannot verify existence of "+color.CyanString("security/clients.pem")+" since "+pkg.Path+" is compressed",
+ cli.printWarning("Cannot verify existence of "+color.CyanString("security/clients.pem")+" since '"+pkg.Path+"' is compressed",
"Deployment to Vespa Cloud requires certificate in application package",
"See https://cloud.vespa.ai/en/security/guide")
return nil
} else {
hint := "Try running 'mvn clean', then 'vespa auth cert add' and finally 'mvn package'"
- return errHint(fmt.Errorf("cannot add certificate to compressed application package: %s", pkg.Path), hint)
+ return errHint(fmt.Errorf("cannot add certificate to compressed application package: '%s'", pkg.Path), hint)
}
}
if force {
@@ -215,7 +215,7 @@ func copyCertificate(cli *CLI, target vespa.Target, pkg vespa.ApplicationPackage
}
err = ioutil.AtomicWriteFile(dstPath, data)
if err == nil {
- cli.printSuccess("Copied certificate from ", tlsOptions.CertificateFile, " to ", dstPath)
+ cli.printSuccess("Copied certificate from '", tlsOptions.CertificateFile, "' to '", dstPath, "'")
}
return err
}
diff --git a/client/go/internal/cli/cmd/cert_test.go b/client/go/internal/cli/cmd/cert_test.go
index 61e90e21176..10241d0483c 100644
--- a/client/go/internal/cli/cmd/cert_test.go
+++ b/client/go/internal/cli/cmd/cert_test.go
@@ -46,7 +46,7 @@ func testCert(t *testing.T, subcommand []string) {
certificate := filepath.Join(homeDir, app.String(), "data-plane-public-cert.pem")
privateKey := filepath.Join(homeDir, app.String(), "data-plane-private-key.pem")
- assert.Equal(t, fmt.Sprintf("Success: Certificate written to %s\nSuccess: Private key written to %s\nSuccess: Copied certificate from %s to %s\n", certificate, privateKey, certificate, pkgCertificate), stdout.String())
+ assert.Equal(t, fmt.Sprintf("Success: Certificate written to '%s'\nSuccess: Private key written to '%s'\nSuccess: Copied certificate from '%s' to '%s'\n", certificate, privateKey, certificate, pkgCertificate), stdout.String())
}
func TestCertCompressedPackage(t *testing.T) {
@@ -87,13 +87,13 @@ func TestCertAdd(t *testing.T) {
pkgCertificate := filepath.Join(appDir, "security", "clients.pem")
homeDir := cli.config.homeDir
certificate := filepath.Join(homeDir, "t1.a1.i1", "data-plane-public-cert.pem")
- assert.Equal(t, fmt.Sprintf("Success: Copied certificate from %s to %s\n", certificate, pkgCertificate), stdout.String())
+ assert.Equal(t, fmt.Sprintf("Success: Copied certificate from '%s' to '%s'\n", certificate, pkgCertificate), stdout.String())
require.NotNil(t, cli.Run("auth", "cert", "add", pkgDir))
- assert.Contains(t, stderr.String(), fmt.Sprintf("Error: application package %s already contains a certificate", appDir))
+ assert.Contains(t, stderr.String(), fmt.Sprintf("Error: application package '%s' already contains a certificate", appDir))
stdout.Reset()
require.Nil(t, cli.Run("auth", "cert", "add", "-f", pkgDir))
- assert.Equal(t, fmt.Sprintf("Success: Copied certificate from %s to %s\n", certificate, pkgCertificate), stdout.String())
+ assert.Equal(t, fmt.Sprintf("Success: Copied certificate from '%s' to '%s'\n", certificate, pkgCertificate), stdout.String())
}
func TestCertNoAdd(t *testing.T) {
@@ -108,17 +108,17 @@ func TestCertNoAdd(t *testing.T) {
certificate := filepath.Join(homeDir, app.String(), "data-plane-public-cert.pem")
privateKey := filepath.Join(homeDir, app.String(), "data-plane-private-key.pem")
- assert.Equal(t, fmt.Sprintf("Success: Certificate written to %s\nSuccess: Private key written to %s\n", certificate, privateKey), stdout.String())
+ assert.Equal(t, fmt.Sprintf("Success: Certificate written to '%s'\nSuccess: Private key written to '%s'\n", certificate, privateKey), stdout.String())
require.NotNil(t, cli.Run("auth", "cert", "-N"))
- assert.Contains(t, stderr.String(), fmt.Sprintf("Error: private key %s already exists", privateKey))
+ assert.Contains(t, stderr.String(), fmt.Sprintf("Error: private key '%s' already exists", privateKey))
require.Nil(t, os.Remove(privateKey))
stderr.Reset()
require.NotNil(t, cli.Run("auth", "cert", "-N"))
- assert.Contains(t, stderr.String(), fmt.Sprintf("Error: certificate %s already exists", certificate))
+ assert.Contains(t, stderr.String(), fmt.Sprintf("Error: certificate '%s' already exists", certificate))
stdout.Reset()
require.Nil(t, cli.Run("auth", "cert", "-N", "-f"))
- assert.Equal(t, fmt.Sprintf("Success: Certificate written to %s\nSuccess: Private key written to %s\n", certificate, privateKey), stdout.String())
+ assert.Equal(t, fmt.Sprintf("Success: Certificate written to '%s'\nSuccess: Private key written to '%s'\n", certificate, privateKey), stdout.String())
}
diff --git a/client/go/internal/cli/cmd/deploy.go b/client/go/internal/cli/cmd/deploy.go
index c9331a540eb..9ae6676bc17 100644
--- a/client/go/internal/cli/cmd/deploy.go
+++ b/client/go/internal/cli/cmd/deploy.go
@@ -86,9 +86,9 @@ $ vespa deploy -t cloud -z perf.aws-us-east-1c`,
}
log.Println()
if opts.Target.IsCloud() {
- cli.printSuccess("Triggered deployment of ", color.CyanString(pkg.Path), " with run ID ", color.CyanString(strconv.FormatInt(result.ID, 10)))
+ cli.printSuccess("Triggered deployment of ", color.CyanString("'"+pkg.Path+"'"), " with run ID ", color.CyanString(strconv.FormatInt(result.ID, 10)))
} else {
- cli.printSuccess("Deployed ", color.CyanString(pkg.Path), " with session ID ", color.CyanString(strconv.FormatInt(result.ID, 10)))
+ cli.printSuccess("Deployed ", color.CyanString("'"+pkg.Path+"'"), " with session ID ", color.CyanString(strconv.FormatInt(result.ID, 10)))
printPrepareLog(cli.Stderr, result)
}
if opts.Target.IsCloud() {
@@ -133,7 +133,7 @@ func newPrepareCmd(cli *CLI) *cobra.Command {
if err := cli.config.writeSessionID(vespa.DefaultApplication, result.ID); err != nil {
return fmt.Errorf("could not write session id: %w", err)
}
- cli.printSuccess("Prepared ", color.CyanString(pkg.Path), " with session ", result.ID)
+ cli.printSuccess("Prepared ", color.CyanString("'"+pkg.Path+"'"), " with session ", result.ID)
printPrepareLog(cli.Stderr, result)
return nil
},
diff --git a/client/go/internal/cli/cmd/deploy_test.go b/client/go/internal/cli/cmd/deploy_test.go
index f34faa21de1..4e32b9bbd60 100644
--- a/client/go/internal/cli/cmd/deploy_test.go
+++ b/client/go/internal/cli/cmd/deploy_test.go
@@ -84,7 +84,7 @@ func TestDeployWait(t *testing.T) {
mockServiceStatus(client, "foo") // Look up services
assert.Nil(t, cli.Run("deploy", "--wait=3", pkg))
assert.Equal(t,
- "\nSuccess: Deployed "+pkg+" with session ID 1\n",
+ "\nSuccess: Deployed '"+pkg+"' with session ID 1\n",
stdout.String())
}
@@ -112,7 +112,7 @@ func TestDeployZipWithURLTargetArgument(t *testing.T) {
cli.httpClient = client
assert.Nil(t, cli.Run(arguments...))
assert.Equal(t,
- "\nSuccess: Deployed "+applicationPackage+" with session ID 0\n",
+ "\nSuccess: Deployed '"+applicationPackage+"' with session ID 0\n",
stdout.String())
assertDeployRequestMade("http://target:19071", client, t)
}
@@ -188,7 +188,7 @@ func assertDeploy(applicationPackage string, arguments []string, t *testing.T) {
cli.httpClient = client
assert.Nil(t, cli.Run(arguments...))
assert.Equal(t,
- "\nSuccess: Deployed "+applicationPackage+" with session ID 0\n",
+ "\nSuccess: Deployed '"+applicationPackage+"' with session ID 0\n",
stdout.String())
assertDeployRequestMade("http://127.0.0.1:19071", client, t)
}
@@ -202,7 +202,7 @@ func assertPrepare(applicationPackage string, arguments []string, t *testing.T)
cli.httpClient = client
assert.Nil(t, cli.Run(arguments...))
assert.Equal(t,
- "Success: Prepared "+applicationPackage+" with session 42\n",
+ "Success: Prepared '"+applicationPackage+"' with session 42\n",
stdout.String())
assertPackageUpload(0, "http://127.0.0.1:19071/application/v2/tenant/default/session", client, t)
diff --git a/client/go/internal/cli/cmd/prod.go b/client/go/internal/cli/cmd/prod.go
index 0912ca31e25..444730c0146 100644
--- a/client/go/internal/cli/cmd/prod.go
+++ b/client/go/internal/cli/cmd/prod.go
@@ -63,7 +63,7 @@ https://cloud.vespa.ai/en/reference/deployment`,
return err
}
if pkg.IsZip() {
- return errHint(fmt.Errorf("cannot modify compressed application package %s", pkg.Path),
+ return errHint(fmt.Errorf("cannot modify compressed application package '%s'", pkg.Path),
"Try running 'mvn clean' and run this command again")
}
@@ -169,7 +169,7 @@ $ vespa prod deploy`,
if err != nil {
return fmt.Errorf("could not deploy application: %w", err)
} else {
- cli.printSuccess(fmt.Sprintf("Deployed %s with build number %s", color.CyanString(pkg.Path), color.CyanString(strconv.FormatInt(build, 10))))
+ cli.printSuccess(fmt.Sprintf("Deployed '%s' with build number %s", color.CyanString(pkg.Path), color.CyanString(strconv.FormatInt(build, 10))))
log.Printf("See %s for deployment progress\n", color.CyanString(fmt.Sprintf("%s/tenant/%s/application/%s/prod/deployment",
deployment.Target.Deployment().System.ConsoleURL, deployment.Target.Deployment().Application.Tenant, deployment.Target.Deployment().Application.Application)))
}
diff --git a/client/go/internal/cli/cmd/prod_test.go b/client/go/internal/cli/cmd/prod_test.go
index 6d8a50124ac..4fed8de7d44 100644
--- a/client/go/internal/cli/cmd/prod_test.go
+++ b/client/go/internal/cli/cmd/prod_test.go
@@ -190,12 +190,12 @@ func prodDeploy(pkgDir string, t *testing.T) {
cli.Environment["VESPA_CLI_API_KEY_FILE"] = filepath.Join(cli.config.homeDir, "t1.api-key.pem")
httpClient.NextResponseString(200, `{"build": 42}`)
assert.Nil(t, cli.Run("prod", "deploy", "--add-cert"))
- assert.Contains(t, stdout.String(), "Success: Deployed . with build number 42")
+ assert.Contains(t, stdout.String(), "Success: Deployed '.' with build number 42")
assert.Contains(t, stdout.String(), "See https://console.vespa-cloud.com/tenant/t1/application/a1/prod/deployment for deployment progress")
stdout.Reset()
httpClient.NextResponseString(200, `{"build": 43}`)
assert.Nil(t, cli.Run("prod", "submit", "--add-cert")) // old variant also works
- assert.Contains(t, stdout.String(), "Success: Deployed . with build number 43")
+ assert.Contains(t, stdout.String(), "Success: Deployed '.' with build number 43")
assert.Contains(t, stdout.String(), "See https://console.vespa-cloud.com/tenant/t1/application/a1/prod/deployment for deployment progress")
}
@@ -216,7 +216,7 @@ func TestProdDeployWithJava(t *testing.T) {
cli.Environment["VESPA_CLI_API_KEY_FILE"] = filepath.Join(cli.config.homeDir, "t1.api-key.pem")
assert.Nil(t, cli.Run("prod", "deploy", "--add-cert", pkgDir))
assert.Equal(t, "", stderr.String())
- assert.Contains(t, stdout.String(), "Success: Deployed "+pkgDir+"/target/application with build number 42")
+ assert.Contains(t, stdout.String(), "Success: Deployed '"+pkgDir+"/target/application' with build number 42")
assert.Contains(t, stdout.String(), "See https://console.vespa-cloud.com/tenant/t1/application/a1/prod/deployment for deployment progress")
}
diff --git a/client/go/internal/vespa/application.go b/client/go/internal/vespa/application.go
index 5d1ab610e38..a65fb41d783 100644
--- a/client/go/internal/vespa/application.go
+++ b/client/go/internal/vespa/application.go
@@ -160,7 +160,7 @@ func (ap *ApplicationPackage) zipReader(test bool) (io.ReadCloser, error) {
}
f, err := os.Open(zipFile)
if err != nil {
- return nil, fmt.Errorf("could not open application package at %s: %w", ap.Path, err)
+ return nil, fmt.Errorf("could not open application package at '%s': %w", ap.Path, err)
}
return f, nil
}