Skip to content

Commit

Permalink
fix: a nit
Browse files Browse the repository at this point in the history
  • Loading branch information
mojtaba-esk committed Jan 7, 2025
1 parent 1a3bbcc commit b81bf31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 9 additions & 5 deletions e2e/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const (

nginxImage = "docker.io/nginx:latest"
nginxVolumeOwner = 0

envK8sHost = "K8S_HOST"
envK8sCACert = "K8S_CA_CERT"
envK8sAuthToken = "K8S_AUTH_TOKEN"
)

type Suite struct {
Expand Down Expand Up @@ -97,16 +101,16 @@ func (s *Suite) RetryOperation(operation func() error, maxRetries int) error {
}

func (s *Suite) K8sDefaultOptions() []k8s.Option {
if os.Getenv("K8S_AUTH_TOKEN") == "" {
s.T().Log("K8S_AUTH_TOKEN is not set, using default cluster config from ~/.kube/config")
if os.Getenv(envK8sAuthToken) == "" || os.Getenv(envK8sCACert) == "" || os.Getenv(envK8sHost) == "" {
s.T().Logf("%s, %s and/or %s are not set, using default cluster config from ~/.kube/config", envK8sAuthToken, envK8sCACert, envK8sHost)
return nil
}

return []k8s.Option{
k8s.WithAuthToken(
os.Getenv("K8S_HOST"),
os.Getenv("K8S_CA_CERT"),
os.Getenv("K8S_AUTH_TOKEN"),
os.Getenv(envK8sHost),
os.Getenv(envK8sCACert),
os.Getenv(envK8sAuthToken),
),
}
}
2 changes: 0 additions & 2 deletions pkg/k8s/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package k8s

import (
"context"
"fmt"

corev1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -26,7 +25,6 @@ func (c *Client) CreateNamespace(ctx context.Context, name string) error {
_, err := c.clientset.CoreV1().Namespaces().Create(ctx, namespace, metav1.CreateOptions{})
if err != nil {
if !apierrs.IsAlreadyExists(err) {
fmt.Printf("err: %v\n", err)
return err
}
c.logger.WithField("name", name).Debug("namespace already exists, continuing")
Expand Down

0 comments on commit b81bf31

Please sign in to comment.