Skip to content

Commit

Permalink
Revert "fix: use kubeconfig file when user specify it (#605)" (#608)
Browse files Browse the repository at this point in the history
This reverts commit e3b21ec.
  • Loading branch information
AlexsJones committed Aug 19, 2023
1 parent cc665ea commit 13f63ed
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ func (c *Client) GetRestClient() rest.Interface {

func NewClient(kubecontext string, kubeconfig string) (*Client, error) {
var config *rest.Config
var err error

if kubeconfig != "" {
config, err := rest.InClusterConfig()
if err != nil {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.ExplicitPath = kubeconfig

if kubeconfig != "" {
loadingRules.ExplicitPath = kubeconfig
}

clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
loadingRules,
&clientcmd.ConfigOverrides{
Expand All @@ -51,13 +54,7 @@ func NewClient(kubecontext string, kubeconfig string) (*Client, error) {
if err != nil {
return nil, err
}
} else {
config, err = rest.InClusterConfig()
if err != nil {
return nil, err
}
}

clientSet, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, err
Expand Down

0 comments on commit 13f63ed

Please sign in to comment.