Skip to content

Commit

Permalink
Merge pull request #78 from rebuy-de/kubeconfig
Browse files Browse the repository at this point in the history
split kubeconfig
  • Loading branch information
svenwltr authored Jun 3, 2021
2 parents f29b394 + 33cc606 commit 20eb579
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/kubeutil/kubeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)

Expand All @@ -27,7 +28,7 @@ func (p *Params) Bind(cmd *cobra.Command) error {
return nil
}

func (p *Params) Client() (kubernetes.Interface, error) {
func (p *Params) Config() (*rest.Config, error) {
if p.kubeconfig == "" {
p.kubeconfig = os.Getenv(EnvKubeconfig)
}
Expand All @@ -37,6 +38,15 @@ func (p *Params) Client() (kubernetes.Interface, error) {
return nil, errors.Wrap(err, "failed to load kubernetes config")
}

return config, nil
}

func (p *Params) Client() (kubernetes.Interface, error) {
config, err := p.Config()
if err != nil {
return nil, errors.WithStack(err)
}

client, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, errors.Wrap(err, "failed to initialize kubernetes client")
Expand Down

0 comments on commit 20eb579

Please sign in to comment.