From 0e7b1bccc3e8ff5e0e5d38cdf04b57a93e3dac58 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 27 Jul 2017 17:01:07 +0100 Subject: [PATCH] first spike of cleanup tenant --- cmds/cleanup.go | 32 ++++++++++++++++++++++++++++++++ cmds/environ.go | 4 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/cmds/cleanup.go b/cmds/cleanup.go index 5d0b610c3..ce0e2beec 100644 --- a/cmds/cleanup.go +++ b/cmds/cleanup.go @@ -99,6 +99,38 @@ func NewCmdCleanUpApp(f *cmdutil.Factory) *cobra.Command { return cmd } +func NewCmdCleanUpTenant(f *cmdutil.Factory) *cobra.Command { + cmd := &cobra.Command{ + Use: "tenant", + Short: "Hard delete your tenant removing all pipelines, apps, jobs and releases", + + Run: func(cmd *cobra.Command, args []string) { + var confirm string + if cmd.Flags().Lookup(yesFlag).Value.String() == "true" { + confirm = "y" + } else { + fmt.Fprintf(os.Stdout, `WARNING this is destructive and will remove all your pipelines, apps, jobs and releases. Continue? [y/N] `) + fmt.Scanln(&confirm) + } + + if confirm == "y" { + util.Info("Removing all tenant pipelines...\n") + err := cleanUpTenant(f) + if err != nil { + util.Fatalf("Failed to remove tenant %v", err) + } + return + } + util.Info("Cancelled") + }, + } + return cmd +} + +func cleanUpTenant(f *cmdutil.Factory) error { + return nil +} + func deleteSystem(f *cmdutil.Factory) error { var oc *oclient.Client diff --git a/cmds/environ.go b/cmds/environ.go index 5e8d4ded6..269a9022e 100644 --- a/cmds/environ.go +++ b/cmds/environ.go @@ -155,9 +155,9 @@ func createEnviron(cmd *cobra.Command, args []string, detectedNS string, c *k8cl // NewCmdDeleteEnviron is a command to delete an environ using: gofabric8 delete environ abcd func NewCmdDeleteEnviron(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ - Use: "environ", + Use: "env", Short: "Delete environment from fabric8-environments configmap", - Aliases: []string{"env"}, + Aliases: []string{"environ", "enviroment"}, Run: func(cmd *cobra.Command, args []string) { wp := cmd.Flags().Lookup("work-project").Value.String() detectedNS, c, _ := getOpenShiftClient(f, wp)