diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-09-07 08:51:31 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-09-07 08:51:31 +0200 |
commit | 3484024d25aa6fb116c2b1958e252c15f3227db4 (patch) | |
tree | e2ba45f3a3d9f688301a0726707d52edafb8995b /client | |
parent | 39bf4a6d515e43b79aa8b145a2da55eb9101ee69 (diff) |
Support building with Go 1.15
Diffstat (limited to 'client')
-rw-r--r-- | client/go/cmd/api_key.go | 6 | ||||
-rw-r--r-- | client/go/cmd/deploy.go | 5 | ||||
-rw-r--r-- | client/go/cmd/helpers.go | 3 | ||||
-rw-r--r-- | client/go/go.mod | 2 | ||||
-rw-r--r-- | client/go/vespa/crypto.go | 7 | ||||
-rw-r--r-- | client/go/vespa/deploy.go | 2 | ||||
-rw-r--r-- | client/go/vespa/deploy_test.go | 3 | ||||
-rw-r--r-- | client/go/vespa/target.go | 4 |
8 files changed, 18 insertions, 14 deletions
diff --git a/client/go/cmd/api_key.go b/client/go/cmd/api_key.go index 37d849ff372..c3a111b0f15 100644 --- a/client/go/cmd/api_key.go +++ b/client/go/cmd/api_key.go @@ -5,8 +5,8 @@ package cmd import ( "fmt" + "io/ioutil" "log" - "os" "path/filepath" "github.com/spf13/cobra" @@ -48,7 +48,7 @@ var apiKeyCmd = &cobra.Command{ fatalErr(err, "Could not create API key") return } - if err := os.WriteFile(apiKeyFile, apiKey, 0600); err == nil { + if err := ioutil.WriteFile(apiKeyFile, apiKey, 0600); err == nil { printSuccess("API private key written to ", apiKeyFile) printPublicKey(apiKeyFile, app.Tenant) } else { @@ -58,7 +58,7 @@ var apiKeyCmd = &cobra.Command{ } func printPublicKey(apiKeyFile, tenant string) { - pemKeyData, err := os.ReadFile(apiKeyFile) + pemKeyData, err := ioutil.ReadFile(apiKeyFile) if err != nil { fatalErr(err, "Failed to read ", apiKeyFile) return diff --git a/client/go/cmd/deploy.go b/client/go/cmd/deploy.go index 27578c29a18..2a9ababddaa 100644 --- a/client/go/cmd/deploy.go +++ b/client/go/cmd/deploy.go @@ -6,6 +6,7 @@ package cmd import ( "fmt" + "io/ioutil" "log" "os" "path/filepath" @@ -135,13 +136,13 @@ func writeSessionID(appConfigDir string, sessionID int64) { if err := os.MkdirAll(appConfigDir, 0755); err != nil { fatalErr(err, "Could not create directory for session ID") } - if err := os.WriteFile(sessionIDFile(appConfigDir), []byte(fmt.Sprintf("%d\n", sessionID)), 0600); err != nil { + if err := ioutil.WriteFile(sessionIDFile(appConfigDir), []byte(fmt.Sprintf("%d\n", sessionID)), 0600); err != nil { fatalErr(err, "Could not write session ID") } } func readSessionID(appConfigDir string) int64 { - b, err := os.ReadFile(sessionIDFile(appConfigDir)) + b, err := ioutil.ReadFile(sessionIDFile(appConfigDir)) if err != nil { fatalErr(err, "Could not read session ID") } diff --git a/client/go/cmd/helpers.go b/client/go/cmd/helpers.go index ba52a911740..67124ec2417 100644 --- a/client/go/cmd/helpers.go +++ b/client/go/cmd/helpers.go @@ -7,6 +7,7 @@ package cmd import ( "crypto/tls" "fmt" + "io/ioutil" "log" "os" "path/filepath" @@ -51,7 +52,7 @@ func printSuccess(msg ...interface{}) { func readAPIKey(tenant string) []byte { configDir := configDir("") apiKeyPath := filepath.Join(configDir, tenant+".api-key.pem") - key, err := os.ReadFile(apiKeyPath) + key, err := ioutil.ReadFile(apiKeyPath) if err != nil { fatalErrHint(err, "Deployment to cloud requires an API key. Try 'vespa api-key'") } diff --git a/client/go/go.mod b/client/go/go.mod index 0558f677c72..893add7218b 100644 --- a/client/go/go.mod +++ b/client/go/go.mod @@ -1,6 +1,6 @@ module github.com/vespa-engine/vespa/client/go -go 1.16 +go 1.15 require ( github.com/logrusorgru/aurora v2.0.3+incompatible diff --git a/client/go/vespa/crypto.go b/client/go/vespa/crypto.go index 56631ce3d0a..d45a4605ff8 100644 --- a/client/go/vespa/crypto.go +++ b/client/go/vespa/crypto.go @@ -15,6 +15,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "math/big" "net/http" "os" @@ -45,12 +46,12 @@ func (kp *PemKeyPair) WritePrivateKeyFile(privateKeyFile string, overwrite bool) } func atomicWriteFile(filename string, data []byte, overwrite bool) error { - tmpFile, err := os.CreateTemp("", tempFilePattern) + tmpFile, err := ioutil.TempFile("", tempFilePattern) if err != nil { return err } defer os.Remove(tmpFile.Name()) - if err := os.WriteFile(tmpFile.Name(), data, 0600); err != nil { + if err := ioutil.WriteFile(tmpFile.Name(), data, 0600); err != nil { return err } _, err = os.Stat(filename) @@ -142,7 +143,7 @@ func (rs *RequestSigner) SignRequest(request *http.Request) error { return err } base64Signature := base64.StdEncoding.EncodeToString(signature) - request.Body = io.NopCloser(body) + request.Body = ioutil.NopCloser(body) request.Header.Set("X-Timestamp", timestamp) request.Header.Set("X-Content-Hash", contentHash) request.Header.Set("X-Key-Id", rs.KeyID) diff --git a/client/go/vespa/deploy.go b/client/go/vespa/deploy.go index 04ab5916d1f..dd66edf7122 100644 --- a/client/go/vespa/deploy.go +++ b/client/go/vespa/deploy.go @@ -236,7 +236,7 @@ func uploadApplicationPackage(url *url.URL, opts DeploymentOpts) (int64, error) URL: url, Method: "POST", Header: header, - Body: io.NopCloser(zipReader), + Body: ioutil.NopCloser(zipReader), } if opts.APIKey != nil { signer := NewRequestSigner(opts.Deployment.Application.SerializedForm(), opts.APIKey) diff --git a/client/go/vespa/deploy_test.go b/client/go/vespa/deploy_test.go index fa2098b2231..f99d42f537e 100644 --- a/client/go/vespa/deploy_test.go +++ b/client/go/vespa/deploy_test.go @@ -1,6 +1,7 @@ package vespa import ( + "io/ioutil" "os" "path/filepath" "testing" @@ -56,6 +57,6 @@ func TestApplicationPackageFrom(t *testing.T) { func writeFile(t *testing.T, filename string) { err := os.MkdirAll(filepath.Dir(filename), 0755) assert.Nil(t, err) - err = os.WriteFile(filename, []byte{0}, 0644) + err = ioutil.WriteFile(filename, []byte{0}, 0644) assert.Nil(t, err) } diff --git a/client/go/vespa/target.go b/client/go/vespa/target.go index 33c50df9540..493f3ec3485 100644 --- a/client/go/vespa/target.go +++ b/client/go/vespa/target.go @@ -4,7 +4,7 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io" + "io/ioutil" "net/http" "time" @@ -230,7 +230,7 @@ func wait(fn responseFunc, req *http.Request, certificate tls.Certificate, timeo response, httpErr = util.HttpDo(req, 10*time.Second, "") if httpErr == nil { statusCode = response.StatusCode - body, err := io.ReadAll(response.Body) + body, err := ioutil.ReadAll(response.Body) if err != nil { return 0, "", err } |