feat(cd): add CD task/job/build ID to Deployment msg#2023
Conversation
📝 WalkthroughWalkthroughThis PR updates the CD command infrastructure and deployment response structures across the CLI and BYOC providers (AWS, GCP, DigitalOcean), replacing the Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (cd.go)
participant Provider as Provider
participant BYOC as BYOC (aws/gcp/do)
participant Recorder as Deployment Recorder
CLI->>Provider: CdCommand(ctx, request)
Provider->>BYOC: runCdCommand()
BYOC-->>Provider: buildId/deploymentId
Provider->>BYOC: Extract CD metadata
BYOC-->>Provider: CdCommandResponse {ETag, CdId, CdType}
Provider-->>CLI: CdCommandResponse {ETag, CdId, CdType}
CLI->>Recorder: putDeploymentAndStack(params with CdId, CdType)
Recorder->>Recorder: Populate Deployment.cd_id, Deployment.cd_type
Recorder-->>CLI: Success
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/pkg/cli/cd.go`:
- Around line 41-44: The code currently treats a nil or incomplete provider
response as success when err == nil; update the post-call check after
provider.CdCommand(ctx, client.CdCommandRequest{...}) to return a non-nil error
if cd == nil or cd.ETag == "" (e.g., fmt.Errorf("invalid CdCommand response: cd
is nil or missing ETag")) instead of returning "", nil so incomplete responses
are surfaced; adjust the caller expectations accordingly.
In `@src/pkg/cli/client/byoc/aws/byoc.go`:
- Around line 295-302: The code dereferences cdBuildId when building the
DeployResponse; add a nil check for cdBuildId returned from runCdCommand (or
AwsCodeBuild.Run) before using *cdBuildId and return a clear error if it's nil.
Update the function that constructs the DeployResponse (where
DeployResponse.CdId is set) to validate cdBuildId != nil, mirror the guard logic
used in QueryBuildID/TailBuildID, and avoid creating the response when cdBuildId
is nil so you don't panic.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: a34e55a8-4fca-4339-b2a0-7b120012c493
⛔ Files ignored due to path filters (1)
src/protos/io/defang/v1/fabric.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (15)
src/pkg/cli/cd.gosrc/pkg/cli/client/byoc/aws/byoc.gosrc/pkg/cli/client/byoc/baseclient.gosrc/pkg/cli/client/byoc/do/byoc.gosrc/pkg/cli/client/byoc/gcp/byoc.gosrc/pkg/cli/client/byoc/gcp/byoc_test.gosrc/pkg/cli/client/playground.gosrc/pkg/cli/client/provider.gosrc/pkg/cli/common.gosrc/pkg/cli/composeDown_test.gosrc/pkg/cli/composeUp.gosrc/pkg/cli/composeUp_test.gosrc/pkg/cli/destroy_test.gosrc/pkg/stacks/stacks.gosrc/protos/io/defang/v1/fabric.proto
Description
Add CD build/task ID to Fabric in Deployment struct. This allows us to check whether a deployment is running, or to abort "defang deploy" and continue it later.
Most of the PR is to make sure the
Deploy/Preview/CdCommandprovider funcs return the CD info to their callers.Linked Issues
Checklist