Skip to content

Commit ef11dba

Browse files
authored
feat: add namespace command (#12)
Closes #11.
1 parent b0c3fdc commit ef11dba

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

pkg/cmd/namespace.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
8+
"github.com/SwissDataScienceCenter/renku-dev-utils/pkg/github"
9+
ns "github.com/SwissDataScienceCenter/renku-dev-utils/pkg/namespace"
10+
"github.com/spf13/cobra"
11+
)
12+
13+
var namespaceCmd = &cobra.Command{
14+
Use: "namespace",
15+
Aliases: []string{"ns"},
16+
Short: "Print the kubernetes namespace of the current deployment",
17+
Run: namespaceFn,
18+
}
19+
20+
func namespaceFn(cmd *cobra.Command, args []string) {
21+
ctx := context.Background()
22+
23+
cli, err := github.NewGitHubCLI("")
24+
if err != nil {
25+
fmt.Println(err)
26+
os.Exit(1)
27+
}
28+
namespace, err = ns.FindCurrentNamespace(ctx, cli)
29+
if err != nil {
30+
fmt.Println(err)
31+
os.Exit(1)
32+
}
33+
34+
fmt.Printf("%s\n", namespace)
35+
}

pkg/cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func init() {
3434
rootCmd.AddCommand(cleanupDeploymentCmd)
3535
rootCmd.AddCommand(copyKeycloakAdminPasswordCmd)
3636
rootCmd.AddCommand(makeMeAdminCmd)
37+
rootCmd.AddCommand(namespaceCmd)
3738
rootCmd.AddCommand(openDeploymentCmd)
3839
rootCmd.AddCommand(versionCmd)
3940
}

0 commit comments

Comments
 (0)