Skip to content

Commit 6c4895c

Browse files
committed
Fix: Only use template in keep run when --template flag is explicitly provided
The run command was incorrectly using templates when the --template option was not provided. Now it only uses templates when the user explicitly includes the --template flag.
1 parent 3c30587 commit 6c4895c

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

docs/guide/deployment/runtime-injection.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ With Docker Compose, environment variables are automatically passed through when
101101
## Template-Based Injection
102102

103103
```bash
104-
# Generate template from existing secrets
105-
keep template:add prod.env --stage=production
106-
107-
# Use specific template
108-
keep run --vault=ssm --stage=production --template=env/prod.env -- npm start
104+
# Generate template from existing secrets in env/production.env
105+
keep template:add --stage=production
109106

110107
# Auto-discover template (looks for env/{stage}.env)
111108
keep run --vault=ssm --stage=production --template -- npm start
109+
110+
# Use specific template
111+
keep run --vault=ssm --stage=production --template=env/prod.env -- npm start
112112
```
113113

114114
See [Managing Templates](./templates.md) for detailed template documentation.

src/Commands/RunCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ protected function buildEnvironment(string $stage, string $vaultSlug): array
134134
$inheritCurrent = !$this->option('no-inherit');
135135

136136
// Handle template-based injection
137-
// If --template is explicitly provided, use template mode
137+
// Only use template if --template option is explicitly provided
138138
// But only if no filters are specified (filters only work in direct mode)
139139
$hasFilters = $this->option('only') || $this->option('except');
140140

141-
if (!$hasFilters && $this->hasOption('template') && $this->option('template') !== false) {
141+
if (!$hasFilters && $templateOption !== null) {
142142
// If template value is empty string, it means auto-discovery
143143
$templatePath = $templateOption === '' ? null : $templateOption;
144144
return $this->buildFromTemplate($templatePath, $stage, $vaultSlug, $inheritCurrent);

0 commit comments

Comments
 (0)