Conversation
Allow template deploy to run without interactive prompts by passing variables via --var flag. In non-interactive mode, missing variables are reported upfront with helpful hints. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughAdded a Changes
Sequence Diagram(s)sequenceDiagram
participant CLI
participant DeployCmd as "deploy.go"
participant Prompt as "Interactive Prompt"
participant DomainAPI as "Domain Availability API"
CLI->>DeployCmd: parse flags (--var => opts.vars)
DeployCmd->>DeployCmd: load template raw.Spec.Variables
alt non-interactive
DeployCmd->>DeployCmd: check all variables present in opts.vars
DeployCmd-->>CLI: error if missing variables
else interactive or partial
loop for each variable
DeployCmd->>DeployCmd: if var in opts.vars use value
alt var type == DOMAIN and region != "sha1"
DeployCmd->>DomainAPI: check domain availability
DomainAPI-->>DeployCmd: available / unavailable
alt unavailable
DeployCmd-->>CLI: error (domain unavailable)
end
else if not provided
DeployCmd->>Prompt: prompt user for value
Prompt-->>DeployCmd: user input
end
end
end
DeployCmd->>CLI: proceed with deployment using resolved vars
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5b80e85df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !f.Interactive { | ||
| var missingVars []string | ||
| for _, v := range raw.Spec.Variables { | ||
| if _, ok := opts.vars[v.Key]; !ok { | ||
| missingVars = append(missingVars, fmt.Sprintf(" --var %s=<value> (%s)", v.Key, v.Description)) |
There was a problem hiding this comment.
Skip DOMAIN vars for sha1 in non-interactive precheck
In non-interactive mode this loop treats every template variable as required, but later in the same function DOMAIN variables are explicitly skipped when project.Region.ID == "sha1" (they’re not supported and the deploy proceeds without them). That means zeabur template deploy -i=false against a sha1 project will always fail with “missing required variables” if the template includes a DOMAIN variable, even though it would have been accepted interactively. Consider exempting DOMAIN vars for sha1 (or mirroring the later conditional) when building missingVars so CI deployments in that region don’t get blocked unnecessarily.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds support for supplying template variables via a --var KEY=value flag to enable non-interactive (CI/CD) deployments, with upfront validation of required variables when running without prompts.
Changes:
- Add
--var(StringToStringVar) flag and store parsed values inOptions.vars. - In non-interactive mode, validate missing template variables upfront and return a consolidated error.
- Prefer
--var-provided values over interactive prompts when building the variables map for deployment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // In non-interactive mode, check all required variables upfront | ||
| if !f.Interactive { | ||
| var missingVars []string | ||
| for _, v := range raw.Spec.Variables { |
There was a problem hiding this comment.
The upfront missing-variable check in non-interactive mode currently treats all template variables as required. This can break existing behavior for DOMAIN variables in region "sha1": later in the loop DOMAIN variables are explicitly skipped for sha1, but the pre-check will still fail unless the user provides --var for them. Align the pre-check with the actual per-variable handling (e.g., skip DOMAIN variables when project.Region.ID == "sha1", and generally only require vars that will actually be consumed).
| // In non-interactive mode, check all required variables upfront | |
| if !f.Interactive { | |
| var missingVars []string | |
| for _, v := range raw.Spec.Variables { | |
| // In non-interactive mode, check all required variables upfront, | |
| // but only for variables that will actually be consumed later. | |
| if !f.Interactive { | |
| var missingVars []string | |
| for _, v := range raw.Spec.Variables { | |
| // DOMAIN variables are skipped for region "sha1" later in the loop, | |
| // so they should not be treated as required here either. | |
| if project.Region != nil && project.Region.ID == "sha1" && v.Type == "DOMAIN" { | |
| continue | |
| } |
| // Check if variable is provided via --var flag | ||
| if val, ok := opts.vars[v.Key]; ok { | ||
| vars[v.Key] = val | ||
| continue | ||
| } |
There was a problem hiding this comment.
--var values are applied before the type-specific logic and continue, which means DOMAIN variables provided via --var bypass the sha1-region skip + warning and the availability check (CheckDomainAvailable). Consider handling DOMAIN keys specially even when provided via --var (e.g., in sha1 ignore with the existing warning, otherwise validate availability and return a clear error if unavailable) so --var doesn’t change DOMAIN semantics.
Previously, DOMAIN type variables provided via --var flag were not validated for availability, allowing deployment with taken domains. Now the CLI checks domain availability before deploying. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
--var KEY=valueflag tozeabur template deploycommand--varUsage
Test plan
--varshows all missing variables--varflags deploys successfully--varshows only missing variables--var🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.