Conversation
…deleting by default and --preview to delete previews
There was a problem hiding this comment.
Pull request overview
This PR implements explicit deployment type targeting for environment variable commands by adding a --prod flag alongside the existing --preview flag. The goal is to require users to explicitly specify whether they're operating on production or preview deployments, particularly for the env rm command to prevent accidental deletions.
Key changes:
- Added
--prodflag to explicitly target production deployments - Added validation to prevent using both
--prodand--previewsimultaneously - Required explicit flag specification for
env rmcommand
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cmd/root.go | Declares the new prodFlag boolean variable |
| cmd/env.go | Adds --prod flag registration and validation logic across env subcommands (add, rm, pull, push) |
| TODO | Marks the TODO item as DONE |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if prodFlag && previewFlag { | ||
| ui.Error("Cannot use both --prod and --preview") | ||
| return fmt.Errorf("conflicting flags") | ||
| } |
There was a problem hiding this comment.
The runEnvPull function doesn't check if neither --prod nor --preview is specified, unlike runEnvRm. This creates inconsistent behavior - runEnvPull will default to production when no flag is specified, while runEnvRm requires an explicit flag. For consistency and to prevent accidental production operations, runEnvPull should also require an explicit flag specification.
| } | |
| } | |
| if !prodFlag && !previewFlag { | |
| ui.Error("Please specify either --prod or --preview") | |
| return fmt.Errorf("no environment specified") | |
| } |
| if prodFlag && previewFlag { | ||
| ui.Error("Cannot use both --prod and --preview") | ||
| return fmt.Errorf("conflicting flags") | ||
| } |
There was a problem hiding this comment.
The runEnvPush function doesn't check if neither --prod nor --preview is specified, unlike runEnvRm. This creates inconsistent behavior - runEnvPush will default to production when no flag is specified, while runEnvRm requires an explicit flag. For consistency and to prevent accidental production operations, runEnvPush should also require an explicit flag specification.
| } | |
| } | |
| if !prodFlag && !previewFlag { | |
| ui.Error("You must specify either --prod or --preview") | |
| return fmt.Errorf("missing required environment flag") | |
| } |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Env vars should now use --prod to delete prod instead of deleting by default and --preview to delete previews