From 7b5fe4c4f8eb36674e9962c0ffeb98bcb98265c7 Mon Sep 17 00:00:00 2001 From: jremy Date: Wed, 14 Aug 2024 15:26:03 +0200 Subject: [PATCH] fix linter error --- internal/core/error.go | 2 +- internal/namespaces/baremetal/v1/helpers_test.go | 6 +++--- internal/namespaces/iam/v1alpha1/error.go | 2 +- internal/namespaces/instance/v1/custom_server_create.go | 8 ++++---- internal/namespaces/rdb/v1/custom_instance.go | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/core/error.go b/internal/core/error.go index 41f80a90ad..450e1987ba 100644 --- a/internal/core/error.go +++ b/internal/core/error.go @@ -43,7 +43,7 @@ func (s *CliError) MarshalHuman() (string, error) { if s.Err != nil { humanError := s.Err if s.Message != "" { - humanError = fmt.Errorf(s.Message) + humanError = fmt.Errorf("%s", s.Message) } str, err := human.Marshal(humanError, nil) if err != nil { diff --git a/internal/namespaces/baremetal/v1/helpers_test.go b/internal/namespaces/baremetal/v1/helpers_test.go index 14073f222e..0cd6c896f6 100644 --- a/internal/namespaces/baremetal/v1/helpers_test.go +++ b/internal/namespaces/baremetal/v1/helpers_test.go @@ -25,11 +25,11 @@ func createServer(metaKey string) core.BeforeFunc { // //nolint:unparam func deleteServer(metaKey string) core.AfterFunc { - return core.ExecAfterCmd(fmt.Sprintf("scw baremetal server delete zone=nl-ams-1 {{ ." + metaKey + ".ID }}")) + return core.ExecAfterCmd(fmt.Sprintf("scw baremetal server delete zone=nl-ams-1 {{ .%s.ID }}", metaKey)) } func deleteServerDefault(metaKey string) core.AfterFunc { - return core.ExecAfterCmd(fmt.Sprintf("scw baremetal server delete {{ ." + metaKey + ".ID }}")) + return core.ExecAfterCmd(fmt.Sprintf("scw baremetal server delete {{ .%s.ID }}", metaKey)) } // add an ssh key with a given meta key @@ -44,5 +44,5 @@ func addSSH(metaKey string, key string) core.BeforeFunc { // delete an ssh key with a given meta key func deleteSSH(metaKey string) core.AfterFunc { - return core.ExecAfterCmd(fmt.Sprintf("scw iam ssh-key delete {{ ." + metaKey + ".ID }}")) + return core.ExecAfterCmd(fmt.Sprintf("scw iam ssh-key delete {{ .%s.ID }}", metaKey)) } diff --git a/internal/namespaces/iam/v1alpha1/error.go b/internal/namespaces/iam/v1alpha1/error.go index a2f727dc9c..2455f8c491 100644 --- a/internal/namespaces/iam/v1alpha1/error.go +++ b/internal/namespaces/iam/v1alpha1/error.go @@ -15,7 +15,7 @@ func installationCanceled(addKeyInstructions string) *core.CliError { func sshKeyNotFound(filename string, addKeyInstructions string) *core.CliError { return &core.CliError{ - Err: fmt.Errorf("could not find an SSH key at " + filename), + Err: fmt.Errorf("could not find an SSH key at %s", filename), Hint: "You can add one later using " + addKeyInstructions, } } diff --git a/internal/namespaces/instance/v1/custom_server_create.go b/internal/namespaces/instance/v1/custom_server_create.go index ef6548a38b..e7a925aef1 100644 --- a/internal/namespaces/instance/v1/custom_server_create.go +++ b/internal/namespaces/instance/v1/custom_server_create.go @@ -552,14 +552,14 @@ func validateLocalVolumeSizes(volumes map[string]*instance.VolumeServerTemplate, } if localVolumeTotalSize < volumeConstraint.MinSize || localVolumeTotalSize > volumeConstraint.MaxSize { - min := humanize.Bytes(uint64(volumeConstraint.MinSize)) + minSize := humanize.Bytes(uint64(volumeConstraint.MinSize)) computedLocal := humanize.Bytes(uint64(localVolumeTotalSize)) if volumeConstraint.MinSize == volumeConstraint.MaxSize { - return fmt.Errorf("%s total local volume size must be equal to %s, got %s", commercialType, min, computedLocal) + return fmt.Errorf("%s total local volume size must be equal to %s, got %s", commercialType, minSize, computedLocal) } - max := humanize.Bytes(uint64(volumeConstraint.MaxSize)) - return fmt.Errorf("%s total local volume size must be between %s and %s, got %s", commercialType, min, max, computedLocal) + maxSize := humanize.Bytes(uint64(volumeConstraint.MaxSize)) + return fmt.Errorf("%s total local volume size must be between %s and %s, got %s", commercialType, minSize, maxSize, computedLocal) } return nil diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index fa1027e5e9..502e7ff9f5 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -706,7 +706,7 @@ func getPublicEndpoint(endpoints []*rdbSDK.Endpoint) (*rdbSDK.Endpoint, error) { } } - return nil, fmt.Errorf(errorMessagePublicEndpointNotFound) + return nil, fmt.Errorf("%s", errorMessagePublicEndpointNotFound) } func getPrivateEndpoint(endpoints []*rdbSDK.Endpoint) (*rdbSDK.Endpoint, error) { @@ -716,7 +716,7 @@ func getPrivateEndpoint(endpoints []*rdbSDK.Endpoint) (*rdbSDK.Endpoint, error) } } - return nil, fmt.Errorf(errorMessagePrivateEndpointNotFound) + return nil, fmt.Errorf("%s", errorMessagePrivateEndpointNotFound) } func createConnectCommandLineArgs(endpoint *rdbSDK.Endpoint, family engineFamily, args *instanceConnectArgs) ([]string, error) { @@ -815,7 +815,7 @@ func instanceConnectCommand() *core.Command { } if len(instance.Endpoints) == 0 { - return nil, fmt.Errorf(errorMessageEndpointNotFound) + return nil, fmt.Errorf("%s", errorMessageEndpointNotFound) } var endpoint *rdbSDK.Endpoint