From 1fb9f5cd65186b845894a34c13e27a8eaece2b23 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Thu, 19 Dec 2024 12:35:45 +0100 Subject: [PATCH] minor default entrypoint docker create, remove default from cli in prep of local use --- Dockerfile | 1 + cmd/create.go | 2 +- cmd/mysql_restore.go | 2 +- cmd/postgres_restore.go | 2 +- cmd/root.go | 10 ---------- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index f38043e..025a8ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -303,6 +303,7 @@ COPY --from=builder /app/bin/app /app/ # default entrypoint is the new go binary already ENTRYPOINT ["/app/app"] +CMD ["create"] # distroless disabled for now, until we switch to the full go based version (without the above bash reference implementation) # FROM bitnami/kubectl:1.28 as kubectl diff --git a/cmd/create.go b/cmd/create.go index 366be15..57327a1 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -11,7 +11,7 @@ import ( // createCmd represents the create command var createCmd = &cobra.Command{ Use: "create", - Short: "(DEFAULT) Creates an application-aware snapshot", + Short: "Creates an application-aware snapshot", // Long: `...`, Run: runCreate, } diff --git a/cmd/mysql_restore.go b/cmd/mysql_restore.go index 844eef3..96912d9 100644 --- a/cmd/mysql_restore.go +++ b/cmd/mysql_restore.go @@ -10,7 +10,7 @@ import ( // mysqlRestoreCmd represents the restore command var mysqlRestoreCmd = &cobra.Command{ Use: "restore", - Short: "Connects to the live mysql/mariadb container and restores the database dump", + Short: "Connects to the live mysql/mariadb container and restores a preexisting database dump", // Long: `...`, Run: func(_ *cobra.Command, _ []string) { config := lib.LoadConfig() diff --git a/cmd/postgres_restore.go b/cmd/postgres_restore.go index 4df07ec..a10353e 100644 --- a/cmd/postgres_restore.go +++ b/cmd/postgres_restore.go @@ -10,7 +10,7 @@ import ( // postgresRestoreCmd represents the dump command var postgresRestoreCmd = &cobra.Command{ Use: "restore", - Short: "Connects to the live postgres container and restores the database dump", + Short: "Connects to the live postgres container and restores a preexisting database dump", // Long: `...`, Run: func(_ *cobra.Command, _ []string) { config := lib.LoadConfig() diff --git a/cmd/root.go b/cmd/root.go index 34c9901..6a0c75b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,12 +1,10 @@ package cmd import ( - "errors" "fmt" "os" "github.com/spf13/cobra" - "github.com/spf13/pflag" ) // rootCmd represents the base command when called without any subcommands @@ -22,14 +20,6 @@ var rootCmd = &cobra.Command{ // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - cmd, _, err := rootCmd.Find(os.Args[1:]) - // default cmd if no cmd is given - // https://github.com/spf13/cobra/issues/823 - if err == nil && cmd.Use == rootCmd.Use && !errors.Is(cmd.Flags().Parse(os.Args[1:]), pflag.ErrHelp) { - args := append([]string{createCmd.Use}, os.Args[1:]...) - rootCmd.SetArgs(args) - } - if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1)