From 3a9d817d6da6a7f8779852d9e018e0aefef3b989 Mon Sep 17 00:00:00 2001 From: hardwarepro <92922224+scooterthedev@users.noreply.github.com> Date: Thu, 18 Dec 2025 06:51:55 -0500 Subject: [PATCH 1/3] Added TODO #2 - Env vars should use --prod to delete prod instead of deleting by default and --preview to delete previews --- TODO | 2 +- cmd/env.go | 32 ++++++++++++++++++++++++++++++-- cmd/root.go | 1 + 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 2eb17d1..a4d0110 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ - move detection to https://github.com/coollabsio/coolpack -- Env vars should use `--prod` to delete prod, instead of deleting prod by default and using `--preview` to delete preview +- Env vars should use `--prod` to delete prod, instead of deleting prod by default and using `--preview` to delete preview - DONE - Fix spacing issues (use debug flag `CDP_DEBUG=1 cdp`) to see where it is coming from - **BIG THING:** allow preview deployments with git setup - For Docker this cannot work, but git deploys should set up Coolify to work with GitHub PRs on the deploy repo diff --git a/cmd/env.go b/cmd/env.go index d17b929..9cf3f30 100644 --- a/cmd/env.go +++ b/cmd/env.go @@ -58,8 +58,8 @@ func init() { envCmd.AddCommand(envPullCmd) envCmd.AddCommand(envPushCmd) - // Add --preview flag for env commands to target preview deployments (from PRs) envCmd.PersistentFlags().BoolVar(&previewFlag, "preview", false, "Target preview deployments (from Pull Requests)") + envCmd.PersistentFlags().BoolVar(&prodFlag, "prod", false, "Target production deployment (from Pull Requests)") } func getAppUUID() (string, *api.Client, error) { @@ -163,7 +163,11 @@ func runEnvAdd(cmd *cobra.Command, args []string) error { return err } - // Set is_preview based on flag + if prodFlag && previewFlag { + ui.Error("Cannot use both --prod and --preview") + return fmt.Errorf("conflicting flags") + } + isPreview := previewFlag ui.Info(fmt.Sprintf("Adding %s...", key)) @@ -189,6 +193,20 @@ func runEnvRm(cmd *cobra.Command, args []string) error { return err } + if !prodFlag && !previewFlag { + ui.Error("Must use either --prod or --preview flag") + ui.Spacer() + ui.Print("Examples:") + ui.Print(" " + ui.CodeStyle.Render(fmt.Sprintf("%s env rm KEY --prod", execName()))) + ui.Print(" " + ui.CodeStyle.Render(fmt.Sprintf("%s env rm KEY --preview", execName()))) + return fmt.Errorf("deployment type not specified") + } + + if prodFlag && previewFlag { + ui.Error("Cannot use both --prod and --preview") + return fmt.Errorf("conflicting flags") + } + // Confirm deletion confirmed, err := ui.ConfirmAction("remove environment variable", key) if err != nil { @@ -246,6 +264,11 @@ func runEnvPull(cmd *cobra.Command, args []string) error { return err } + if prodFlag && previewFlag { + ui.Error("Cannot use both --prod and --preview") + return fmt.Errorf("conflicting flags") + } + deploymentType := "production" if previewFlag { deploymentType = "preview" @@ -316,6 +339,11 @@ func runEnvPush(cmd *cobra.Command, args []string) error { return err } + if prodFlag && previewFlag { + ui.Error("Cannot use both --prod and --preview") + return fmt.Errorf("conflicting flags") + } + deploymentType := "production" if previewFlag { deploymentType = "preview" diff --git a/cmd/root.go b/cmd/root.go index 0fef207..3f16154 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,6 +18,7 @@ var ( // Flags for env command previewFlag bool + prodFlag bool // Global verbose flag verboseFlag bool From cc378a85819dc339c7dde161ed948254bc0f208e Mon Sep 17 00:00:00 2001 From: Scooter <92922224+scooterthedev@users.noreply.github.com> Date: Thu, 18 Dec 2025 07:00:07 -0500 Subject: [PATCH 2/3] Copilot fixes for checking for runEnvAdd Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cmd/env.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/env.go b/cmd/env.go index 9cf3f30..444a741 100644 --- a/cmd/env.go +++ b/cmd/env.go @@ -168,6 +168,10 @@ func runEnvAdd(cmd *cobra.Command, args []string) error { return fmt.Errorf("conflicting flags") } + if !prodFlag && !previewFlag { + ui.Error("You must specify exactly one of --prod or --preview") + return fmt.Errorf("missing environment target flag") + } isPreview := previewFlag ui.Info(fmt.Sprintf("Adding %s...", key)) From 82306afe98ad444895d451b6ff61bb1c30431193 Mon Sep 17 00:00:00 2001 From: Scooter <92922224+scooterthedev@users.noreply.github.com> Date: Thu, 18 Dec 2025 07:01:06 -0500 Subject: [PATCH 3/3] pf Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cmd/env.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/env.go b/cmd/env.go index 444a741..7d2417d 100644 --- a/cmd/env.go +++ b/cmd/env.go @@ -59,7 +59,7 @@ func init() { envCmd.AddCommand(envPushCmd) envCmd.PersistentFlags().BoolVar(&previewFlag, "preview", false, "Target preview deployments (from Pull Requests)") - envCmd.PersistentFlags().BoolVar(&prodFlag, "prod", false, "Target production deployment (from Pull Requests)") + envCmd.PersistentFlags().BoolVar(&prodFlag, "prod", false, "Target main production deployment") } func getAppUUID() (string, *api.Client, error) {