image build: add --image-pull-{proxy,noproxy}#86
Conversation
Code Review by Qodo
1. Duplicate proxy env entries
|
✅ 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. |
|
Tested in chmeliik#19 (with chmeliik/build-definitions@8fc9d38) |
|
@qodo-code-review
IMO the "last value wins" behavior of exec.Cmd is pretty obvious, but added a comment about it |
pkg/cliwrappers/buildah_test.go
Outdated
| HttpProxy: "http://proxy.example.com:8080", | ||
| NoProxy: "localhost,127.0.0.1", |
There was a problem hiding this comment.
I'm not sure how much this test is testing, probably only the fact that the env vars were set.
There was a problem hiding this comment.
Yeah, that's it. I didn't find any easy way to integration-test it.
One idea was to set those URLs to something that will cause the pull to fail, but then the test would spend 8 minutes retrying
There was a problem hiding this comment.
As an option, we can try to use golang stdlib: net/http/httputil to setup proxy just for test. I think it should be possible to even make sure the proxy got the request.
Regarding waiting time, will DisableRetryer=true help?
There was a problem hiding this comment.
Good call! I didn't know how simple it was to create a tunneling proxy (especially with Claude's help 😄 ). Replaced the two questionable unit tests with an integration test.
| func (e *CliExecutor) Execute(c Cmd) (string, string, int, error) { | ||
| cmd := exec.Command(c.Name, c.Args...) | ||
| cmd.Dir = c.Dir | ||
| cmd.Env = c.Env |
There was a problem hiding this comment.
Is replacing of all env vars intentional?
There was a problem hiding this comment.
The intention is to have the same semantics as exec.Cmd - leaving it nil inherits the parent process env, otherwise replace
mmorhun
left a comment
There was a problem hiding this comment.
The suggestions are optional, so up to you.
Assisted-by: Claude Signed-off-by: Adam Cmiel <acmiel@redhat.com>
Sets the relevant environment variables in the 'buildah pull' environment to support the layer caching proxy [1]. Note that the Konflux buildah task also used to set ALL_PROXY in addition to HTTP_PROXY and HTTPS_PROXY. This has always been useless. ALL_PROXY is not a standard environment variable and the Go libraries used by buildah don't take it into account at all. [1]: https://github.com/konflux-ci/architecture/blob/main/ADR/0047-caching-for-container-build-layers.md Assisted-by: Claude Signed-off-by: Adam Cmiel <acmiel@redhat.com>
Sets the relevant environment variables in the 'buildah pull' environment to support the layer caching proxy 1.
Note that the Konflux buildah task also used to set ALL_PROXY in addition to HTTP_PROXY and HTTPS_PROXY. This has always been useless. ALL_PROXY is not a standard environment variable and the Go libraries used by buildah don't take it into account at all.