diff --git a/pkg/cmd/namespace.go b/pkg/cmd/namespace.go new file mode 100644 index 0000000..fb7d8c2 --- /dev/null +++ b/pkg/cmd/namespace.go @@ -0,0 +1,35 @@ +package cmd + +import ( + "context" + "fmt" + "os" + + "github.com/SwissDataScienceCenter/renku-dev-utils/pkg/github" + ns "github.com/SwissDataScienceCenter/renku-dev-utils/pkg/namespace" + "github.com/spf13/cobra" +) + +var namespaceCmd = &cobra.Command{ + Use: "namespace", + Aliases: []string{"ns"}, + Short: "Print the kubernetes namespace of the current deployment", + Run: namespaceFn, +} + +func namespaceFn(cmd *cobra.Command, args []string) { + ctx := context.Background() + + cli, err := github.NewGitHubCLI("") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + namespace, err = ns.FindCurrentNamespace(ctx, cli) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fmt.Printf("%s\n", namespace) +} diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 9ee9319..5d3e7f8 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -34,6 +34,7 @@ func init() { rootCmd.AddCommand(cleanupDeploymentCmd) rootCmd.AddCommand(copyKeycloakAdminPasswordCmd) rootCmd.AddCommand(makeMeAdminCmd) + rootCmd.AddCommand(namespaceCmd) rootCmd.AddCommand(openDeploymentCmd) rootCmd.AddCommand(versionCmd) }