Skip to content

Commit

Permalink
expose proxy for embedded cluster (#4664)
Browse files Browse the repository at this point in the history
* expose proxy for embedded cluster
  • Loading branch information
jdewinne authored Jun 6, 2024
1 parent bb34dfd commit a4b8f39
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/handlers/embedded_cluster_node_join_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -182,5 +201,6 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
EmbeddedClusterVersion: ecVersion,
AirgapRegistryAddress: airgapRegistryAddress,
IsAirgap: install.Spec.AirGap,
Proxy: proxy,
})
}
12 changes: 12 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4b8f39

Please sign in to comment.