Skip to content

Commit

Permalink
Merge pull request #596 from MUzairS15/MUzairS15/fix-logic
Browse files Browse the repository at this point in the history
fix error handling
  • Loading branch information
Mohd Uzair authored Sep 27, 2024
2 parents 6fd2108 + 08164fd commit a8d2a6d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions utils/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func DetectKubeConfig(configfile []byte) (config *rest.Config, err error) {
}

if config, err = clientcmd.RESTConfigFromKubeConfig(cfgFile); err == nil {
return config, ErrRestConfigFromKubeConfig(err)
return config, nil
}
}

// If deployed within the cluster
if config, err = rest.InClusterConfig(); err == nil {
return config, ErrRestConfigFromKubeConfig(err)
return config, nil
}

// Look for kubeconfig from the path mentioned in $KUBECONFIG
Expand All @@ -38,7 +38,7 @@ func DetectKubeConfig(configfile []byte) (config *rest.Config, err error) {
return nil, err
}
if config, err = clientcmd.RESTConfigFromKubeConfig(cfgFile); err == nil {
return config, ErrRestConfigFromKubeConfig(err)
return config, nil
}
}

Expand All @@ -49,10 +49,10 @@ func DetectKubeConfig(configfile []byte) (config *rest.Config, err error) {
return nil, err
}
if config, err = clientcmd.RESTConfigFromKubeConfig(cfgFile); err == nil {
return config, ErrRestConfigFromKubeConfig(err)
return config, nil
}

return
return nil, ErrRestConfigFromKubeConfig(err)
}

// ProcessConfig handles loading, validating, and optionally saving or returning a kubeconfig
Expand Down

0 comments on commit a8d2a6d

Please sign in to comment.