Skip to content

Commit 865f125

Browse files
authored
BREAKING: Simplify export template variable naming (#116)
Remove __ARG__ suffix from command-line argument template variables to create cleaner, more consistent naming across environment variables and arguments. BREAKING CHANGES: - Template variables for command-line arguments changed from MCPD__{SERVER}__ARG__{VAR} to MCPD__{SERVER}__{VAR} - Both environment variables and command-line arguments now use the same naming scheme: MCPD__{SERVER_NAME}__{VARIABLE_NAME} Migration: - Users with existing CI/CD pipelines using exported variables must rename their environment variables to remove the __ARG__ suffix if they re-create files from export - Example: MCPD__SERVER__ARG__TOKEN → MCPD__SERVER__TOKEN Other improvements: - Consolidated template generation logic to use single source of truth - Added documentation for variable name collision handling - Updated command help text to reflect unified naming scheme
1 parent 7fd7f50 commit 865f125

File tree

14 files changed

+127
-101
lines changed

14 files changed

+127
-101
lines changed

cmd/config/export/export.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func (c *Cmd) longDescription() string {
7575
"execution context file (e.g. `~/.config/mcpd/secrets.dev.toml`), the export command outputs two files:\n\n" +
7676
"Environment Contract:\n\n" +
7777
"Lists all required and configured environment variables as secure, namespaced placeholders:\n\n" +
78-
"`MCPD__{SERVER_NAME}__{ENV_VAR}` - Creates placeholders for command line arguments to be populated with env vars\n\n" +
79-
"`MCPD__{SERVER_NAME}__ARG_{ARG_NAME}` - This file is intended for the platform operator or CI/CD system\n\n" +
78+
"`MCPD__{SERVER_NAME}__{VAR_NAME}` - Creates placeholders for both environment variables and command line arguments to be populated with env vars\n\n" +
79+
"This file is intended for the platform operator or CI/CD system\n\n" +
8080
"Portable Execution Context:\n\n" +
8181
"- A new secrets `.toml` file that defines sanitized runtime args and env sections for each server using the " +
8282
"placeholders aligned with the environment contract\n" +

cmd/config/export/testdata/basic_export/context.test.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[servers]
22
[servers.test-server]
3-
args = ["--verbose", "--debug", "--config=${MCPD__TEST_SERVER__ARG__CONFIG}", "--port=${MCPD__TEST_SERVER__ARG__PORT}", "--extra=${MCPD__TEST_SERVER__ARG__EXTRA}"]
3+
args = ["--verbose", "--debug", "--config=${MCPD__TEST_SERVER__CONFIG}", "--port=${MCPD__TEST_SERVER__PORT}", "--extra=${MCPD__TEST_SERVER__EXTRA}"]
44
[servers.test-server.env]
55
API_KEY = "${MCPD__TEST_SERVER__API_KEY}"
66
EXTRA_VAR = "${MCPD__TEST_SERVER__EXTRA_VAR}"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MCPD__TEST_SERVER__API_KEY=${MCPD__TEST_SERVER__API_KEY}
2-
MCPD__TEST_SERVER__ARG__CONFIG=${MCPD__TEST_SERVER__ARG__CONFIG}
3-
MCPD__TEST_SERVER__ARG__EXTRA=${MCPD__TEST_SERVER__ARG__EXTRA}
4-
MCPD__TEST_SERVER__ARG__PORT=${MCPD__TEST_SERVER__ARG__PORT}
2+
MCPD__TEST_SERVER__CONFIG=${MCPD__TEST_SERVER__CONFIG}
3+
MCPD__TEST_SERVER__EXTRA=${MCPD__TEST_SERVER__EXTRA}
54
MCPD__TEST_SERVER__EXTRA_VAR=${MCPD__TEST_SERVER__EXTRA_VAR}
5+
MCPD__TEST_SERVER__PORT=${MCPD__TEST_SERVER__PORT}
66
MCPD__TEST_SERVER__SECRET=${MCPD__TEST_SERVER__SECRET}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[servers]
22
[servers.github-server]
3-
args = ["--org=${MCPD__GITHUB_SERVER__ARG__ORG}", "--api-version=${MCPD__GITHUB_SERVER__ARG__API_VERSION}"]
3+
args = ["--org=${MCPD__GITHUB_SERVER__ORG}", "--api-version=${MCPD__GITHUB_SERVER__API_VERSION}"]
44
[servers.github-server.env]
55
DEBUG = "${MCPD__GITHUB_SERVER__DEBUG}"
66
GITHUB_TOKEN = "${MCPD__GITHUB_SERVER__GITHUB_TOKEN}"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MCPD__GITHUB_SERVER__ARG__API_VERSION=${MCPD__GITHUB_SERVER__ARG__API_VERSION}
2-
MCPD__GITHUB_SERVER__ARG__ORG=${MCPD__GITHUB_SERVER__ARG__ORG}
1+
MCPD__GITHUB_SERVER__API_VERSION=${MCPD__GITHUB_SERVER__API_VERSION}
32
MCPD__GITHUB_SERVER__DEBUG=${MCPD__GITHUB_SERVER__DEBUG}
4-
MCPD__GITHUB_SERVER__GITHUB_TOKEN=${MCPD__GITHUB_SERVER__GITHUB_TOKEN}
3+
MCPD__GITHUB_SERVER__GITHUB_TOKEN=${MCPD__GITHUB_SERVER__GITHUB_TOKEN}
4+
MCPD__GITHUB_SERVER__ORG=${MCPD__GITHUB_SERVER__ORG}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[servers]
22
[servers.minimal-server]
3-
args = ["--required-arg=${MCPD__MINIMAL_SERVER__ARG__REQUIRED_ARG}"]
3+
args = ["--required-arg=${MCPD__MINIMAL_SERVER__REQUIRED_ARG}"]
44
[servers.minimal-server.env]
55
REQUIRED_VAR = "${MCPD__MINIMAL_SERVER__REQUIRED_VAR}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MCPD__MINIMAL_SERVER__ARG__REQUIRED_ARG=${MCPD__MINIMAL_SERVER__ARG__REQUIRED_ARG}
1+
MCPD__MINIMAL_SERVER__REQUIRED_ARG=${MCPD__MINIMAL_SERVER__REQUIRED_ARG}
22
MCPD__MINIMAL_SERVER__REQUIRED_VAR=${MCPD__MINIMAL_SERVER__REQUIRED_VAR}

cmd/config/export/testdata/multiple_servers/context.test.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[servers]
22
[servers.server-a]
3-
args = ["--token=${MCPD__SERVER_A__ARG__TOKEN}", "--port=${MCPD__SERVER_A__ARG__PORT}"]
3+
args = ["--token=${MCPD__SERVER_A__TOKEN}", "--port=${MCPD__SERVER_A__PORT}"]
44
[servers.server-b]
55
[servers.server-b.env]
66
DATABASE_URL = "${MCPD__SERVER_B__DATABASE_URL}"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MCPD__SERVER_A__ARG__PORT=${MCPD__SERVER_A__ARG__PORT}
2-
MCPD__SERVER_A__ARG__TOKEN=${MCPD__SERVER_A__ARG__TOKEN}
1+
MCPD__SERVER_A__PORT=${MCPD__SERVER_A__PORT}
2+
MCPD__SERVER_A__TOKEN=${MCPD__SERVER_A__TOKEN}
33
MCPD__SERVER_B__DATABASE_URL=${MCPD__SERVER_B__DATABASE_URL}
44
MCPD__SERVER_B__DEBUG_MODE=${MCPD__SERVER_B__DEBUG_MODE}

docs/configuration.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,34 @@ Options:
6262
!!! warning "Setting Log Path"
6363
Log entries will be discarded by default, unless a log path is configured.
6464
Output intended for the terminal is still emitted.
65+
66+
---
67+
68+
## Configuration Export
69+
70+
The `mcpd config export` command generates portable configuration files for deployment across different environments. It creates template variables using the naming pattern `MCPD__{SERVER_NAME}__{VARIABLE_NAME}`.
71+
72+
### Template Variable Generation
73+
74+
Environment variables and command-line arguments are both converted to template variables using the same naming scheme:
75+
76+
- Environment variable`DATABASE_URL` becomes `MCPD__{SERVER_NAME}__DATABASE_URL`
77+
- Command-line argument `--database-url` becomes `MCPD__{SERVER_NAME}__DATABASE_URL`
78+
79+
### Variable Name Collisions
80+
81+
!!! danger "Naming Collisions"
82+
If a server has both an environment variable and a command-line argument that normalize to the same name (e.g., `DATABASE_URL` and `--database-url`), they will generate the same template variable name.
83+
84+
In most cases, this is intentional, the same configuration value is being used in different ways. The collision results in a single template variable that can be used for both the environment variable and command-line argument.
85+
86+
#### Example collision
87+
88+
```toml
89+
[[servers]]
90+
name = "example"
91+
required_env = ["DATABASE_URL"]
92+
required_args = ["--database-url"]
93+
```
94+
95+
Both will use the template variable `MCPD__EXAMPLE__DATABASE_URL` in the generated files.

0 commit comments

Comments
 (0)