Skip to content

Commit

Permalink
feat: add cleanup script for local path provisioner (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdand-weka authored Dec 21, 2023
1 parent 5ce5518 commit 281e18b
Show file tree
Hide file tree
Showing 19 changed files with 505 additions and 273 deletions.
2 changes: 0 additions & 2 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/weka/gohomecli/internal/cli/api"
"github.com/weka/gohomecli/internal/cli/app"
"github.com/weka/gohomecli/internal/cli/config"
"github.com/weka/gohomecli/internal/cli/install"
"github.com/weka/gohomecli/internal/cli/local"
"github.com/weka/gohomecli/internal/utils"
)
Expand All @@ -15,7 +14,6 @@ func init() {
api.Cli.InitCobra(app.Cmd())
config.Cli.InitCobra(app.Cmd())
local.Cli.InitCobra(app.Cmd())
install.Cli.InitCobra(app.Cmd())
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
42 changes: 0 additions & 42 deletions internal/cli/install/chart/cli.go

This file was deleted.

48 changes: 0 additions & 48 deletions internal/cli/install/configure/configure.go

This file was deleted.

41 changes: 0 additions & 41 deletions internal/cli/install/install.go

This file was deleted.

81 changes: 0 additions & 81 deletions internal/cli/install/k3s/k3s.go

This file was deleted.

22 changes: 22 additions & 0 deletions internal/cli/local/cleanup/cleanup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cleanup

import (
"github.com/spf13/cobra"

"github.com/weka/gohomecli/internal/cli/app/hooks"
)

var (
Cli hooks.Cli
)

var cleanupCmd = &cobra.Command{
Use: "cleanup",
Short: "Cleanup local setup",
}

func init() {
Cli.AddHook(func(appCmd *cobra.Command) {
appCmd.AddCommand(cleanupCmd)
})
}
31 changes: 31 additions & 0 deletions internal/cli/local/cleanup/local-storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cleanup

import (
"github.com/spf13/cobra"
"github.com/weka/gohomecli/internal/local/cleanup"
)

var config struct {
LocalPath string
}

var localStorageCmd = &cobra.Command{
Use: "local-storage",
Short: "cleans up unused volumes from local path provisioner",
RunE: func(cmd *cobra.Command, args []string) error {
if config.LocalPath != "" {
cleanup.SetLocalStoragePath(config.LocalPath)
}

return cleanup.LocalStorage(cmd.Context())
},
}

func init() {
Cli = append(Cli, func(c *cobra.Command) {
cleanupCmd.AddCommand(localStorageCmd)

cleanupCmd.Flags().StringVar(&config.LocalPath, "path", "", "directory to local-path-provisioner")
cleanupCmd.Flags().MarkHidden("bundle")
})
}
12 changes: 6 additions & 6 deletions internal/cli/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"github.com/spf13/cobra"

"github.com/weka/gohomecli/internal/cli/app/hooks"
"github.com/weka/gohomecli/internal/cli/install/chart"
"github.com/weka/gohomecli/internal/cli/install/configure"
"github.com/weka/gohomecli/internal/cli/install/k3s"
"github.com/weka/gohomecli/internal/cli/local/cleanup"
"github.com/weka/gohomecli/internal/cli/local/dump"
"github.com/weka/gohomecli/internal/cli/local/setup"
"github.com/weka/gohomecli/internal/cli/local/upgrade"
"github.com/weka/gohomecli/internal/env"
"github.com/weka/gohomecli/internal/utils"
)
Expand Down Expand Up @@ -37,8 +37,8 @@ func init() {
appCmd.AddCommand(localCmd)

dump.Cli.InitCobra(localCmd)
k3s.Cli.InitCobra(localCmd)
chart.Cli.InitCobra(localCmd)
configure.Cli.InitCobra(localCmd)
setup.Cli.InitCobra(localCmd)
upgrade.Cli.InitCobra(localCmd)
cleanup.Cli.InitCobra(localCmd)
})
}
Loading

0 comments on commit 281e18b

Please sign in to comment.