Skip to content

refactor: update recipe config accessors#279

Open
lionello wants to merge 3 commits into
mainfrom
lio/rename-recipe-keys
Open

refactor: update recipe config accessors#279
lionello wants to merge 3 commits into
mainfrom
lio/rename-recipe-keys

Conversation

@lionello

@lionello lionello commented Jun 3, 2026

Copy link
Copy Markdown
Member

Update recipe config accessors to use namespaced accessors for AWS, Azure, and GCP.

This means recipes use provider specific keys, ie. defang-aws, defang-gcp, defang-azure which is how all other providers manage their config.

Summary by CodeRabbit

  • Refactor
    • Configuration reorganized so provider settings are scoped per cloud and log-retention handling is unified across providers.
  • New Features
    • Pulumi stack config is now generated from recipe input or environment and emitted as Pulumi-compatible JSON; project defaults and autonaming behavior are applied consistently.
  • Tests
    • Expanded config parsing and end-to-end Pulumi integration tests; test environment values made deterministic.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 332d9a95-acd0-4a88-b974-bd6c0a95d4d0

📥 Commits

Reviewing files that changed from the base of the PR and between d05e2d5 and 9350a04.

📒 Files selected for processing (2)
  • cd/config.go
  • cd/config_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cd/config.go
  • cd/config_test.go

📝 Walkthrough

Walkthrough

Introduce a namespaced Recipe config API, migrate AWS/Azure/GCP provider recipes to cloud-scoped namespaces, centralize Pulumi stack config generation into cd/config.go, update cd_main to use JSON stack config, and add tests validating parsing, env-driven config, and Automation API behavior.

Changes

Configuration Namespace Refactoring & CD config consolidation

Layer / File(s) Summary
Recipe abstraction foundation
provider/common/recipe.go
Introduce Recipe type, namespaced typed accessors (boolValue, intValue, stringValue), NewRecipe(namespace), and export Defang with Prefix/Version. (ranges: range_310be393f5cb, range_6a98498c55df, range_08feb8cb1ab2)
AWS provider recipe migration
provider/defangaws/aws/recipe.go, provider/defangaws/aws/infra.go, provider/defangaws/aws/lb.go
Migrate AWS recipe vars to common.NewRecipe("defang-aws") and update consuming files to use package LogRetentionDays. (ranges: range_b7c74879e684, range_59bf60c4c014, range_98ab4b40e9e2, range_7cb10cbd349d, range_827998864af9)
Azure provider recipe migration
provider/defangazure/azure/recipe.go, provider/defangazure/project.go
Migrate Azure recipe to defang-azure, add LogRetentionDays, remove DeletionProtection, and update project.go to use providerazure.LogRetentionDays. (ranges: range_25385363721f, range_a40803fe2a2c, range_95d69833875a, range_6119063c9b66)
GCP provider recipe migration
provider/defanggcp/gcp/recipe.go
Migrate GCP recipe to defang-gcp and replace common.DeletionProtection with recipe.Bool("deletion-protection", false). (ranges: range_3b46bcc0bb41)
Pulumi CD program update
cd/program/project_pb.go, cd/cd_main.go
Switch parseStateURL to common.Defang.String(...).Get(ctx), replace auto.ConfigMap flow with stackConfigJson(...) and call stack.SetAllConfigJson, and inline project workspace config. (ranges: range_d2c02cc91fed, range_797263618912, range_a18b77a1036d, range_fd47bb75e468)
Centralized cd config implementation
cd/config.go
Add stackConfigJson, unmarshalRecipe, setDefaultStackConfig, addStackConfigFromEnv, configMap/configValue and MarshalJSON to produce Pulumi CLI-compatible JSON. (ranges: range_7d56bbbab739, range_2d1e122d4675, range_121c107277c8, range_4a5128805683, range_5da7964bfa41)
cd config tests & Automation API test
cd/config_test.go
Add tests for default autonaming, env-based provider config (AWS/GCP/Azure), parsing YAML/JSON Pulumi config, marshaling configMap, and an Automation API integration test. (ranges: range_810e5c40cdc1, range_01fac6e3e396, range_0b06a0d84812, range_ed8bccea6a75, range_9455267559b9, range_7b6ab750feb1, range_60aadb12027a, range_d3b61cad63b3, range_af541df3c312, range_4d746a58a7fa)
Test harness updates and removals
cd/main_test.go, cd/cd_main_test.go, cd/cd_main_integration_test.go
Add TEST_PROJECT constant and set PROJECT deterministically, remove legacy stack-config tests/helpers from cd_main_test, and update integration test to use TEST_PROJECT. (ranges: range_00f362d32635, range_b07490baf848, range_e4a7606f5f1a, range_3644368b19c4, range_edf8316f30bd, range_1c393f007cec)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Suggested labels

azure

Suggested reviewers

  • edwardrf
  • jordanstephens

Poem

🐰 I hopped through recipes, neat and spry,
Namespaces stitched beneath the sky.
AWS, Azure, GCP in line,
Pulumi configs now cleanly shine.
This rabbit cheers — one tidy deploy, oh my!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main focus of the changeset: refactoring recipe configuration accessors to use provider-specific namespaced keys.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lio/rename-recipe-keys

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

@lionello lionello changed the title refactor: update recipe config accessors to use namespaced accessors … refactor: update recipe config accessors Jun 3, 2026
@lionello lionello temporarily deployed to defang-staging June 3, 2026 18:44 — with GitHub Actions Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@provider/defangaws/aws/recipe.go`:
- Around line 5-30: The recipe currently reads AWS settings (e.g.,
DeletionProtection, BackupRetentionDays, LogRetentionDays) only from defang-aws
which silently falls back to defaults; update these accessors so they first try
the defang-aws key and if missing check the legacy defang namespace (e.g., read
defang:deletion-protection when recipe.Bool("deletion-protection") is absent)
before applying the default. Modify the logic around the recipe variable created
by common.NewRecipe("defang-aws") to perform a fallback lookup for the specific
symbols DeletionProtection, BackupRetentionDays, LogRetentionDays (and any other
AWS-related flags like AllowOverwriteRecords/RetainDnsOnDelete) by querying the
legacy key and returning that value when present, or else the existing default.
🪄 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: d7b72592-9a5e-4c4b-b763-0692526dae7d

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac2986 and 0687549.

📒 Files selected for processing (8)
  • cd/program/project_pb.go
  • provider/common/recipe.go
  • provider/defangaws/aws/infra.go
  • provider/defangaws/aws/lb.go
  • provider/defangaws/aws/recipe.go
  • provider/defangazure/azure/recipe.go
  • provider/defangazure/project.go
  • provider/defanggcp/gcp/recipe.go

Comment thread provider/defangaws/aws/recipe.go
@lionello lionello temporarily deployed to defang-staging June 5, 2026 15:23 — with GitHub Actions Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cd/config.go`:
- Around line 141-163: In addStackConfigFromEnv, avoid overwriting
recipe-provided values and false-positive errors by first checking config for
existing keys: when setting keys like "defang:cdImage", "defang:etag",
"defang:org", "defang:stateUrl" and "defang:provider" only write into config if
the corresponding env var is non-empty OR the config map does not already
contain that key; likewise, when validating the provider (the logic that
currently errors if no provider env var is present), first consult
config["defang:provider"] and only error if neither the env var nor an existing
config entry exist. Use the function name addStackConfigFromEnv, the config map
and configValue struct to locate where to apply these conditional writes and the
provider validation to fix.
🪄 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: 8901c8a2-6500-4d1e-b68c-19d987607ad8

📥 Commits

Reviewing files that changed from the base of the PR and between 0687549 and d05e2d5.

📒 Files selected for processing (6)
  • cd/cd_main.go
  • cd/cd_main_integration_test.go
  • cd/cd_main_test.go
  • cd/config.go
  • cd/config_test.go
  • cd/main_test.go
💤 Files with no reviewable changes (1)
  • cd/cd_main_test.go
✅ Files skipped from review due to trivial changes (1)
  • cd/main_test.go

Comment thread cd/config.go
@lionello lionello temporarily deployed to defang-staging June 10, 2026 14:16 — with GitHub Actions Inactive
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