Skip to content

Commit 373a414

Browse files
authored
Pass-through PROXY environment to Replicated SDK deployment (#4862)
1 parent fa660c6 commit 373a414

File tree

3 files changed

+87
-9
lines changed

3 files changed

+87
-9
lines changed

pkg/rewrite/rewrite.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func Rewrite(rewriteOptions RewriteOptions) error {
111111
IsAirgap: rewriteOptions.IsAirgap,
112112
KotsadmID: k8sutil.GetKotsadmID(clientset),
113113
AppID: rewriteOptions.AppID,
114+
HTTPProxyEnvValue: rewriteOptions.HTTPProxyEnvValue,
115+
HTTPSProxyEnvValue: rewriteOptions.HTTPSProxyEnvValue,
116+
NoProxyEnvValue: rewriteOptions.NoProxyEnvValue,
114117
}
115118
if err = upstream.WriteUpstream(u, writeUpstreamOptions); err != nil {
116119
log.FinishSpinnerWithError()

pkg/upstream/helm.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,24 @@ func buildReplicatedValues(u *types.Upstream, options types.WriteOptions) (map[s
278278
replicatedValues["license"] = string(MustMarshalLicense(u.License))
279279
}
280280

281+
replicatedValues["extraEnv"] = []struct {
282+
Name string `yaml:"name"`
283+
Value string `yaml:"value"`
284+
}{
285+
{
286+
Name: "HTTP_PROXY",
287+
Value: options.HTTPProxyEnvValue,
288+
},
289+
{
290+
Name: "HTTPS_PROXY",
291+
Value: options.HTTPSProxyEnvValue,
292+
},
293+
{
294+
Name: "NO_PROXY",
295+
Value: options.NoProxyEnvValue,
296+
},
297+
}
298+
281299
return replicatedValues, nil
282300
}
283301

pkg/upstream/helm_test.go

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ func Test_configureChart(t *testing.T) {
2121
type Test struct {
2222
name string
2323
isAirgap bool
24+
httpProxy string
25+
httpsProxy string
26+
noProxy string
2427
chartContent map[string]string
2528
want map[string]string
2629
wantErr bool
@@ -288,8 +291,11 @@ another: value
288291
// Generate dynamic tests using the supported replicated chart names
289292
for _, chartName := range testReplicatedChartNames {
290293
tests = append(tests, Test{
291-
name: "online - a standalone replicated chart",
292-
isAirgap: false,
294+
name: "online - a standalone replicated chart",
295+
isAirgap: false,
296+
httpProxy: "http://10.1.0.1:3128",
297+
httpsProxy: "https://10.1.0.1:3129",
298+
noProxy: "localhost,127.0.0.1",
293299
chartContent: map[string]string{
294300
"replicated/Chart.yaml": fmt.Sprintf(`apiVersion: v1
295301
name: %s
@@ -376,6 +382,13 @@ some: value
376382
# and this comment as well
377383
378384
appID: app-id
385+
extraEnv:
386+
- name: HTTP_PROXY
387+
value: http://10.1.0.1:3128
388+
- name: HTTPS_PROXY
389+
value: https://10.1.0.1:3129
390+
- name: NO_PROXY
391+
value: localhost,127.0.0.1
379392
isAirgap: false
380393
replicatedID: kotsadm-id
381394
`,
@@ -459,6 +472,13 @@ some: value
459472
# and this comment as well
460473
461474
appID: app-id
475+
extraEnv:
476+
- name: HTTP_PROXY
477+
value: ""
478+
- name: HTTPS_PROXY
479+
value: ""
480+
- name: NO_PROXY
481+
value: ""
462482
isAirgap: true
463483
replicatedID: kotsadm-id
464484
global:
@@ -482,8 +502,11 @@ global:
482502
})
483503

484504
tests = append(tests, Test{
485-
name: "online - a guestbook chart with the replicated subchart",
486-
isAirgap: false,
505+
name: "online - a guestbook chart with the replicated subchart",
506+
isAirgap: false,
507+
httpProxy: "http://10.1.0.1:3128",
508+
httpsProxy: "https://10.1.0.1:3129",
509+
noProxy: "localhost,127.0.0.1",
487510
chartContent: map[string]string{
488511
"guestbook/Chart.yaml": `apiVersion: v2
489512
name: guestbook
@@ -569,6 +592,13 @@ image:
569592
- service/replicated
570593
versionLabel: 1.0.0
571594
appID: app-id
595+
extraEnv:
596+
- name: HTTP_PROXY
597+
value: http://10.1.0.1:3128
598+
- name: HTTPS_PROXY
599+
value: https://10.1.0.1:3129
600+
- name: NO_PROXY
601+
value: localhost,127.0.0.1
572602
isAirgap: false
573603
replicatedID: kotsadm-id
574604
global:
@@ -675,6 +705,13 @@ image:
675705
- service/replicated
676706
versionLabel: 1.0.0
677707
appID: app-id
708+
extraEnv:
709+
- name: HTTP_PROXY
710+
value: ""
711+
- name: HTTPS_PROXY
712+
value: ""
713+
- name: NO_PROXY
714+
value: ""
678715
isAirgap: true
679716
license: |
680717
apiVersion: kots.io/v1beta1
@@ -733,8 +770,11 @@ some: value
733770
})
734771

735772
tests = append(tests, Test{
736-
name: "online - a redis chart with the replicated subchart and predefined replicated and global values",
737-
isAirgap: false,
773+
name: "online - a redis chart with the replicated subchart and predefined replicated and global values",
774+
isAirgap: false,
775+
httpProxy: "http://10.1.0.1:3128",
776+
httpsProxy: "https://10.1.0.1:3129",
777+
noProxy: "localhost,127.0.0.1",
738778
chartContent: map[string]string{
739779
"redis/Chart.yaml": `apiVersion: v1
740780
name: redis
@@ -848,6 +888,13 @@ global:
848888
- service/replicated
849889
versionLabel: 1.0.0
850890
appID: app-id
891+
extraEnv:
892+
- name: HTTP_PROXY
893+
value: http://10.1.0.1:3128
894+
- name: HTTPS_PROXY
895+
value: https://10.1.0.1:3129
896+
- name: NO_PROXY
897+
value: localhost,127.0.0.1
851898
isAirgap: false
852899
replicatedID: kotsadm-id
853900
`, chartName),
@@ -965,6 +1012,13 @@ global:
9651012
- service/replicated
9661013
versionLabel: 1.0.0
9671014
appID: app-id
1015+
extraEnv:
1016+
- name: HTTP_PROXY
1017+
value: ""
1018+
- name: HTTPS_PROXY
1019+
value: ""
1020+
- name: NO_PROXY
1021+
value: ""
9681022
isAirgap: true
9691023
license: |
9701024
apiVersion: kots.io/v1beta1
@@ -1244,9 +1298,12 @@ some: value
12441298
}
12451299

12461300
writeOptions := types.WriteOptions{
1247-
KotsadmID: "kotsadm-id",
1248-
AppID: "app-id",
1249-
IsAirgap: tt.isAirgap,
1301+
KotsadmID: "kotsadm-id",
1302+
AppID: "app-id",
1303+
IsAirgap: tt.isAirgap,
1304+
HTTPProxyEnvValue: tt.httpProxy,
1305+
HTTPSProxyEnvValue: tt.httpsProxy,
1306+
NoProxyEnvValue: tt.noProxy,
12501307
}
12511308

12521309
got, err := configureChart(chartBytes, upstream, writeOptions)

0 commit comments

Comments
 (0)