Skip to content

Commit 34c02ec

Browse files
committed
Fix #60: Secrets support in container build args
1 parent 3005a45 commit 34c02ec

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

internal/app/container_manager.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ func NewContainerManager(logger *types.Logger, app *App, containerFile string,
143143
cargs_map[k] = v
144144
}
145145

146+
// Evaluate secrets in the build args
147+
for k, v := range cargs_map {
148+
val, err := app.secretEvalFunc(secretsAllowed, app.AppConfig.Security.DefaultSecretsProvider, v)
149+
if err != nil {
150+
return nil, fmt.Errorf("error evaluating secret for %s: %w", k, err)
151+
}
152+
cargs_map[k] = val
153+
}
154+
146155
m := &ContainerManager{
147156
Logger: logger,
148157
app: app,

tests/run_cli_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ elif [[ -z "$CL_CONTAINER_COMMANDS" ]]; then
216216
CL_CONTAINER_COMMANDS="docker podman"
217217
fi
218218

219+
export PYTHON_VERSION=3.12.4-slim
219220
port_base=9000
220221
for cmd in ${CL_CONTAINER_COMMANDS}; do
221222
http_port=`expr $port_base + 1`
@@ -231,6 +232,7 @@ port = $https_port
231232
app_default_auth_type="none"
232233
[system]
233234
container_command="$cmd"
235+
[secret.env]
234236
EOF
235237
rm -rf metadata run/clace.sock
236238
CL_CONFIG_FILE=config_container.toml GOCOVERDIR=$GOCOVERDIR ../clace server start &

tests/test_containers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tests:
99
container0020: # setup flask dev app
1010
command: ../clace app create --dev --spec python-flask --approve ./flaskapp /cont_flaskdev
1111
container0030: # setup flask prod app
12-
command: ../clace app create --spec python-flask --carg PYTHON_VERSION=3.12.4-slim --copt cpu-shares=1000 --approve ./flaskapp /cont_flaskprod
12+
command: ../clace app create --spec python-flask --carg PYTHON_VERSION='{{secret_from "env" "PYTHON_VERSION"}}' --copt cpu-shares=1000 --approve ./flaskapp /cont_flaskprod
1313
container0031: # invalid python version carg fails
1414
command: ../clace app create --spec python-flask --cvol /tmp:/atmp --cvol /testvol --container-arg PYTHON_VERSION=4invalid-slim --approve ./flaskapp /cont_flaskdev2
1515
container0032: # check curl

0 commit comments

Comments
 (0)