Skip to content

Commit 2df30a8

Browse files
Alexander Merkleuserid0x0
authored andcommitted
build,add: add support for corporate proxies
Use the Proxy Environment http_proxy/HTTPS_PROXY/NO_PROXY to handle the http request. Signed-off-by: Alexander Merkle <[email protected]>
1 parent 1b5cdd5 commit 2df30a8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

add.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ func getURL(src string, chown *idtools.IDPair, mountpoint, renameTarget string,
141141
}
142142
tlsClientConfig.InsecureSkipVerify = insecureSkipTLSVerify == types.OptionalBoolTrue
143143

144-
tr := &http.Transport{TLSClientConfig: tlsClientConfig}
144+
tr := &http.Transport{
145+
TLSClientConfig: tlsClientConfig,
146+
Proxy: http.ProxyFromEnvironment,
147+
}
145148
httpClient := &http.Client{Transport: tr}
146149
response, err := httpClient.Get(src)
147150
if err != nil {

tests/bud.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7272,6 +7272,15 @@ _EOF
72727272
fi
72737273
}
72747274

7275+
@test "build proxy - ADD URL" {
7276+
_prefetch alpine
7277+
target=alpine-image
7278+
http_proxy=http://127.0.0.1:47 HTTPS_PROXY=http://127.0.0.1:47 \
7279+
run_buildah 125 build $WITH_POLICY_JSON -t alpine-image -f $BUDFILES/add-checksum/Containerfile $BUDFILES/add-checksum
7280+
expect_output --substring "127.0.0.1:47" "connection to fake proxy must fail"
7281+
expect_output --substring "connection refused" "connection to fake proxy must fail"
7282+
}
7283+
72757284
@test "bud-with-mount-bind-from-like-buildkit" {
72767285
skip_if_no_runtime
72777286
skip_if_in_container

0 commit comments

Comments
 (0)