diff --git a/pkg/handlers/embedded_cluster_node_join_command.go b/pkg/handlers/embedded_cluster_node_join_command.go index d27bcabb94..6f38f6079b 100644 --- a/pkg/handlers/embedded_cluster_node_join_command.go +++ b/pkg/handlers/embedded_cluster_node_join_command.go @@ -17,6 +17,12 @@ type GenerateEmbeddedClusterNodeJoinCommandResponse struct { Command []string `json:"command"` } +type Proxy struct { + HTTPProxy string `json:"httpProxy"` + HTTPSProxy string `json:"httpsProxy"` + NoProxy string `json:"noProxy"` +} + type GetEmbeddedClusterNodeJoinCommandResponse struct { ClusterID string `json:"clusterID"` K0sJoinCommand string `json:"k0sJoinCommand"` @@ -27,6 +33,7 @@ type GetEmbeddedClusterNodeJoinCommandResponse struct { EmbeddedClusterVersion string `json:"embeddedClusterVersion"` AirgapRegistryAddress string `json:"airgapRegistryAddress"` IsAirgap bool `json:"isAirgap"` + Proxy *Proxy `json:"proxy,omitempty"` } type GenerateEmbeddedClusterNodeJoinCommandRequest struct { @@ -172,6 +179,18 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht airgapRegistryAddress, _, _ = kotsutil.GetEmbeddedRegistryCreds(clientset) } + httpProxy := util.HTTPProxy() + httpsProxy := util.HTTPSProxy() + noProxy := util.NoProxy() + var proxy *Proxy + if httpProxy != "" || httpsProxy != "" || noProxy != "" { + proxy = &Proxy{ + HTTPProxy: httpProxy, + HTTPSProxy: httpsProxy, + NoProxy: noProxy, + } + } + JSON(w, http.StatusOK, GetEmbeddedClusterNodeJoinCommandResponse{ ClusterID: install.Spec.ClusterID, K0sJoinCommand: k0sJoinCommand, @@ -182,5 +201,6 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht EmbeddedClusterVersion: ecVersion, AirgapRegistryAddress: airgapRegistryAddress, IsAirgap: install.Spec.AirGap, + Proxy: proxy, }) } diff --git a/pkg/util/util.go b/pkg/util/util.go index e0e2048f0d..5b03fce0c6 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -177,6 +177,18 @@ func EmbeddedClusterVersion() string { return os.Getenv("EMBEDDED_CLUSTER_VERSION") } +func HTTPProxy() string { + return os.Getenv("HTTP_PROXY") +} + +func HTTPSProxy() string { + return os.Getenv("HTTPS_PROXY") +} + +func NoProxy() string { + return os.Getenv("NO_PROXY") +} + func GetValueFromMapPath(m interface{}, path []string) interface{} { if len(path) == 0 { return nil