Skip to content

Commit

Permalink
Export NewFromConfig function
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chacin <[email protected]>
  • Loading branch information
pablochacin committed Sep 13, 2023
1 parent 172a349 commit 510e41d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/kubernetes/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Test_Kubernetes(t *testing.T) {
t.Fatalf("failed to create rest client for kubernetes : %s", err)
}

k8s, err := newFromConfig(restcfg)
k8s, err := NewFromConfig(restcfg)
if err != nil {
t.Fatalf("error creating kubernetes client: %v", err)
}
Expand Down Expand Up @@ -299,7 +299,7 @@ func Test_UnsupportedKubernetesVersion(t *testing.T) {
t.Fatalf("failed to create rest client for kubernetes : %s", err)
}

_, err = newFromConfig(restcfg)
_, err = NewFromConfig(restcfg)
if err == nil {
t.Errorf("should had failed creating kubernetes client")
return
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type k8s struct {
kubernetes.Interface
}

// newFromConfig returns a Kubernetes instance configured with the provided kubeconfig.
func newFromConfig(config *rest.Config) (Kubernetes, error) {
// NewFromConfig returns a Kubernetes instance configured with the provided kubeconfig.
func NewFromConfig(config *rest.Config) (Kubernetes, error) {
// As per the discussion in [1] client side rate limiting is no longer required.
// Setting a large limit
// [1] https://github.com/kubernetes/kubernetes/issues/111880
Expand Down Expand Up @@ -62,7 +62,7 @@ func NewFromKubeconfig(kubeconfig string) (Kubernetes, error) {
return nil, err
}

return newFromConfig(config)
return NewFromConfig(config)
}

// New returns a Kubernetes instance or an error when no config is eligible to be used.
Expand All @@ -73,7 +73,7 @@ func NewFromKubeconfig(kubeconfig string) (Kubernetes, error) {
func New() (Kubernetes, error) {
k8sConfig, err := rest.InClusterConfig()
if err == nil {
return newFromConfig(k8sConfig)
return NewFromConfig(k8sConfig)
}

if !errors.Is(err, rest.ErrNotInCluster) {
Expand Down

0 comments on commit 510e41d

Please sign in to comment.