mirror of
https://github.com/containers/podman.git
synced 2025-12-01 18:49:18 +08:00
remote: allow --http-proxy for remote clients
The remote client should be allowed to specify if the container should be run with the proxy env vars. It will still use the proxy vars from the server process and not the client. This makes podman-remote more consistent with the local version and easier to use in environments where a proxy is required. Fixes #16520 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@@ -299,7 +299,7 @@ var _ = Describe("Podman build", func() {
|
||||
Expect(session.OutputToString()).To(ContainSubstring("hello"))
|
||||
})
|
||||
|
||||
It("podman build --http_proxy flag", func() {
|
||||
It("podman build http proxy test", func() {
|
||||
if env, found := os.LookupEnv("http_proxy"); found {
|
||||
defer os.Setenv("http_proxy", env)
|
||||
} else {
|
||||
@@ -309,6 +309,9 @@ var _ = Describe("Podman build", func() {
|
||||
if IsRemote() {
|
||||
podmanTest.StopRemoteService()
|
||||
podmanTest.StartRemoteService()
|
||||
// set proxy env again so it will only effect the client
|
||||
// the remote client should still use the proxy that was set for the server
|
||||
os.Setenv("http_proxy", "127.0.0.2")
|
||||
}
|
||||
podmanTest.AddImageToRWStore(ALPINE)
|
||||
dockerfile := fmt.Sprintf(`FROM %s
|
||||
@@ -317,10 +320,17 @@ RUN printenv http_proxy`, ALPINE)
|
||||
dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile")
|
||||
err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
session := podmanTest.Podman([]string{"build", "--pull-never", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir})
|
||||
// --http-proxy should be true by default so we do not set it
|
||||
session := podmanTest.Podman([]string{"build", "--pull-never", "--file", dockerfilePath, podmanTest.TempDir})
|
||||
session.Wait(120)
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4"))
|
||||
|
||||
// this tries to use the cache so we explicitly disable it
|
||||
session = podmanTest.Podman([]string{"build", "--no-cache", "--pull-never", "--http-proxy=false", "--file", dockerfilePath, podmanTest.TempDir})
|
||||
session.Wait(120)
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring(`Error: building at STEP "RUN printenv http_proxy"`))
|
||||
})
|
||||
|
||||
It("podman build relay exit code to process", func() {
|
||||
|
||||
@@ -130,6 +130,9 @@ ENV hello=world
|
||||
if IsRemote() {
|
||||
podmanTest.StopRemoteService()
|
||||
podmanTest.StartRemoteService()
|
||||
// set proxy env again so it will only effect the client
|
||||
// the remote client should still use the proxy that was set for the server
|
||||
os.Setenv("http_proxy", "127.0.0.2")
|
||||
}
|
||||
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "http_proxy"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
||||
@@ -20,7 +20,7 @@ RUN echo $rand_content > /$rand_filename
|
||||
EOF
|
||||
|
||||
# The 'apk' command can take a long time to fetch files; bump timeout
|
||||
PODMAN_TIMEOUT=240 run_podman build -t build_test --format=docker --http-proxy $tmpdir
|
||||
PODMAN_TIMEOUT=240 run_podman build -t build_test --format=docker $tmpdir
|
||||
is "$output" ".*COMMIT" "COMMIT seen in log"
|
||||
|
||||
run_podman run --rm build_test cat /$rand_filename
|
||||
|
||||
Reference in New Issue
Block a user