prefetch: allow outputting multiple env files#87
Conversation
Code Review by Qodo
1.
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
96971e6 to
9498604
Compare
|
@konflux-ci/prefetch @slimreaper35 PTAL if the plan makes sense |
| Name: "env-file", | ||
| TypeKind: reflect.String, | ||
| TypeKind: reflect.Slice, |
There was a problem hiding this comment.
nitpick: Maybe the name could be --env-files / KBC_PD_ENV_FILES now, but that would require a change in the environment variable in the task.
There was a problem hiding this comment.
Yeah, I wanted to avoid breaking changes, but it's probably OK to do them at this point. I'm fairly sure e2e tests will catch this when build-definitions gets the hermeto image update PR
The integration tests for the prefetch command run in quay.io/konflux-ci/hermeto:latest and mount the compiled kbc binary to /usr/bin/konflux-build-cli. But the hermeto image already installs kbc to /usr/local/bin/konflux-build-cli. This path takes precedence over /usr/bin, causing the tests to run against the preinstalled binary rather than the one we actually want to test. Fix by executing the kbc binary by its full path instead of executing it only by name. Signed-off-by: Adam Cmiel <acmiel@redhat.com>
In a not-yet-released (as of making this commit) buildah version, we
will get the ability to set build-time environment variables without
having to modify the Containerfile.
This will be done via a combination of --secret and --mount:
--secret id=PIP_FIND_LINKS,src=workdir/prefetch-env/PIP_FIND_LINKS
--mount type=secret,id=PIP_FIND_LINKS,env=PIP_FIND_LINKS
This solution won't be practical with just a prefetch.env file. To find
the names and values of variables to set, the 'image build' command
would have to parse an env file, which can contain shell-quoted strings.
Make it possible to output both a prefetch.env and a prefetch-env.json
(or any other arbitrary file names) at the same time. Hermeto will
select the correct format based on the file extension.
Signed-off-by: Adam Cmiel <acmiel@redhat.com>
For consistency with other kbc flags that accept multiple values, use plural. Note that this is a breaking change, but since we currently only have one user (the prefetch-dependencies Tekton task), that should be OK Signed-off-by: Adam Cmiel <acmiel@redhat.com>
9498604 to
35f585f
Compare
|
/retest |
The plan is to immediately follow up with a PR that makes the Konflux prefetch task return
cachi2.env,prefetch.envandprefetch-env.json(currently only outputscachi2.env).Prefetch support in the build task will be implemented as follows:
<prefetch-dir>/prefetch-env.jsonexists andbuildah version>= (not yet released), inject env vars without modifying the containerfile (described more in the commit message)<prefetch-dir>/prefetch.envor<prefetch-dir>/cachi2.envexists, modify the containerfile to source it in each RUN instruction (cachi2.envfallback needed in case the build task is used with an older version of the prefetch task).envfile at/cachi2/cachi2.env. It is possible that some users use the existence of the file to decide if they should do some prefetch-specific things. To be investigated.