fix: interpolate a task file before it is parsed

A var used in container_limits broke the build, because FileConfigSource
parses the file into an atc.TaskConfig before any interpolation happens, and
'((container_mem_limit))' is not a memory limit. Only fields that are plain
strings survived that first parse.

FileConfigSource can now hand back the file as written, and
InterpolateTemplateConfigSource resolves those bytes and parses once,
instead of parsing, marshalling back and parsing again. For a task file the
interpolation pass now always runs, with the pipeline vars followed by the
credential variables, so a var resolves the same way wherever it appears in
the file.
This commit is contained in:
dualfroz committed 2026-09-13 15:29:51 +02:00
1 parent af4510fc7f
commit 10dad07bcd
4 files changed
+154 -24

No files matched your search

+30
View File
@@ -1185,4 +1185,34 @@ var _ = Describe("TaskStep", func() {
})
})
})
Context("when the plan has a config path whose container_limits use vars", func() {
BeforeEach(func() {
state = exec.NewRunState(noopStepper, vars.StaticVariables{
"cpu-limit": 512,
"mem-limit": "5gb",
})
repo = state.ArtifactRepository()
repo.RegisterArtifact("some-artifact", runtimetest.NewVolume("some-volume"), false)
fakeStreamer.StreamFileReturns(gbytes.BufferWithBytes([]byte(`
platform: some-platform
container_limits:
cpu: ((cpu-limit))
memory: ((mem-limit))
run: {path: ls}
`)), nil)
taskPlan.ConfigPath = "some-artifact/task.yml"
fakePool = new(execfakes.FakePool)
fakePool.FindOrSelectWorkerReturns(nil, errors.New("no worker for you"))
})
It("interpolates the file before it is parsed, so the step gets as far as picking a worker", func() {
Expect(stepErr).To(MatchError(ContainSubstring("no worker for you")))
})
})
})