From c17f387f31a45c97b7c3ddcceff3bd1954102d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Egelund-M=C3=BCller?= Date: Thu, 2 Jan 2025 13:10:45 +0100 Subject: [PATCH] CLI: Support specifying org in `sudo project reset` (#6343) --- cli/cmd/sudo/project/reset.go | 40 ++++++++++++----------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/cli/cmd/sudo/project/reset.go b/cli/cmd/sudo/project/reset.go index 7e1dcc4bac4..c57aa93ae1c 100644 --- a/cli/cmd/sudo/project/reset.go +++ b/cli/cmd/sudo/project/reset.go @@ -1,46 +1,31 @@ package project import ( - "fmt" - "github.com/rilldata/rill/cli/pkg/cmdutil" adminv1 "github.com/rilldata/rill/proto/gen/rill/admin/v1" "github.com/spf13/cobra" ) func ResetCmd(ch *cmdutil.Helper) *cobra.Command { - var project, path string var force bool resetCmd := &cobra.Command{ - Use: "reset []", - Args: cobra.MaximumNArgs(1), - Short: "Re-deploy project", - Long: "Create a new deployment for the project (and tear down the current one)", - PersistentPreRunE: cmdutil.CheckChain(cmdutil.CheckAuth(ch), cmdutil.CheckOrganization(ch)), + Use: "reset ", + Args: cobra.ExactArgs(2), + Short: "Re-deploy the project", + Long: "Create a new deployment for the project (and tear down the current one)", RunE: func(cmd *cobra.Command, args []string) error { - ctx := cmd.Context() + org := args[0] + project := args[1] client, err := ch.Client() if err != nil { return err } - if len(args) > 0 { - project = args[0] - } - - if !cmd.Flags().Changed("project") && len(args) == 0 && ch.Interactive { - var err error - project, err = ch.InferProjectName(ctx, ch.Org, path) - if err != nil { - return fmt.Errorf("unable to infer project name (use `--project` to explicitly specify the name): %w", err) - } - } - if !force { - ch.PrintfWarn("This will create a new deployment, which means your project may be unavailable for a while as data sources are reloaded from scratch. If you just need to refresh data, use `rill project refresh`.\n") - ok, err := cmdutil.ConfirmPrompt("Do you want to continue?", "", false) + ch.PrintfWarn("The project will be unavailable for a while as data sources are reloaded from scratch. If you just need to refresh data, use `rill project refresh`.\n") + ok, err := cmdutil.ConfirmPrompt("Continue?", "", false) if err != nil { return err } @@ -49,20 +34,21 @@ func ResetCmd(ch *cmdutil.Helper) *cobra.Command { } } - _, err = client.RedeployProject(ctx, &adminv1.RedeployProjectRequest{Organization: ch.Org, Project: project}) + _, err = client.RedeployProject(cmd.Context(), &adminv1.RedeployProjectRequest{ + Organization: org, + Project: project, + }) if err != nil { return err } - fmt.Printf("Triggered project reset. To see status, run `rill project status --project %s`.\n", project) + ch.Printf("Triggered reset of %q.\n", project) return nil }, } resetCmd.Flags().SortFlags = false - resetCmd.Flags().StringVar(&project, "project", "", "Project name") - resetCmd.Flags().StringVar(&path, "path", ".", "Project directory") resetCmd.Flags().BoolVar(&force, "force", false, "Force reset even if project is already deployed") return resetCmd }