From e6a146bf0df73010e87b13f2d1ea5531687b5a09 Mon Sep 17 00:00:00 2001 From: Igor Lysak Date: Mon, 5 Aug 2024 16:52:16 +0300 Subject: [PATCH] Clean up code from deprecations #94 (#96) * Enable staticcheck for deprications * Stop using depricated io/ioutil * Stop using depricated strings.Title * Stop using depricated os.SEEK_SET * Stop using depricated rand.Seed * Stop using depricated google.golang.org/genproto/googleapis/cloud/kms/v1 --- cmd/hub/api/cloudaccount.go | 3 +-- cmd/hub/api/cluster.go | 3 +-- cmd/hub/api/filecache.go | 3 ++- cmd/hub/aws/s3.go | 4 ++-- cmd/hub/azure/blobs.go | 4 ++-- cmd/hub/cmd/application.go | 6 +++--- cmd/hub/cmd/component.go | 6 +++--- cmd/hub/cmd/environment.go | 4 ++-- cmd/hub/cmd/instance.go | 6 +++--- cmd/hub/cmd/secret.go | 4 ++-- cmd/hub/cmd/template.go | 6 +++--- cmd/hub/cmd/util.go | 4 ++-- cmd/hub/compose/elaborate.go | 4 +++- cmd/hub/filecache/cache.go | 4 ++-- cmd/hub/gcp/gcs.go | 4 ++-- cmd/hub/gcp/kms.go | 2 +- cmd/hub/kube/kubeconfig.go | 6 +++--- cmd/hub/lifecycle/ask.go | 3 +-- cmd/hub/lifecycle/backup.go | 5 +++-- cmd/hub/lifecycle/deploy.go | 6 +++--- cmd/hub/lifecycle/outputs.go | 4 ++-- cmd/hub/lifecycle/probe.go | 4 ++-- cmd/hub/lifecycle/requirement.go | 3 +-- cmd/hub/lifecycle/template.go | 4 ++-- cmd/hub/metrics/meter.go | 2 +- cmd/hub/storage/print.go | 5 +++-- cmd/hub/storage/read.go | 7 ++++--- cmd/hub/util/gzip.go | 4 ++-- cmd/hub/util/util.go | 4 +++- go.mod | 4 ++-- staticcheck.conf | 2 +- 31 files changed, 67 insertions(+), 63 deletions(-) diff --git a/cmd/hub/api/cloudaccount.go b/cmd/hub/api/cloudaccount.go index 12bdc499..61635dff 100644 --- a/cmd/hub/api/cloudaccount.go +++ b/cmd/hub/api/cloudaccount.go @@ -13,7 +13,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net/url" "os" @@ -556,7 +555,7 @@ func cloudSpecificCredentials(provider, region string, args []string) (string, m return "", nil, fmt.Errorf("Unable to open credentials file: %v", err) } defer file.Close() - data, err := ioutil.ReadAll(file) + data, err := io.ReadAll(file) if err != nil { return "", nil, fmt.Errorf("Unable to read credentials file `%s`: %v", credentialsFile, err) } diff --git a/cmd/hub/api/cluster.go b/cmd/hub/api/cluster.go index 4cabec17..902efaab 100644 --- a/cmd/hub/api/cluster.go +++ b/cmd/hub/api/cluster.go @@ -16,7 +16,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net" "os" @@ -609,7 +608,7 @@ func readImportSecrets(secretsOrder []Secret, pems io.Reader) ([]Secret, error) } log.Printf("Reading TLS auth certs and key%s", stdin) } - pemBytes, err := ioutil.ReadAll(pems) + pemBytes, err := io.ReadAll(pems) if err != nil { return nil, err } diff --git a/cmd/hub/api/filecache.go b/cmd/hub/api/filecache.go index 952c79d8..aca80287 100644 --- a/cmd/hub/api/filecache.go +++ b/cmd/hub/api/filecache.go @@ -11,6 +11,7 @@ package api import ( "errors" "hash/crc64" + "io" "os" "github.com/epam/hubctl/cmd/hub/filecache" @@ -50,7 +51,7 @@ func storeAccessToken(apiBaseUrl, loginToken string, tokens *SigninResponse) err return errors.New("No cache file created") } defer file.Close() - _, err = file.Seek(0, os.SEEK_SET) + _, err = file.Seek(0, io.SeekStart) if err != nil { return err } diff --git a/cmd/hub/aws/s3.go b/cmd/hub/aws/s3.go index bb67484b..1eb6bba5 100644 --- a/cmd/hub/aws/s3.go +++ b/cmd/hub/aws/s3.go @@ -9,7 +9,7 @@ package aws import ( "bytes" "fmt" - "io/ioutil" + "io" "log" "net/url" "os" @@ -110,7 +110,7 @@ func ReadS3(s3path string) ([]byte, error) { if err != nil { return nil, fmt.Errorf("Failed to GET S3 object `%s`: %v\n\t%s", s3path, err, optionsHelp) } - data, err := ioutil.ReadAll(obj.Body) + data, err := io.ReadAll(obj.Body) if err != nil { return nil, fmt.Errorf("Failed to read S3 object `%s`: %v", s3path, err) } diff --git a/cmd/hub/azure/blobs.go b/cmd/hub/azure/blobs.go index 4902a3ce..8fa431e3 100644 --- a/cmd/hub/azure/blobs.go +++ b/cmd/hub/azure/blobs.go @@ -9,7 +9,7 @@ package azure import ( "errors" "fmt" - "io/ioutil" + "io" "net/url" "os" "strings" @@ -95,7 +95,7 @@ func ReadStorageBlob(path string) ([]byte, error) { return nil, err } defer reader.Close() - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { return nil, fmt.Errorf("Failed to read Azure storage blob `%s`: %v", path, err) } diff --git a/cmd/hub/cmd/application.go b/cmd/hub/cmd/application.go index aa6cee7e..45309103 100644 --- a/cmd/hub/cmd/application.go +++ b/cmd/hub/cmd/application.go @@ -12,7 +12,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "os" "github.com/spf13/cobra" @@ -109,7 +109,7 @@ func installApplication(args []string) error { if createRaw { api.RawInstallApplication(os.Stdin, waitAndTailDeployLogs) } else { - createBytes, err := ioutil.ReadAll(os.Stdin) + createBytes, err := io.ReadAll(os.Stdin) if err != nil || len(createBytes) < 3 { return fmt.Errorf("Unable to read data (read %d bytes): %v", len(createBytes), err) } @@ -133,7 +133,7 @@ func patchApplication(args []string) error { if patchRaw { api.RawPatchApplication(selector, os.Stdin, waitAndTailDeployLogs) } else { - patchBytes, err := ioutil.ReadAll(os.Stdin) + patchBytes, err := io.ReadAll(os.Stdin) if err != nil || len(patchBytes) < 3 { return fmt.Errorf("Unable to read patch data (read %d bytes): %v", len(patchBytes), err) } diff --git a/cmd/hub/cmd/component.go b/cmd/hub/cmd/component.go index dde9c5e6..6d0fd47b 100644 --- a/cmd/hub/cmd/component.go +++ b/cmd/hub/cmd/component.go @@ -12,7 +12,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "os" "github.com/spf13/cobra" @@ -137,7 +137,7 @@ func createComponent(args []string) error { if createRaw { api.RawCreateComponent(os.Stdin) } else { - createBytes, err := ioutil.ReadAll(os.Stdin) + createBytes, err := io.ReadAll(os.Stdin) if err != nil || len(createBytes) < 3 { return fmt.Errorf("Unable to read data (read %d bytes): %v", len(createBytes), err) } @@ -161,7 +161,7 @@ func patchComponent(args []string) error { if patchRaw { api.RawPatchComponent(selector, os.Stdin) } else { - patchBytes, err := ioutil.ReadAll(os.Stdin) + patchBytes, err := io.ReadAll(os.Stdin) if err != nil || len(patchBytes) < 3 { return fmt.Errorf("Unable to read patch data (read %d bytes): %v", len(patchBytes), err) } diff --git a/cmd/hub/cmd/environment.go b/cmd/hub/cmd/environment.go index 1e8e7c22..bf974db8 100644 --- a/cmd/hub/cmd/environment.go +++ b/cmd/hub/cmd/environment.go @@ -12,7 +12,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "os" "github.com/spf13/cobra" @@ -152,7 +152,7 @@ func patchEnvironment(args []string) error { if patchRaw { api.RawPatchEnvironment(selector, os.Stdin) } else { - patchBytes, err := ioutil.ReadAll(os.Stdin) + patchBytes, err := io.ReadAll(os.Stdin) if err != nil || len(patchBytes) < 3 { return fmt.Errorf("Unable to read patch data (read %d bytes): %v", len(patchBytes), err) } diff --git a/cmd/hub/cmd/instance.go b/cmd/hub/cmd/instance.go index 6d9af105..8d1ea198 100644 --- a/cmd/hub/cmd/instance.go +++ b/cmd/hub/cmd/instance.go @@ -12,7 +12,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "os" "strconv" @@ -254,7 +254,7 @@ func createInstance(args []string) error { if createRaw { api.RawCreateStackInstance(os.Stdin) } else { - createBytes, err := ioutil.ReadAll(os.Stdin) + createBytes, err := io.ReadAll(os.Stdin) if err != nil || len(createBytes) < 3 { return fmt.Errorf("Unable to read data (read %d bytes): %v", len(createBytes), err) } @@ -278,7 +278,7 @@ func patchInstance(args []string) error { if patchRaw { api.RawPatchStackInstance(selector, os.Stdin, patchReplace) } else { - patchBytes, err := ioutil.ReadAll(os.Stdin) + patchBytes, err := io.ReadAll(os.Stdin) if err != nil || len(patchBytes) < 3 { return fmt.Errorf("Unable to read patch data (read %d bytes): %v", len(patchBytes), err) } diff --git a/cmd/hub/cmd/secret.go b/cmd/hub/cmd/secret.go index 3851ed2e..b9d92777 100644 --- a/cmd/hub/cmd/secret.go +++ b/cmd/hub/cmd/secret.go @@ -11,7 +11,7 @@ package cmd import ( "errors" "fmt" - "io/ioutil" + "io" "os" "strings" @@ -89,7 +89,7 @@ func createSecret(entityKind string, args []string) error { value = value[len(maybeKey)+1:] } if value == "-" { - valueBytes, err := ioutil.ReadAll(os.Stdin) + valueBytes, err := io.ReadAll(os.Stdin) if err != nil || len(valueBytes) == 0 { return fmt.Errorf("Bad secret value read from stdin (read %d bytes): %s", len(valueBytes), util.Errors2(err)) diff --git a/cmd/hub/cmd/template.go b/cmd/hub/cmd/template.go index 2d3f81f1..0dfda526 100644 --- a/cmd/hub/cmd/template.go +++ b/cmd/hub/cmd/template.go @@ -12,7 +12,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "os" "github.com/spf13/cobra" @@ -166,7 +166,7 @@ func createTemplate(args []string) error { if createRaw { api.RawCreateTemplate(os.Stdin) } else { - createBytes, err := ioutil.ReadAll(os.Stdin) + createBytes, err := io.ReadAll(os.Stdin) if err != nil || len(createBytes) < 3 { return fmt.Errorf("Unable to read data (read %d bytes): %v", len(createBytes), err) } @@ -200,7 +200,7 @@ func patchTemplate(args []string) error { if patchRaw { api.RawPatchTemplate(selector, os.Stdin) } else { - patchBytes, err := ioutil.ReadAll(os.Stdin) + patchBytes, err := io.ReadAll(os.Stdin) if err != nil || len(patchBytes) < 3 { return fmt.Errorf("Unable to read patch data (read %d bytes): %v", len(patchBytes), err) } diff --git a/cmd/hub/cmd/util.go b/cmd/hub/cmd/util.go index 1daa1d71..a6b60b59 100644 --- a/cmd/hub/cmd/util.go +++ b/cmd/hub/cmd/util.go @@ -12,7 +12,7 @@ import ( "encoding/base64" "errors" "fmt" - "io/ioutil" + "io" "log" "os" @@ -104,7 +104,7 @@ func otpEncode(args []string) error { log.Fatalf("Unable to decode base64 random: %v", err) } - input, err := ioutil.ReadAll(os.Stdin) + input, err := io.ReadAll(os.Stdin) if err != nil { log.Fatalf("Unable to read input (read %d bytes): %v", len(input), err) } diff --git a/cmd/hub/compose/elaborate.go b/cmd/hub/compose/elaborate.go index 5f0be6e6..9c58e382 100644 --- a/cmd/hub/compose/elaborate.go +++ b/cmd/hub/compose/elaborate.go @@ -17,6 +17,8 @@ import ( "sort" "strings" + "golang.org/x/text/cases" + "golang.org/x/text/language" "gopkg.in/yaml.v2" "github.com/epam/hubctl/cmd/hub/config" @@ -204,7 +206,7 @@ func elaborate(manifestFilename string, parametersFilenames []string, overrides if len(stackManifest.Components) > 0 { components = fmt.Sprintf("with components: %s", strings.Join(stackManifest.Lifecycle.Order, ", ")) } - log.Printf("*** %s %s %s", strings.Title(stackManifest.Kind), stackManifest.Meta.Name, + log.Printf("*** %s %s %s", cases.Title(language.Und).String(stackManifest.Kind), stackManifest.Meta.Name, components) } diff --git a/cmd/hub/filecache/cache.go b/cmd/hub/filecache/cache.go index b8ec9f44..02cc856a 100644 --- a/cmd/hub/filecache/cache.go +++ b/cmd/hub/filecache/cache.go @@ -9,7 +9,7 @@ package filecache import ( "errors" "fmt" - "io/ioutil" + "io" "log" "os" @@ -33,7 +33,7 @@ func ReadCache(flag int) (*os.File, *FileCache, error) { } return nil, nil, err } - yamlBytes, err := ioutil.ReadAll(file) + yamlBytes, err := io.ReadAll(file) if err != nil { file.Close() return nil, nil, err diff --git a/cmd/hub/gcp/gcs.go b/cmd/hub/gcp/gcs.go index f71f4229..528fc2fa 100644 --- a/cmd/hub/gcp/gcs.go +++ b/cmd/hub/gcp/gcs.go @@ -9,7 +9,7 @@ package gcp import ( "context" "fmt" - "io/ioutil" + "io" "net/url" "os" "strings" @@ -95,7 +95,7 @@ func ReadGCS(path string) ([]byte, error) { return nil, err } defer reader.Close() - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { return nil, fmt.Errorf("Failed to read GCS object `%s`: %v", path, err) } diff --git a/cmd/hub/gcp/kms.go b/cmd/hub/gcp/kms.go index c25c8e0f..670b13de 100644 --- a/cmd/hub/gcp/kms.go +++ b/cmd/hub/gcp/kms.go @@ -12,7 +12,7 @@ import ( "time" kms "cloud.google.com/go/kms/apiv1" - kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1" + "cloud.google.com/go/kms/apiv1/kmspb" ) const aes256KeySize = 32 diff --git a/cmd/hub/kube/kubeconfig.go b/cmd/hub/kube/kubeconfig.go index bdd40067..6895ca42 100644 --- a/cmd/hub/kube/kubeconfig.go +++ b/cmd/hub/kube/kubeconfig.go @@ -9,7 +9,7 @@ package kube import ( "errors" "fmt" - "io/ioutil" + "io" "log" "os" "path/filepath" @@ -125,7 +125,7 @@ func readKubeconfig(filename string) (*KubeConfig, error) { return nil, fmt.Errorf("Unable to open `%s`: %v", filename, err) } defer file.Close() - content, err := ioutil.ReadAll(file) + content, err := io.ReadAll(file) if err != nil { return nil, fmt.Errorf("Unable to read `%s`: %v", filename, err) } @@ -148,7 +148,7 @@ func writeKubeconfig(filename string, config *KubeConfig) error { if err != nil { return fmt.Errorf("Unable to marshall `%s`: %v", filename, err) } - _, err = file.Seek(0, os.SEEK_SET) + _, err = file.Seek(0, io.SeekStart) if err != nil { return fmt.Errorf("Unable to seek `%s`: %v", filename, err) } diff --git a/cmd/hub/lifecycle/ask.go b/cmd/hub/lifecycle/ask.go index a1d68c8c..b7839aec 100644 --- a/cmd/hub/lifecycle/ask.go +++ b/cmd/hub/lifecycle/ask.go @@ -8,7 +8,6 @@ package lifecycle import ( "fmt" - "io/ioutil" "log" "os" "strings" @@ -57,7 +56,7 @@ func AskParameter(parameter manifest.Parameter, } } if filename != "" { - bytes, err := ioutil.ReadFile(filename) + bytes, err := os.ReadFile(filename) if err != nil { return "(error)", fmt.Errorf("Error reading `%s`: %v", filename, err) } diff --git a/cmd/hub/lifecycle/backup.go b/cmd/hub/lifecycle/backup.go index 38ef1f32..c477358d 100644 --- a/cmd/hub/lifecycle/backup.go +++ b/cmd/hub/lifecycle/backup.go @@ -13,9 +13,10 @@ import ( "io" "log" "os" - "strings" "time" + "golang.org/x/text/cases" + "golang.org/x/text/language" "gopkg.in/yaml.v2" "github.com/epam/hubctl/cmd/hub/config" @@ -136,7 +137,7 @@ func BackupCreate(request *Request, bundles []string, jsonOutput, allowPartial b } if config.Verbose { - log.Printf("%s %v", strings.Title(verb), implementsBackup) + log.Printf("%s %v", cases.Title(language.Und).String(verb), implementsBackup) } bundle := state.BackupManifest{ diff --git a/cmd/hub/lifecycle/deploy.go b/cmd/hub/lifecycle/deploy.go index ceddf300..03a997fe 100644 --- a/cmd/hub/lifecycle/deploy.go +++ b/cmd/hub/lifecycle/deploy.go @@ -15,10 +15,11 @@ import ( "os/exec" "path/filepath" "strings" - "time" petname "github.com/dustinkirkland/golang-petname" "github.com/google/uuid" + "golang.org/x/text/cases" + "golang.org/x/text/language" "github.com/epam/hubctl/cmd/hub/config" "github.com/epam/hubctl/cmd/hub/ext" @@ -183,7 +184,6 @@ func Execute(request *Request, pipe io.WriteCloser) { if stackName == "" { stackName = os.Getenv(HubEnvVarHubStackName) if stackName == "" { - rand.Seed(time.Now().UnixNano()) suffix := rand.Intn(1000) + 1 name := petname.Generate(2, "-") stackName = fmt.Sprintf("%s-%d", name, suffix) @@ -579,7 +579,7 @@ NEXT_COMPONENT: if isDeploy { provides2 := noEnvironmentProvides(provides) if len(provides2) > 0 { - log.Printf("%s provides:", strings.Title(stackManifest.Kind)) + log.Printf("%s provides:", cases.Title(language.Und).String(stackManifest.Kind)) util.PrintDeps(provides2) } printStackOutputs(stackOutputs) diff --git a/cmd/hub/lifecycle/outputs.go b/cmd/hub/lifecycle/outputs.go index fbe3928a..05737775 100644 --- a/cmd/hub/lifecycle/outputs.go +++ b/cmd/hub/lifecycle/outputs.go @@ -11,8 +11,8 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" "log" + "os" "path/filepath" "strings" @@ -94,7 +94,7 @@ func expandRequestedOutputs(componentName, componentDir string, if !filepath.IsAbs(filename) { filename = filepath.Join(componentDir, filename) } - bytes, err := ioutil.ReadFile(filename) + bytes, err := os.ReadFile(filename) if err != nil { util.Warn("Unable to read raw output `%s` from `%s` for component `%s` output `%s`: %v", variable, filename, componentName, requestedOutput.Name, err) diff --git a/cmd/hub/lifecycle/probe.go b/cmd/hub/lifecycle/probe.go index f837b55e..ab7f4f05 100644 --- a/cmd/hub/lifecycle/probe.go +++ b/cmd/hub/lifecycle/probe.go @@ -9,7 +9,7 @@ package lifecycle import ( "errors" "fmt" - "io/ioutil" + "io" "log" "os" "os/exec" @@ -130,7 +130,7 @@ func probeMakefile(dir string, verb string) (bool, error) { } return false, fmt.Errorf("%s: %v", filename, err) } - bytes, err := ioutil.ReadAll(makefile) + bytes, err := io.ReadAll(makefile) if err != nil { return false, fmt.Errorf("%s: %v", filename, err) } diff --git a/cmd/hub/lifecycle/requirement.go b/cmd/hub/lifecycle/requirement.go index b3e3fe06..cd6b1627 100644 --- a/cmd/hub/lifecycle/requirement.go +++ b/cmd/hub/lifecycle/requirement.go @@ -11,7 +11,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "log" "os" "os/exec" @@ -395,7 +394,7 @@ func checkRequiresGcp() error { return err } - jsonData, err := ioutil.ReadFile(credsFile) + jsonData, err := os.ReadFile(credsFile) if err != nil { return fmt.Errorf("Unable to read `%s`: %v", credsFile, err) } diff --git a/cmd/hub/lifecycle/template.go b/cmd/hub/lifecycle/template.go index 622ee13f..14520e9c 100644 --- a/cmd/hub/lifecycle/template.go +++ b/cmd/hub/lifecycle/template.go @@ -12,7 +12,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "log" "net/url" "os" @@ -359,7 +359,7 @@ func processTemplate(filename, kind, componentName string, if err != nil { return []error{fmt.Errorf("Unable to open `%s` component template input `%s`: %v", componentName, filename, err)} } - byteContent, err := ioutil.ReadAll(tmpl) + byteContent, err := io.ReadAll(tmpl) if err != nil { return []error{fmt.Errorf("Unable to read `%s` component template content `%s`: %v", componentName, filename, err)} } diff --git a/cmd/hub/metrics/meter.go b/cmd/hub/metrics/meter.go index 9ec75fe2..a019214c 100644 --- a/cmd/hub/metrics/meter.go +++ b/cmd/hub/metrics/meter.go @@ -168,7 +168,7 @@ func meteringConfig() (bool, string, error) { return !conf.Disabled, "", errors.New("No cache file created") } defer file.Close() - _, err = file.Seek(0, os.SEEK_SET) + _, err = file.Seek(0, io.SeekStart) if err != nil { return !conf.Disabled, "", err } diff --git a/cmd/hub/storage/print.go b/cmd/hub/storage/print.go index 7a065284..673964c0 100644 --- a/cmd/hub/storage/print.go +++ b/cmd/hub/storage/print.go @@ -8,13 +8,14 @@ package storage import ( "log" - "strings" "github.com/epam/hubctl/cmd/hub/util" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) func printFiles(files []File, kind string) { - log.Printf("%s %s:", strings.Title(kind), util.Plural(len(files), "file")) + log.Printf("%s %s:", cases.Title(language.Und).String(kind), util.Plural(len(files), "file")) for _, file := range files { locked := "" if file.Locked { diff --git a/cmd/hub/storage/read.go b/cmd/hub/storage/read.go index 0ae48147..b03b3b01 100644 --- a/cmd/hub/storage/read.go +++ b/cmd/hub/storage/read.go @@ -8,7 +8,6 @@ package storage import ( "fmt" - "io/ioutil" "log" "net/url" "os" @@ -21,6 +20,8 @@ import ( "github.com/epam/hubctl/cmd/hub/crypto" "github.com/epam/hubctl/cmd/hub/gcp" "github.com/epam/hubctl/cmd/hub/util" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) var remoteStorageSchemes = []string{"s3", "gs", "az"} @@ -45,7 +46,7 @@ func checkPath(path, kind string) (*File, error) { err = fmt.Errorf("Unable to parse `%s` %s file path as URL: %v", path, kind, err) } else if !util.Contains(remoteStorageSchemes, remote.Scheme) { err = fmt.Errorf("%s file `%s` scheme `%s` not supported. Supported schemes: %v", - strings.Title(kind), path, remote.Scheme, remoteStorageSchemes) + cases.Title(language.Und).String(kind), path, remote.Scheme, remoteStorageSchemes) } if err != nil { return nil, err @@ -252,7 +253,7 @@ func readFile(file *File) ([]byte, error) { switch file.Kind { case "fs": - data, err = ioutil.ReadFile(file.Path) + data, err = os.ReadFile(file.Path) case "s3": data, err = aws.ReadS3(file.Path) diff --git a/cmd/hub/util/gzip.go b/cmd/hub/util/gzip.go index ef962d43..3b1c2472 100644 --- a/cmd/hub/util/gzip.go +++ b/cmd/hub/util/gzip.go @@ -10,7 +10,7 @@ import ( "bytes" "compress/gzip" "fmt" - "io/ioutil" + "io" ) func IsGzipData(data []byte) bool { @@ -23,7 +23,7 @@ func Gunzip(compressed []byte) ([]byte, error) { if err != nil { return nil, err } - data, err := ioutil.ReadAll(gunzip) + data, err := io.ReadAll(gunzip) if err != nil { return nil, err } diff --git a/cmd/hub/util/util.go b/cmd/hub/util/util.go index 0fb48214..7aad8f25 100644 --- a/cmd/hub/util/util.go +++ b/cmd/hub/util/util.go @@ -21,6 +21,8 @@ import ( "github.com/logrusorgru/aurora" "github.com/mattn/go-isatty" + "golang.org/x/text/cases" + "golang.org/x/text/language" "github.com/epam/hubctl/cmd/hub/config" ) @@ -590,7 +592,7 @@ func initSecretSuffixes() []string { for _, suf := range seed { suffixes = append(suffixes, "."+suf) suffixes = append(suffixes, "_"+suf) - suffixes = append(suffixes, strings.Title(suf)) + suffixes = append(suffixes, cases.Title(language.Und).String(suf)) suffixes = append(suffixes, strings.ToUpper(suf)) } return suffixes diff --git a/go.mod b/go.mod index 26953f7e..6c363698 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,6 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/crypto v0.21.0 google.golang.org/api v0.114.0 - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 gopkg.in/yaml.v2 v2.4.0 ) @@ -37,6 +36,7 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect golang.org/x/mod v0.16.0 // indirect golang.org/x/tools v0.19.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect ) require ( @@ -103,7 +103,7 @@ require ( golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.14.0 golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/grpc v1.56.3 // indirect diff --git a/staticcheck.conf b/staticcheck.conf index 63bec862..bd006bb4 100644 --- a/staticcheck.conf +++ b/staticcheck.conf @@ -1 +1 @@ -checks = ["all", "-ST1005", "-ST1000", "-ST1003", "-SA1019", "-ST1020", "-ST1022"] +checks = ["all", "-ST1005", "-ST1000", "-ST1003", "-ST1020", "-ST1022"]