Skip to content

Commit

Permalink
Support intepolation for env of services (nektos#47)
Browse files Browse the repository at this point in the history
Reviewed-on: https://gitea.com/gitea/act/pulls/47
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
  • Loading branch information
Zettat123 authored and GuessWhoSamFoo committed Aug 6, 2023
1 parent fe6bb02 commit 924b312
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/runner/run_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,13 @@ func (rc *RunContext) startJobContainer() common.Executor {

// add service containers
for name, spec := range rc.Run.Job().Services {
mergedEnv := envList
interpolatedEnvs := make(map[string]string, len(spec.Env))
for k, v := range spec.Env {
mergedEnv = append(mergedEnv, fmt.Sprintf("%s=%s", k, v))
interpolatedEnvs[k] = rc.ExprEval.Interpolate(ctx, v)
}
envs := make([]string, 0, len(interpolatedEnvs))
for k, v := range interpolatedEnvs {
envs = append(envs, fmt.Sprintf("%s=%s", k, v))
}
serviceContainerName := createContainerName(rc.jobContainerName(), name)
c := container.NewContainer(&container.NewContainerInput{
Expand All @@ -274,7 +278,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
Image: spec.Image,
Username: username,
Password: password,
Env: mergedEnv,
Env: envs,
Mounts: map[string]string{
// TODO merge volumes
name: ext.ToContainerPath(rc.Config.Workdir),
Expand Down

0 comments on commit 924b312

Please sign in to comment.