feat(template): support deploy by template code with -c/--code flag#195
feat(template): support deploy by template code with -c/--code flag#195
Conversation
Add `-c/--code` flag to `template deploy` so users can deploy marketplace templates directly by code without manually fetching the YAML first. Before: zeabur template get -c KXL04P --raw > /tmp/mongodb.yaml zeabur template deploy -f /tmp/mongodb.yaml --project-id <id> After: zeabur template deploy -c KXL04P --project-id <id> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI as Deploy Command
participant Validator as Validation Logic
participant HTTP as HTTP Client
participant Zeabur as Zeabur Server
User->>CLI: run deploy --code=abc123
CLI->>Validator: validate flags (--file / --code)
alt invalid: both or neither provided
Validator-->>CLI: return validation error
CLI-->>User: show error
else valid (--code)
Validator-->>CLI: validation passed
CLI->>HTTP: GET https://zeabur.com/templates/abc123.yaml (30s timeout)
HTTP->>Zeabur: request
alt 200 OK
Zeabur-->>HTTP: 200 + body
HTTP-->>CLI: template content
CLI-->>User: proceed with deploy
else 404
Zeabur-->>HTTP: 404 Not Found
HTTP-->>CLI: "template not found" error
CLI-->>User: show error
else other non-200
Zeabur-->>HTTP: non-200 status
HTTP-->>CLI: unexpected status error
CLI-->>User: show error
end
end
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 docstrings
🧪 Generate unit tests (beta)
Comment |
Update instructions to use `template deploy -c <code>` instead of the two-step `template get --raw > file && template deploy -f file` workflow. Depends on zeabur/cli#195. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cmd/template/deploy/deploy.go`:
- Around line 63-81: The current fetch uses http.Get without timeout and reports
any non-200 as "not found"; replace it with a context.WithTimeout (import
context and time) and perform the request with http.NewRequestWithContext or an
http.Client with Timeout to enforce a deadline when fetching templateURL (the
block handling opts.code and spinner s). After s.Start(), create ctx, do the
request with the timeout, stop s on error, defer resp.Body.Close(), and then
distinguish resp.StatusCode==http.StatusNotFound to return "template not found
(code: %s)" while returning a different error for other non-200 codes like
"failed fetching template (code: %s, HTTP %d)". Ensure spinner s is stopped in
all early-return paths.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fcfec7dc-9e7c-4d61-8c9c-679385b1d939
📒 Files selected for processing (1)
internal/cmd/template/deploy/deploy.go
Use context.WithTimeout (30s) consistent with get.go pattern. Distinguish 404 "template not found" from other HTTP errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cmd/template/deploy/deploy.go`:
- Around line 338-340: The code currently unconditionally errors when both
opts.file and opts.code are empty; change it to only return the "one required"
error in non-interactive runs and keep the mutual-exclusion behavior for
both-set. Concretely: retain the existing mutual-exclusion check for opts.file
&& opts.code and return an error there, but for the "neither provided" case,
branch on the runtime interactive flag (use the existing interactive indicator
in your CLI context, e.g., opts.interactive or the command IO helper such as
o.IO.IsInteractive()) — if non-interactive return the fmt.Errorf, otherwise
allow execution to continue so the command can prompt the user for a source
selection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bab2ee6c-534b-4ae9-92c3-716f5fa53324
📒 Files selected for processing (1)
internal/cmd/template/deploy/deploy.go
…ags provided In interactive mode, prompt user to choose between file and code source instead of hard-failing. Non-interactive mode still requires explicit flags. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
#23) * fix: prevent duplicate services on redeploy and add marketplace deploy - zeabur-deploy: split into "First Deploy" and "Redeploy" sections, emphasize that --service-id is REQUIRED for redeployment to avoid creating duplicate services, and mandate saving service-id after first deploy - zeabur-template-deploy: add Marketplace Prebuilt Services section with --marketplace-code flag for common services (MongoDB, PostgreSQL, MySQL, Redis, MinIO) so AI doesn't write custom template YAML files for services that already exist in the marketplace Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add marketplace prebuilt services section to template-deploy skill Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: replace deprecated marketplace-code with template search + get workflow Use `template search` → `template get -c <code> --raw` → `template deploy -f` instead of the deprecated `--marketplace-code` flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use new -c/--code flag for marketplace template deploy Update instructions to use `template deploy -c <code>` instead of the two-step `template get --raw > file && template deploy -f file` workflow. Depends on zeabur/cli#195. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add advanced section for fetch-and-customize workflow Keep `template get --raw` + edit + `deploy -f` as an advanced use case for users who need to customize the template YAML before deploying. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
-c/--codeflag totemplate deploycommandhttps://zeabur.com/templates/<code>.yamland deploys it directly-f/--file— only one can be specifiedBefore
After
Test plan
go build ./...passesgo test ./...passestemplate deploy --helpshows new-c/--codeflagtemplate deploy -c KXL04P --project-id <id>deploys MongoDB successfully🤖 Generated with Claude Code
Summary by CodeRabbit