Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return the entire installation spec object in a EC join struct #4911

Merged
merged 4 commits into from
Sep 21, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 14 additions & 45 deletions pkg/handlers/embedded_cluster_node_join_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ type GenerateEmbeddedClusterNodeJoinCommandResponse struct {
}

type GetEmbeddedClusterNodeJoinCommandResponse struct {
ClusterID string `json:"clusterID"`
K0sJoinCommand string `json:"k0sJoinCommand"`
K0sToken string `json:"k0sToken"`
K0sUnsupportedOverrides string `json:"k0sUnsupportedOverrides"`
EndUserK0sConfigOverrides string `json:"endUserK0sConfigOverrides"`
MetricsBaseURL string `json:"metricsBaseURL"`
EmbeddedClusterVersion string `json:"embeddedClusterVersion"`
AirgapRegistryAddress string `json:"airgapRegistryAddress"`
IsAirgap bool `json:"isAirgap"`
Proxy *ecv1beta1.ProxySpec `json:"proxy,omitempty"`
Network *ecv1beta1.NetworkSpec `json:"network,omitempty"`
LocalArtifactMirrorPort int `json:"localArtifactMirrorPort,omitempty"`
ClusterID string `json:"clusterID"`
K0sJoinCommand string `json:"k0sJoinCommand"`
K0sToken string `json:"k0sToken"`
EmbeddedClusterVersion string `json:"embeddedClusterVersion"`
AirgapRegistryAddress string `json:"airgapRegistryAddress"`
Spec ecv1beta1.InstallationSpec `json:"installationSpec,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not call it InstallationSpec

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean sure
it doesn't change anything, it's already encoded as 'installationSpec' 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated now

}

type GenerateEmbeddedClusterNodeJoinCommandRequest struct {
Expand Down Expand Up @@ -158,11 +152,9 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
return
}

// extract the configuration overrides from the installation object
endUserK0sConfigOverrides := install.Spec.EndUserK0sConfigOverrides
var k0sUnsupportedOverrides, ecVersion string
// extract the version from the installation object for backwards compatibility
var ecVersion string
if install.Spec.Config != nil {
k0sUnsupportedOverrides = install.Spec.Config.UnsupportedOverrides.K0s
ecVersion = install.Spec.Config.Version
}

Expand All @@ -177,35 +169,12 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
airgapRegistryAddress, _, _ = kotsutil.GetEmbeddedRegistryCreds(clientset)
}

httpProxy := util.HTTPProxy()
httpsProxy := util.HTTPSProxy()
noProxy := util.NoProxy()
var proxy *ecv1beta1.ProxySpec
if httpProxy != "" || httpsProxy != "" || noProxy != "" {
proxy = &ecv1beta1.ProxySpec{
HTTPProxy: httpProxy,
HTTPSProxy: httpsProxy,
NoProxy: noProxy,
}
}

localArtifactMirrorPort := 0
if install.Spec.LocalArtifactMirror != nil {
localArtifactMirrorPort = install.Spec.LocalArtifactMirror.Port
}

JSON(w, http.StatusOK, GetEmbeddedClusterNodeJoinCommandResponse{
ClusterID: install.Spec.ClusterID,
K0sJoinCommand: k0sJoinCommand,
K0sToken: k0sToken,
K0sUnsupportedOverrides: k0sUnsupportedOverrides,
EndUserK0sConfigOverrides: endUserK0sConfigOverrides,
MetricsBaseURL: install.Spec.MetricsBaseURL,
EmbeddedClusterVersion: ecVersion,
AirgapRegistryAddress: airgapRegistryAddress,
IsAirgap: install.Spec.AirGap,
Proxy: proxy,
Network: install.Spec.Network,
LocalArtifactMirrorPort: localArtifactMirrorPort,
ClusterID: install.Spec.ClusterID,
K0sJoinCommand: k0sJoinCommand,
K0sToken: k0sToken,
EmbeddedClusterVersion: ecVersion,
AirgapRegistryAddress: airgapRegistryAddress,
Spec: install.Spec,
})
}
Loading