Skip to content

Commit

Permalink
fir err msg
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
  • Loading branch information
odubajDT committed Oct 3, 2024
1 parent 79bffb5 commit 062d966
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
3 changes: 0 additions & 3 deletions internal/metadataproviders/kubeadm/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ type kubeadmProvider struct {
}

func NewProvider(configMapName string, configMapNamespace string, apiConf k8sconfig.APIConfig) (Provider, error) {
if configMapName == "" || configMapNamespace == "" {
return nil, fmt.Errorf("configMapName and configMapNamespace can't be empty")
}
k8sAPIClient, err := k8sconfig.MakeClient(apiConf)
if err != nil {
return nil, fmt.Errorf("failed to create K8s API client: %w", err)
Expand Down
11 changes: 1 addition & 10 deletions internal/metadataproviders/kubeadm/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ func TestNewProvider(t *testing.T) {
t.Setenv("KUBERNETES_SERVICE_HOST", "127.0.0.1")
t.Setenv("KUBERNETES_SERVICE_PORT", "6443")

_, err := NewProvider("", "", k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeNone})
assert.EqualError(t, err, "configMapName and configMapNamespace can't be empty")

_, err = NewProvider("", "ns", k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeNone})
assert.EqualError(t, err, "configMapName and configMapNamespace can't be empty")

_, err = NewProvider("name", "", k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeNone})
assert.EqualError(t, err, "configMapName and configMapNamespace can't be empty")

_, err = NewProvider("name", "ns", k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeNone})
_, err := NewProvider("name", "ns", k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeNone})
assert.NoError(t, err)
}

Expand Down

0 comments on commit 062d966

Please sign in to comment.