From e54d73fecd7d577ac5620da0043588d7e9026a82 Mon Sep 17 00:00:00 2001 From: Lucas Fernando Cardoso Nunes Date: Fri, 15 Dec 2023 14:54:23 -0300 Subject: [PATCH] fix: uparam always nil https://github.com/mvdan/unparam/issues/40 --- pkg/providers/k8s/k8s.go | 13 ++++--------- pkg/providers/k8s/k8s_test.go | 5 +---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/pkg/providers/k8s/k8s.go b/pkg/providers/k8s/k8s.go index e9e1e6e..4ae43a9 100644 --- a/pkg/providers/k8s/k8s.go +++ b/pkg/providers/k8s/k8s.go @@ -33,11 +33,7 @@ func New(l *log.Logger, cfg api.StaticConfig) (*provider) { return nil } - p.KubeContext, err = getKubeContext(cfg) - if err != nil { - p.log.Debugf("vals-k8s: Unable to get a valid kubeContext: %s", err) - return nil - } + p.KubeContext = getKubeContext(cfg) if p.KubeContext == "" { p.log.Debugf("vals-k8s: kubeContext was not provided. Using current context.") @@ -126,12 +122,11 @@ func (p *provider) GetStringMap(path string) (map[string]interface{}, error) { } // Return an empty Kube context if none is provided -//nolint:unparam // TODO: https://github.com/mvdan/unparam/issues/40 -func getKubeContext(cfg api.StaticConfig) (string, error) { +func getKubeContext(cfg api.StaticConfig) string { if cfg.String("kubeContext") != "" { - return cfg.String("kubeContext"), nil + return cfg.String("kubeContext") } - return "", nil + return "" } // Build the client-go config using a specific context diff --git a/pkg/providers/k8s/k8s_test.go b/pkg/providers/k8s/k8s_test.go index 5871553..333c22d 100644 --- a/pkg/providers/k8s/k8s_test.go +++ b/pkg/providers/k8s/k8s_test.go @@ -190,10 +190,7 @@ func Test_getKubeContext(t *testing.T) { for i := range testcases { tc := testcases[i] t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { - got, err := getKubeContext(tc.config) - if err != nil { - t.Fatalf("unexpected error: %s", err) - } + got := getKubeContext(tc.config) if diff := cmp.Diff(tc.want, got); diff != "" { t.Errorf("unexpected result: -(want), +(got)\n%s", diff) }