Skip to content

Commit a4b8f39

Browse files
authored
expose proxy for embedded cluster (#4664)
* expose proxy for embedded cluster
1 parent bb34dfd commit a4b8f39

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

pkg/handlers/embedded_cluster_node_join_command.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ type GenerateEmbeddedClusterNodeJoinCommandResponse struct {
1717
Command []string `json:"command"`
1818
}
1919

20+
type Proxy struct {
21+
HTTPProxy string `json:"httpProxy"`
22+
HTTPSProxy string `json:"httpsProxy"`
23+
NoProxy string `json:"noProxy"`
24+
}
25+
2026
type GetEmbeddedClusterNodeJoinCommandResponse struct {
2127
ClusterID string `json:"clusterID"`
2228
K0sJoinCommand string `json:"k0sJoinCommand"`
@@ -27,6 +33,7 @@ type GetEmbeddedClusterNodeJoinCommandResponse struct {
2733
EmbeddedClusterVersion string `json:"embeddedClusterVersion"`
2834
AirgapRegistryAddress string `json:"airgapRegistryAddress"`
2935
IsAirgap bool `json:"isAirgap"`
36+
Proxy *Proxy `json:"proxy,omitempty"`
3037
}
3138

3239
type GenerateEmbeddedClusterNodeJoinCommandRequest struct {
@@ -172,6 +179,18 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
172179
airgapRegistryAddress, _, _ = kotsutil.GetEmbeddedRegistryCreds(clientset)
173180
}
174181

182+
httpProxy := util.HTTPProxy()
183+
httpsProxy := util.HTTPSProxy()
184+
noProxy := util.NoProxy()
185+
var proxy *Proxy
186+
if httpProxy != "" || httpsProxy != "" || noProxy != "" {
187+
proxy = &Proxy{
188+
HTTPProxy: httpProxy,
189+
HTTPSProxy: httpsProxy,
190+
NoProxy: noProxy,
191+
}
192+
}
193+
175194
JSON(w, http.StatusOK, GetEmbeddedClusterNodeJoinCommandResponse{
176195
ClusterID: install.Spec.ClusterID,
177196
K0sJoinCommand: k0sJoinCommand,
@@ -182,5 +201,6 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
182201
EmbeddedClusterVersion: ecVersion,
183202
AirgapRegistryAddress: airgapRegistryAddress,
184203
IsAirgap: install.Spec.AirGap,
204+
Proxy: proxy,
185205
})
186206
}

pkg/util/util.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ func EmbeddedClusterVersion() string {
177177
return os.Getenv("EMBEDDED_CLUSTER_VERSION")
178178
}
179179

180+
func HTTPProxy() string {
181+
return os.Getenv("HTTP_PROXY")
182+
}
183+
184+
func HTTPSProxy() string {
185+
return os.Getenv("HTTPS_PROXY")
186+
}
187+
188+
func NoProxy() string {
189+
return os.Getenv("NO_PROXY")
190+
}
191+
180192
func GetValueFromMapPath(m interface{}, path []string) interface{} {
181193
if len(path) == 0 {
182194
return nil

0 commit comments

Comments
 (0)