Skip to content

Commit

Permalink
fix: uparam always nil
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcnunes committed Dec 15, 2023
1 parent bf5cbb2 commit e54d73f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
13 changes: 4 additions & 9 deletions pkg/providers/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions pkg/providers/k8s/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e54d73f

Please sign in to comment.