Skip to content

fix(samples): exclude auto-populated Defang vars from detected sample configs - #407

Merged
lionello merged 1 commit into
mainfrom
sam/exclude-reserved-config-vars
Jul 28, 2026
Merged

fix(samples): exclude auto-populated Defang vars from detected sample configs#407
lionello merged 1 commit into
mainfrom
sam/exclude-reserved-config-vars

Conversation

@defang-sam

@defang-sam defang-sam Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What

Drop the auto-populated variables COMPOSE_PROJECT_NAME, DEFANG_PROVIDER, and DEFANG_STACK from each sample's detected configs in scripts/prep-samples.js.

Why

prep-samples.js parses every sample's compose.yaml and records the env vars a developer must set as config into static/samples-v2.json (consumed by the sample pages on the website). These three are populated automatically by compose-go/Defang, so listing them as "configs to set" is noise. Notably self-improving-mastra uses ${DEFANG_STACK}/${DEFANG_PROVIDER}, which the script currently surfaces.

How

Added a RESERVED_CONFIG_VARS set and delete those names from each sample's configs before emitting. Covers both env forms (list - VAR, map VAR:) and ${...} interpolation references, since all feed the same configs set. Mirrors the CLI's canonical reservedConfigNames (DefangLabs/defang src/pkg/cli/compose/validation.go).

Verification

Ran the real prep-samples.js against a fixture sample declaring all three reserved vars (bare key, map form, and via ${...}) plus genuine secrets; the emitted configs contained only the genuine secrets. (This repo has no JS test runner for scripts/, so no unit-test harness was added.)

Part of a 3-repo change (also DefangLabs/defang and DefangLabs/portal).

🤖 Generated with Claude Code

… configs

prep-samples.js records the env vars a sample needs as config into samples-v2.json (consumed by the website). COMPOSE_PROJECT_NAME, DEFANG_PROVIDER and DEFANG_STACK are populated automatically by compose-go/Defang, so drop them from each sample's detected configs. Mirrors the CLI's reservedConfigNames (DefangLabs/defang src/pkg/cli/compose/validation.go).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@defang-sam
defang-sam Bot requested a review from a team as a code owner July 28, 2026 21:33
@lionello
lionello merged commit 840f11a into main Jul 28, 2026
5 checks passed
@lionello
lionello deleted the sam/exclude-reserved-config-vars branch July 28, 2026 21:48
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.

1 participant