Skip to content

Commit

Permalink
feat(cli): namespace creation on install
Browse files Browse the repository at this point in the history
Signed-off-by: christoph <[email protected]>
  • Loading branch information
christophenne committed Sep 13, 2024
1 parent 3530b0b commit b13c5e3
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions cmd/glasskube/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/glasskube/glasskube/pkg/install"
"github.com/glasskube/glasskube/pkg/statuswriter"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -223,20 +222,10 @@ var installCmd = &cobra.Command{
}

if installCmdOptions.NamespaceOptions.Namespace != "" {
exists, err := namespaces.IsNamespaceInstalled(
ctx,
cs,
installCmdOptions.NamespaceOptions.Namespace,
)
if errors.IsNotFound(err) && !exists {
fmt.Printf(" * Namespace %v does not exist and will be created",
installCmdOptions.NamespaceOptions.Namespace,
)
err := namespaces.InstallNamespace(
ctx,
cs,
installCmdOptions.NamespaceOptions.Namespace,
)
if ok, err := namespaces.IsNamespaceInstalled(ctx, cs, installCmdOptions.NamespaceOptions.Namespace); !ok {
fmt.Printf(" * Namespace %v does not exist and will be created\n",
installCmdOptions.NamespaceOptions.Namespace)
err := namespaces.InstallNamespace(ctx, cs, installCmdOptions.NamespaceOptions.Namespace)
if err != nil {
fmt.Fprintf(os.Stderr, "An error occurred in creating the Namespace:\n\n%v\n", err)
cliutils.ExitWithError()
Expand Down

0 comments on commit b13c5e3

Please sign in to comment.