From 57481e6cc096bb6ebb08f765073ccf9ac9f940d1 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 14 Apr 2023 22:15:47 +0200 Subject: [PATCH] ci: update linter and fix lint violations Signed-off-by: Mark Sagi-Kazar --- .github/workflows/ci.yaml | 5 +--- .golangci.yml | 18 ++++++++++++-- Makefile | 2 +- cmd/controller/main.go | 18 ++++---------- cmd/refresher/main.go | 11 ++++----- controllers/imagepullsecret_controller.go | 25 ++++++++++++------- controllers/imagepullsecret_reconciler.go | 29 +++++++++++++---------- controllers/refresher_controller.go | 25 ++++++++++--------- controllers/stringset.go | 1 + pkg/ecr/manager.go | 14 ++++++----- pkg/ecr/token.go | 4 ++-- pkg/ecr/types.go | 7 +++--- pkg/pullsecrets/docker_config.go | 18 +++++++------- pkg/pullsecrets/error.go | 2 ++ pkg/pullsecrets/provider_ecr.go | 9 ++++--- pkg/pullsecrets/provider_error.go | 2 +- pkg/pullsecrets/provider_static.go | 2 +- 17 files changed, 105 insertions(+), 87 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ea0b8c..ff17148 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,9 +16,6 @@ jobs: name: Checks runs-on: ubuntu-latest - env: - GOLANGCI_LINT_VERSION: 1.26.0 - steps: - name: Checkout repository uses: actions/checkout@83b7061638ee4956cf7545a6f7efe594e5ad0247 # v3.5.1 @@ -55,7 +52,7 @@ jobs: run: go mod vendor && make license-check - name: Run lint - run: GOLANGCI_VERSION=${{ env.GOLANGCI_LINT_VERSION }} make lint + run: make lint build: name: Build diff --git a/.golangci.yml b/.golangci.yml index c3aa0f8..164d6a4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,14 +22,28 @@ linters: - nestif - testpackage - nolintlint + - wrapcheck + - varnamelen + - ireturn + - exhaustivestruct + - exhaustruct + - gomoddirectives + - exhaustive + - cyclop + - ifshort linters-settings: golint: min-confidence: 0.1 gocyclo: min-complexity: 40 - goimports: - local-prefixes: github.com/banzaicloud + gci: + sections: + - standard + - default + - prefix(github.com/banzaicloud/imps) + goimports: + local-prefixes: github.com/banzaicloud/imps gocritic: disabled-checks: - ifElseChain diff --git a/Makefile b/Makefile index 802cd12..1cc2832 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CRD_OPTIONS ?= "crd" # TODO: Use this when allowDangerousTypes feature is released to support floats # CRD_OPTIONS ?= "crd:trivialVersions=true,allowDangerousTypes=true" LICENSEI_VERSION = 0.7.0 -GOLANGCI_VERSION ?= 1.45.2 +GOLANGCI_VERSION ?= 1.52.2 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index f76cb6b..fea20c6 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -8,27 +8,19 @@ import ( "strings" "time" + "github.com/banzaicloud/imps/api/v1alpha1" + "github.com/banzaicloud/imps/controllers" + "github.com/banzaicloud/imps/internal/errorhandler" + "github.com/banzaicloud/imps/internal/log" "github.com/banzaicloud/imps/pkg/ecr" - "github.com/banzaicloud/operator-tools/pkg/reconciler" - - logrintegration "logur.dev/integration/logr" - - "github.com/banzaicloud/imps/internal/errorhandler" - "github.com/spf13/pflag" "github.com/spf13/viper" "k8s.io/apimachinery/pkg/runtime" - - "github.com/banzaicloud/imps/controllers" - "github.com/banzaicloud/imps/internal/log" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" + logrintegration "logur.dev/integration/logr" "logur.dev/logur" ctrl "sigs.k8s.io/controller-runtime" - - "github.com/banzaicloud/imps/api/v1alpha1" - // +kubebuilder:scaffold:imports ) var ( diff --git a/cmd/refresher/main.go b/cmd/refresher/main.go index a84a724..84f7768 100644 --- a/cmd/refresher/main.go +++ b/cmd/refresher/main.go @@ -7,6 +7,11 @@ import ( "time" "emperror.dev/errors" + "github.com/banzaicloud/imps/controllers" + "github.com/banzaicloud/imps/internal/errorhandler" + "github.com/banzaicloud/imps/internal/log" + "github.com/banzaicloud/imps/pkg/ecr" + "github.com/banzaicloud/operator-tools/pkg/reconciler" "github.com/spf13/pflag" "github.com/spf13/viper" "k8s.io/apimachinery/pkg/runtime" @@ -15,12 +20,6 @@ import ( logrintegration "logur.dev/integration/logr" "logur.dev/logur" ctrl "sigs.k8s.io/controller-runtime" - - "github.com/banzaicloud/imps/controllers" - "github.com/banzaicloud/imps/internal/errorhandler" - "github.com/banzaicloud/imps/internal/log" - "github.com/banzaicloud/imps/pkg/ecr" - "github.com/banzaicloud/operator-tools/pkg/reconciler" ) var ( diff --git a/controllers/imagepullsecret_controller.go b/controllers/imagepullsecret_controller.go index a65dbcc..f187fa3 100644 --- a/controllers/imagepullsecret_controller.go +++ b/controllers/imagepullsecret_controller.go @@ -19,22 +19,20 @@ import ( "time" "emperror.dev/emperror" - "logur.dev/logur" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - + "github.com/banzaicloud/imps/api/v1alpha1" + "github.com/banzaicloud/imps/internal/cron" + "github.com/banzaicloud/operator-tools/pkg/reconciler" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" + "logur.dev/logur" ctrl "sigs.k8s.io/controller-runtime" ctrlBuilder "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - - "github.com/banzaicloud/imps/api/v1alpha1" - "github.com/banzaicloud/imps/internal/cron" - "github.com/banzaicloud/operator-tools/pkg/reconciler" ) // AlertingPolicyReconciler reconciles a AlertingPolicy object @@ -58,6 +56,7 @@ func (r *ImagePullSecretReconciler) Reconcile(ctx context.Context, req ctrl.Requ if err != nil { r.ErrorHandler.Handle(err) } + return result, err } @@ -87,6 +86,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c ns, ok := obj.(*corev1.Namespace) if !ok { r.Log.Info("object is not a Namespace") + return []ctrl.Request{} } @@ -95,6 +95,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c err := r.Client.List(context.TODO(), impsList) if err != nil { r.Log.Info(err.Error()) + return []ctrl.Request{} } @@ -107,6 +108,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c "namespace": ns, "error": err, }) + continue } @@ -119,6 +121,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c }) } } + return res } @@ -126,6 +129,7 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re pod, ok := obj.(*corev1.Pod) if !ok { r.Log.Info("object is not a Pod or Namespace") + return []ctrl.Request{} } @@ -135,7 +139,6 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re err := r.Client.Get(context.TODO(), types.NamespacedName{ Name: pod.Namespace, }, podsNamespace) - if err != nil { r.Log.Warn("cannot get pod's namespace, please authorize the controller to list namespaces, or too many reconcilations will be executed", map[string]interface{}{ "error": err, @@ -149,6 +152,7 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re err = r.Client.List(context.TODO(), impsList) if err != nil { r.Log.Info(err.Error()) + return []ctrl.Request{} } var res []ctrl.Request @@ -160,6 +164,7 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re "pod": pod, "error": err, }) + continue } @@ -184,6 +189,7 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re }) } } + return res } @@ -191,6 +197,7 @@ func (r *ImagePullSecretReconciler) impsReferencingSecret(obj client.Object) []c secret, ok := obj.(*corev1.Secret) if !ok { r.Log.Info("object is not a Secret") + return []ctrl.Request{} } @@ -199,6 +206,7 @@ func (r *ImagePullSecretReconciler) impsReferencingSecret(obj client.Object) []c err := r.Client.List(context.TODO(), impsList) if err != nil { r.Log.Info(err.Error()) + return []ctrl.Request{} } @@ -215,5 +223,6 @@ func (r *ImagePullSecretReconciler) impsReferencingSecret(obj client.Object) []c } } } + return res } diff --git a/controllers/imagepullsecret_reconciler.go b/controllers/imagepullsecret_reconciler.go index 66a5e19..31686a6 100644 --- a/controllers/imagepullsecret_reconciler.go +++ b/controllers/imagepullsecret_reconciler.go @@ -19,27 +19,22 @@ import ( "fmt" "time" - "github.com/banzaicloud/imps/pkg/pullsecrets" - "emperror.dev/errors" + "github.com/banzaicloud/imps/api/v1alpha1" + "github.com/banzaicloud/imps/pkg/pullsecrets" + "github.com/banzaicloud/operator-tools/pkg/reconciler" corev1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/banzaicloud/imps/api/v1alpha1" - "github.com/banzaicloud/operator-tools/pkg/reconciler" - "logur.dev/logur" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" ) -var ( - requeueObject = ctrl.Result{ - Requeue: true, - RequeueAfter: 5 * time.Second, - } -) +var requeueObject = ctrl.Result{ + Requeue: true, + RequeueAfter: 5 * time.Second, +} func (r *ImagePullSecretReconciler) setFailedStatus(ctx context.Context, imps *v1alpha1.ImagePullSecret, failureError error) { imps.Status.Status = v1alpha1.ReconciliationFailed @@ -121,6 +116,7 @@ func (r *ImagePullSecretReconciler) reconcile(ctx context.Context, req ctrl.Requ r.setReadyStatus(ctx, &imps, targetNamespaces, resultingConfig.Expiration) } logger.Info("Reconciling ImagePullSecret finished") + return result, err } @@ -132,6 +128,7 @@ func (r *ImagePullSecretReconciler) reconcileImagePullSecret(ctx context.Context "imps": imps, }) r.Recorder.Event(imps, "Warning", "SecretReconciliationError", fmt.Sprintf("Cannot list namespaces requiring the secret: %s", err.Error())) + return requeueObject, nil, err } @@ -150,6 +147,7 @@ func (r *ImagePullSecretReconciler) reconcileImagePullSecret(ctx context.Context }) r.Recorder.Event(imps, "Warning", "SecretReconciliationError", fmt.Sprintf("Cannot reconcile secret: %s/%s", namespaceName, imps.Spec.Target.Secret.Name)) wasError = true + continue } r.Log.Info("reconciled secret", map[string]interface{}{ @@ -172,6 +170,7 @@ func (r *ImagePullSecretReconciler) reconcileImagePullSecret(ctx context.Context "imps": imps, }) r.Recorder.Event(imps, "Warning", "SecretReconciliationError", fmt.Sprintf("Cannot enumerate secrets: %s", err.Error())) + return requeueObject, nil, err } @@ -203,6 +202,7 @@ func (r *ImagePullSecretReconciler) reconcileImagePullSecret(ctx context.Context "secret": existingSecret, }) r.Recorder.Event(imps, "Warning", "SecretDeletionError", fmt.Sprintf("Cannot remove secret %s/%s", existingSecret.Namespace, existingSecret.Name)) + return requeueObject, nil, err } } @@ -237,6 +237,7 @@ func (r *ImagePullSecretReconciler) namespacesRequiringSecret(ctx context.Contex "error": err, "imps": imps, }) + continue } if shouldReconcile { @@ -267,6 +268,7 @@ func (r *ImagePullSecretReconciler) anyPodMatchesSelectorInNS(ctx context.Contex "pod": pod, "imps": imps, }) + continue } @@ -274,6 +276,7 @@ func (r *ImagePullSecretReconciler) anyPodMatchesSelectorInNS(ctx context.Contex return true, nil } } + return false, nil } diff --git a/controllers/refresher_controller.go b/controllers/refresher_controller.go index 0308255..fa1b69a 100644 --- a/controllers/refresher_controller.go +++ b/controllers/refresher_controller.go @@ -18,25 +18,21 @@ import ( "context" "time" + "emperror.dev/emperror" "emperror.dev/errors" - ctrlBuilder "sigs.k8s.io/controller-runtime/pkg/builder" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/predicate" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" - + "github.com/banzaicloud/imps/internal/cron" "github.com/banzaicloud/imps/pkg/pullsecrets" - - "emperror.dev/emperror" - "logur.dev/logur" - + "github.com/banzaicloud/operator-tools/pkg/reconciler" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + "logur.dev/logur" ctrl "sigs.k8s.io/controller-runtime" + ctrlBuilder "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/banzaicloud/imps/internal/cron" - "github.com/banzaicloud/operator-tools/pkg/reconciler" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + "sigs.k8s.io/controller-runtime/pkg/source" ) // RefresherReconciler reconciles a AlertingPolicy object @@ -58,6 +54,7 @@ func (r *RefresherReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( if err != nil { r.ErrorHandler.Handle(err) } + return result, err } @@ -77,6 +74,7 @@ func (r *RefresherReconciler) isMatchingSecret(obj client.Object) []ctrl.Request secret, ok := obj.(*corev1.Secret) if !ok { r.Log.Info("object is not a Secret") + return []ctrl.Request{} } @@ -137,6 +135,7 @@ func (r *RefresherReconciler) reconcile(ctx context.Context, req ctrl.Request) ( }) } } + return result, err } diff --git a/controllers/stringset.go b/controllers/stringset.go index fa74811..3644543 100644 --- a/controllers/stringset.go +++ b/controllers/stringset.go @@ -22,5 +22,6 @@ func (s StringSet) Has(needle string) bool { return true } } + return false } diff --git a/pkg/ecr/manager.go b/pkg/ecr/manager.go index 31d9ece..afaba48 100644 --- a/pkg/ecr/manager.go +++ b/pkg/ecr/manager.go @@ -21,7 +21,7 @@ import ( "emperror.dev/errors" "github.com/aws/aws-sdk-go-v2/aws" - ecr_types "github.com/aws/aws-sdk-go-v2/service/ecr/types" + ecrTypes "github.com/aws/aws-sdk-go-v2/service/ecr/types" "logur.dev/logur" ) @@ -40,9 +40,9 @@ func Initialize(logger logur.Logger) { tokenManager.start() } -var tokenManager *TokenManager = nil +var tokenManager *TokenManager -func GetAuthorizationToken(ctx context.Context, region string, credentials aws.Credentials, roleArn string) (ecr_types.AuthorizationData, error) { +func GetAuthorizationToken(ctx context.Context, region string, credentials aws.Credentials, roleArn string) (ecrTypes.AuthorizationData, error) { return tokenManager.GetAuthorizationToken(ctx, StringableCredentials{ Credentials: credentials, Region: region, @@ -104,26 +104,28 @@ func (t *TokenManager) discardOldTokens() { } } -func (t *TokenManager) GetAuthorizationToken(ctx context.Context, key StringableCredentials) (ecr_types.AuthorizationData, error) { +func (t *TokenManager) GetAuthorizationToken(ctx context.Context, key StringableCredentials) (ecrTypes.AuthorizationData, error) { t.Lock() defer t.Unlock() token, found := t.ManagedTokens[key.String()] if !found { token, err := NewECRToken(ctx, key) if err != nil { - return ecr_types.AuthorizationData{}, err + return ecrTypes.AuthorizationData{}, err } t.ManagedTokens[key.String()] = token if token.CurrentToken == nil { - return ecr_types.AuthorizationData{}, errors.New("no token is available") + return ecrTypes.AuthorizationData{}, errors.New("no token is available") } t.Logger.Info("token refreshed", map[string]interface{}{ "aws_access_key_id": token.Creds.AccessKeyID, "region": token.Creds.Region, }) + return *token.CurrentToken, nil } token.LastQueriedAt = time.Now() + return *token.CurrentToken, nil } diff --git a/pkg/ecr/token.go b/pkg/ecr/token.go index cea6c54..4a74e54 100644 --- a/pkg/ecr/token.go +++ b/pkg/ecr/token.go @@ -20,7 +20,7 @@ import ( "emperror.dev/errors" "github.com/aws/aws-sdk-go-v2/service/ecr" - ecr_types "github.com/aws/aws-sdk-go-v2/service/ecr/types" + ecrTypes "github.com/aws/aws-sdk-go-v2/service/ecr/types" ) const ( @@ -31,7 +31,7 @@ const ( type Token struct { Creds StringableCredentials - CurrentToken *ecr_types.AuthorizationData + CurrentToken *ecrTypes.AuthorizationData TokenValidityDuration time.Duration LastQueriedAt time.Time } diff --git a/pkg/ecr/types.go b/pkg/ecr/types.go index a869a61..6679b3b 100644 --- a/pkg/ecr/types.go +++ b/pkg/ecr/types.go @@ -31,14 +31,14 @@ type StringableCredentials struct { RoleArn string } -func (c *StringableCredentials) GetCreds(ctx context.Context) (aws.Credentials, error) { +func (c *StringableCredentials) GetCreds(_ context.Context) (aws.Credentials, error) { return c.Credentials, nil } func (c *StringableCredentials) ToAwsConfig() aws.Config { cfg := aws.Config{ Region: c.Region, - Credentials: aws.CredentialsProviderFunc(func(ctx context.Context) (aws.Credentials, error) { + Credentials: aws.CredentialsProviderFunc(func(_ context.Context) (aws.Credentials, error) { return c.Credentials, nil }), } @@ -49,10 +49,11 @@ func (c *StringableCredentials) ToAwsConfig() aws.Config { creds := stscreds.NewAssumeRoleProvider(stsSvc, c.RoleArn) cfg.Credentials = aws.NewCredentialsCache(creds) } + return cfg } -func (c *StringableCredentials) Retrieve(ctx context.Context) (aws.Credentials, error) { +func (c *StringableCredentials) Retrieve(_ context.Context) (aws.Credentials, error) { return c.Credentials, nil } diff --git a/pkg/pullsecrets/docker_config.go b/pkg/pullsecrets/docker_config.go index a6002b5..a762269 100644 --- a/pkg/pullsecrets/docker_config.go +++ b/pkg/pullsecrets/docker_config.go @@ -20,15 +20,12 @@ import ( "fmt" "time" + "emperror.dev/errors" "github.com/banzaicloud/imps/api/common" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - - "emperror.dev/errors" ) func NewDockerRegistryConfig() common.DockerRegistryConfig { @@ -67,9 +64,9 @@ func NewConfigFromSecrets(ctx context.Context, c client.Client, refs []types.Nam Namespace: secretRef.Namespace, Name: secretRef.Name, }, &secret) - if err != nil { config.Registries[secretName] = NewErroredCredentialProvider(err) + continue } @@ -77,8 +74,8 @@ func NewConfigFromSecrets(ctx context.Context, c client.Client, refs []types.Nam case common.SecretTypeBasicAuth: dockerConfig, found := secret.Data[common.SecretKeyDockerConfig] if !found { - config.Registries[secretName] = NewErroredCredentialProvider( - errors.NewWithDetails("no docker configuration found in secret", "secret", secret.ObjectMeta)) + config.Registries[secretName] = NewErroredCredentialProvider(errors.NewWithDetails("no docker configuration found in secret", "secret", secret.ObjectMeta)) + continue } config.Registries[secretName] = config.StaticProviderFromDockerConfig(dockerConfig) @@ -89,6 +86,7 @@ func NewConfigFromSecrets(ctx context.Context, c client.Client, refs []types.Nam errors.NewWithDetails("unknown secret type", "type", secret.Type, "secret", secret.ObjectMeta)) } } + return config } @@ -107,6 +105,7 @@ func getOptionalFieldFromMap(data map[string][]byte, key string, defaultVal stri if !found { return defaultVal } + return string(value) } @@ -153,7 +152,7 @@ type ResultingDockerConfig struct { func (c Config) ResultingDockerConfig(ctx context.Context) (*ResultingDockerConfig, error) { finalRegistryConfig := NewDockerRegistryConfig() - var minExpiration *time.Time = nil + var minExpiration *time.Time secretErrors := NewErrorsPerSecret() for secret, provider := range c.Registries { @@ -161,6 +160,7 @@ func (c Config) ResultingDockerConfig(ctx context.Context) (*ResultingDockerConf credentials, err := provider.LoginCredentials(ctx) if err != nil { secretErrors.SetSecretError(secret, err) + continue } diff --git a/pkg/pullsecrets/error.go b/pkg/pullsecrets/error.go index 7374d1e..5632e92 100644 --- a/pkg/pullsecrets/error.go +++ b/pkg/pullsecrets/error.go @@ -43,6 +43,7 @@ func (e ErrorsPerSecret) AsStatus() map[string]string { status[secret] = err.Error() } } + return status } @@ -54,6 +55,7 @@ func (e ErrorsPerSecret) FailedSecrets() []string { invalidSecrets = append(invalidSecrets, secret) } } + return invalidSecrets } diff --git a/pkg/pullsecrets/provider_ecr.go b/pkg/pullsecrets/provider_ecr.go index bd667e7..f0af898 100644 --- a/pkg/pullsecrets/provider_ecr.go +++ b/pkg/pullsecrets/provider_ecr.go @@ -20,11 +20,9 @@ import ( "fmt" "strings" - "github.com/banzaicloud/imps/api/common" - "github.com/aws/aws-sdk-go-v2/aws" - - imps_ecr "github.com/banzaicloud/imps/pkg/ecr" + "github.com/banzaicloud/imps/api/common" + impsEcr "github.com/banzaicloud/imps/pkg/ecr" ) type ECRLoginCredentialsProvider struct { @@ -51,7 +49,7 @@ func (p ECRLoginCredentialsProvider) GetURL() string { } func (p ECRLoginCredentialsProvider) LoginCredentials(ctx context.Context) ([]LoginCredentialsWithDetails, error) { - token, err := imps_ecr.GetAuthorizationToken(ctx, p.Region, p.Credentials, p.RoleArn) + token, err := impsEcr.GetAuthorizationToken(ctx, p.Region, p.Credentials, p.RoleArn) if err != nil { return nil, err } @@ -61,6 +59,7 @@ func (p ECRLoginCredentialsProvider) LoginCredentials(ctx context.Context) ([]Lo } splitAuth := strings.SplitN(string(decodedAuth), ":", 2) + return []LoginCredentialsWithDetails{ { LoginCredentials: common.LoginCredentials{ diff --git a/pkg/pullsecrets/provider_error.go b/pkg/pullsecrets/provider_error.go index fa2947a..47793cc 100644 --- a/pkg/pullsecrets/provider_error.go +++ b/pkg/pullsecrets/provider_error.go @@ -31,6 +31,6 @@ func NewErroredCredentialProvider(err error) ErroredCredentialProvider { } } -func (p ErroredCredentialProvider) LoginCredentials(ctx context.Context) ([]LoginCredentialsWithDetails, error) { +func (p ErroredCredentialProvider) LoginCredentials(_ context.Context) ([]LoginCredentialsWithDetails, error) { return nil, p.Error } diff --git a/pkg/pullsecrets/provider_static.go b/pkg/pullsecrets/provider_static.go index 6c1aab4..b247161 100644 --- a/pkg/pullsecrets/provider_static.go +++ b/pkg/pullsecrets/provider_static.go @@ -39,6 +39,6 @@ func NewStaticLoginCredentialProvider(parsedDockerConfig common.DockerRegistryCo return p } -func (p StaticLoginCredentialProvider) LoginCredentials(ctx context.Context) ([]LoginCredentialsWithDetails, error) { +func (p StaticLoginCredentialProvider) LoginCredentials(_ context.Context) ([]LoginCredentialsWithDetails, error) { return p.Credentials, nil }