Skip to content

Commit

Permalink
Merge pull request #150 from Bharadwajshivam28/default_namespace
Browse files Browse the repository at this point in the history
Fixed the default namespace issue
  • Loading branch information
k8s-ci-robot authored Feb 15, 2024
2 parents b648ff7 + b3b74dd commit eb138c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var rootCmd = &cobra.Command{
client.ClientSet = clientSet
common.PrintInfo(client.ClientSet, config)
if cleanup {
common.SetDefaultNamespace()
service.Cleanup(client.ClientSet)
} else if listImages {
service.PrintListImages(client.ClientSet)
Expand Down
6 changes: 6 additions & 0 deletions pkg/common/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) {
log.Printf("Server version : %#v", *serverVersion)
}

func SetDefaultNamespace() {
if viper.Get("namespace") == "" {
viper.Set("namespace", DefaultNamespace)
}
}

// ValidateArgs validates the arguments passed to the program
// and creates the output directory if it doesn't exist

Expand Down
1 change: 1 addition & 0 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func RunE2E(clientset *kubernetes.Clientset) {
// Cleanup removes all resources created during E2E tests.
func Cleanup(clientset *kubernetes.Clientset) {
namespace := viper.GetString("namespace")
log.Printf("using namespace: %v", namespace)

err := clientset.CoreV1().Pods(namespace).Delete(ctx, common.PodName, metav1.DeleteOptions{})
if err != nil {
Expand Down

0 comments on commit eb138c8

Please sign in to comment.