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) }