Skip to content

Comments

Save mode for each deployment#1722

Merged
lionello merged 3 commits intomainfrom
jordan/save-mode-with-deployments
Dec 16, 2025
Merged

Save mode for each deployment#1722
lionello merged 3 commits intomainfrom
jordan/save-mode-with-deployments

Conversation

@jordanstephens
Copy link
Member

@jordanstephens jordanstephens commented Dec 16, 2025

Description

Save deployment mode for each deployment and print it when listing deployments

Linked Issues

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Summary by CodeRabbit

  • New Features
    • Deployment mode is now captured and displayed in the deployments list output.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Walkthrough

This PR extends the Deployment message in protobuf to include a deployment mode field, then propagates this change through the CLI by initializing the mode when creating deployments and displaying it in the deployment listings table.

Changes

Cohort / File(s) Summary
Protobuf Schema Updates
src/protos/io/defang/v1/fabric.proto
Added mode field (type DeploymentMode) to the Deployment message at field number 11, extending the deployment structure with mode tracking.
Deployment Request Initialization
src/pkg/cli/composeUp.go
Initializes the Mode field in the DeployRequest using mode.Value() when creating a deployment record.
Deployment Listing Display
src/pkg/cli/deploymentsList.go
Added Mode string field to PrintDeployment struct, populated from d.Mode.String(). Extended deployment table output to include a new Mode column between Deployment and DeployedAt.
Test Updates
src/pkg/cli/deploymentsList_test.go
Updated mock deployment data to set Mode to MODE_UNSPECIFIED and modified test expectations to include the new Mode column in the output table.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review the protobuf field addition for consistency with enum definitions
  • Verify mode initialization logic in composeUp.go aligns with deployment request semantics
  • Confirm the mode string conversion and table column placement in deploymentsList.go produce correct output formatting

Possibly related PRs

  • Onboard users to stacks during deployment #1700 — Modifies the Deployment message in the same protobuf file and deployment payload in composeUp.go to add a Stack field, indicating parallel structural enhancements to deployment metadata.

Suggested reviewers

  • lionello

Poem

🐰 A mode for each deployment, tracked with care,
From proto to listing, the data floats fair,
One field added, displayed with grace,
Deployments now show their rightful place! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Save mode for each deployment' directly and clearly describes the main change: persisting deployment mode metadata and displaying it in deployment listings.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jordan/save-mode-with-deployments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

level=warning msg="[linters_context] running gomodguard failed: unable to read module file go.mod: current working directory must have a go.mod file: if you are not using go modules it is suggested to disable this linter"
level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/pkg/cli/deploymentsList_test.go (1)

83-84: Consider adding test cases for other deployment modes.

The test currently only validates MODE_UNSPECIFIED. While this covers the default case, adding test cases for DEVELOPMENT, STAGING, and PRODUCTION modes would provide better coverage of the new functionality.

src/pkg/cli/deploymentsList.go (1)

55-55: Consider more user-friendly mode display format.

Using .String() displays the full enum name (e.g., "MODE_UNSPECIFIED", "DEVELOPMENT"). Consider transforming these for better readability:

  • "MODE_UNSPECIFIED" → "-" or "Unspecified"
  • "DEVELOPMENT" → "Development" (title case)
  • "STAGING" → "Staging"
  • "PRODUCTION" → "Production"

Example transformation:

-			Mode:        d.Mode.String(),
+			Mode:        formatMode(d.Mode),

Then add a helper function:

func formatMode(mode defangv1.DeploymentMode) string {
	if mode == defangv1.DeploymentMode_MODE_UNSPECIFIED {
		return "-"
	}
	name := mode.String()
	return strings.Title(strings.ToLower(name))
}
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b2963c and 5683557.

⛔ Files ignored due to path filters (1)
  • src/protos/io/defang/v1/fabric.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (4)
  • src/pkg/cli/composeUp.go (1 hunks)
  • src/pkg/cli/deploymentsList.go (3 hunks)
  • src/pkg/cli/deploymentsList_test.go (2 hunks)
  • src/protos/io/defang/v1/fabric.proto (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/pkg/cli/deploymentsList_test.go (3)
src/pkg/modes/modes.go (1)
  • Mode (12-12)
src/protos/io/defang/v1/fabric.pb.go (1)
  • DeploymentMode_MODE_UNSPECIFIED (86-86)
src/pkg/crun/local/local.go (1)
  • Local (21-27)
src/pkg/cli/deploymentsList.go (2)
src/pkg/modes/modes.go (1)
  • Mode (12-12)
src/pkg/term/table.go (1)
  • Table (11-13)
src/pkg/cli/composeUp.go (1)
src/pkg/modes/modes.go (1)
  • Mode (12-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (5)
src/protos/io/defang/v1/fabric.proto (1)

455-455: LGTM! Proto field addition is backward compatible.

The new mode field is properly defined with a sequential field number and uses the existing DeploymentMode enum. Since proto3 treats all fields as optional by default, this change is backward compatible with existing clients and servers.

src/pkg/cli/composeUp.go (1)

164-164: LGTM! Mode is properly propagated to deployment metadata.

The deployment mode from the parameters is correctly set in the PutDeploymentRequest, ensuring the mode is persisted with each deployment.

src/pkg/cli/deploymentsList_test.go (1)

41-41: LGTM! Test properly includes the new Mode field.

The mock deployment correctly includes the Mode field set to MODE_UNSPECIFIED, which is the appropriate default value for deployments without an explicitly set mode.

src/pkg/cli/deploymentsList.go (2)

21-21: LGTM! Mode field properly added to output structure.

The Mode field is correctly added to the PrintDeployment struct for display purposes.


69-69: Note: Column order change may affect output parsers.

Inserting the "Mode" column between "Deployment" and "DeployedAt" changes the table layout. If any scripts or tools parse this output programmatically, they may break. Consider whether adding the Mode column at the end would be less disruptive, or if this breaking change is acceptable for your use case.

@lionello lionello merged commit dc909e4 into main Dec 16, 2025
14 checks passed
@lionello lionello deleted the jordan/save-mode-with-deployments branch December 16, 2025 22:04
@coderabbitai coderabbitai bot mentioned this pull request Jan 25, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants