diff --git a/pkg/asset/agent/common.go b/pkg/asset/agent/common.go index 5a42406a08e..578a9432473 100644 --- a/pkg/asset/agent/common.go +++ b/pkg/asset/agent/common.go @@ -12,6 +12,7 @@ import ( ) const ( + // ExternalPlatformNameOci is the name of the external platform for OCP. ExternalPlatformNameOci = "oci" ) diff --git a/pkg/asset/imagebased/configimage/clusterconfiguration.go b/pkg/asset/imagebased/configimage/clusterconfiguration.go index 54f57ef86bc..b54581dbb94 100644 --- a/pkg/asset/imagebased/configimage/clusterconfiguration.go +++ b/pkg/asset/imagebased/configimage/clusterconfiguration.go @@ -90,6 +90,12 @@ func (cc *ClusterConfiguration) Generate(_ context.Context, dependencies asset.P if installConfig.Config == nil || imageBasedConfig.Config == nil { return cc.finish() } + if imageBasedConfig.Config.ClusterID != "" { + clusterID.UUID = imageBasedConfig.Config.ClusterID + } + if imageBasedConfig.Config.InfraID != "" { + clusterID.InfraID = imageBasedConfig.Config.InfraID + } cc.Config = &imagebased.SeedReconfiguration{ APIVersion: imagebased.SeedReconfigurationVersion, diff --git a/pkg/asset/imagebased/configimage/clusterconfiguration_test.go b/pkg/asset/imagebased/configimage/clusterconfiguration_test.go index 4fa84bee18a..678721270d7 100644 --- a/pkg/asset/imagebased/configimage/clusterconfiguration_test.go +++ b/pkg/asset/imagebased/configimage/clusterconfiguration_test.go @@ -64,6 +64,22 @@ func TestClusterConfiguration_Generate(t *testing.T) { expectedConfig: clusterConfiguration().build().Config, }, + { + name: "valid configuration with cluster and infra ID", + dependencies: []asset.Asset{ + clusterID(), + kubeadminPassword(), + lbCertKey(), + localhostCertKey(), + serviceNetworkCertKey(), + adminKubeConfigCertKey(), + ingressCertKey(), + installConfig().build(), + imageBasedConfigWithSetClusterID("some-id", "some-infra-id"), + }, + + expectedConfig: clusterConfigurationWithProvidedIDs("some-id", "some-infra-id").build().Config, + }, { name: "valid configuration with proxy", dependencies: []asset.Asset{ @@ -340,6 +356,13 @@ func clusterConfiguration() *ClusterConfigurationBuilder { return ccb } +func clusterConfigurationWithProvidedIDs(clusterID string, infraID string) *ClusterConfigurationBuilder { + ccb := clusterConfiguration() + ccb.ClusterConfiguration.Config.ClusterID = clusterID + ccb.ClusterConfiguration.Config.InfraID = infraID + return ccb +} + func clusterID() *ClusterID { return &ClusterID{ installconfig.ClusterID{ diff --git a/pkg/asset/imagebased/configimage/imagebased_config.go b/pkg/asset/imagebased/configimage/imagebased_config.go index 5bcc2a1845d..bf8182317ae 100644 --- a/pkg/asset/imagebased/configimage/imagebased_config.go +++ b/pkg/asset/imagebased/configimage/imagebased_config.go @@ -154,7 +154,6 @@ func (i *ImageBasedConfig) validateImageBasedConfig() field.ErrorList { func (i *ImageBasedConfig) validateNetworkConfig() field.ErrorList { var allErrs field.ErrorList - fmt.Sprintf("NetworkConfig: %s", i.Config.NetworkConfig) // empty NetworkConfig is fine if i.Config.NetworkConfig == nil || i.Config.NetworkConfig.String() == "" { return nil diff --git a/pkg/asset/imagebased/configimage/installconfig.go b/pkg/asset/imagebased/configimage/installconfig.go index 9fcbe96f7da..b2079c8bbe5 100644 --- a/pkg/asset/imagebased/configimage/installconfig.go +++ b/pkg/asset/imagebased/configimage/installconfig.go @@ -50,9 +50,8 @@ func (i *InstallConfig) Generate(_ context.Context, parents asset.Parents) error return nil } -// adding custom loadFromFile method to load the install-config.yaml file -// as default one adds many default values that are not needed for image-based install config and can break our logic -// such as machine network for example +// loadFromFile method to load the install-config.yaml file. +// Default one adds many default values that are not needed for image-based install config and can break our logic such as machine network for example. func (i *InstallConfig) loadFromFile(f asset.FileFetcher) (found bool, err error) { file, err := f.FetchByName(InstallConfigFilename) if err != nil { diff --git a/pkg/asset/imagebased/configimage/util_test.go b/pkg/asset/imagebased/configimage/util_test.go index d087d9103b8..9f1acaf7f23 100644 --- a/pkg/asset/imagebased/configimage/util_test.go +++ b/pkg/asset/imagebased/configimage/util_test.go @@ -111,6 +111,13 @@ func imageBasedConfig() *ImageBasedConfig { return ibConfig } +func imageBasedConfigWithSetClusterID(clusterID string, infraID string) *ImageBasedConfig { + ibConfig := imageBasedConfig() + ibConfig.Config.ClusterID = clusterID + ibConfig.Config.InfraID = infraID + return ibConfig +} + func unmarshalJSON(b []byte) []byte { output, err := yaml.JSONToYAML(b) if err != nil { diff --git a/pkg/types/imagebased/imagebased_config_types.go b/pkg/types/imagebased/imagebased_config_types.go index 765afa48fb5..64cedcd1129 100644 --- a/pkg/types/imagebased/imagebased_config_types.go +++ b/pkg/types/imagebased/imagebased_config_types.go @@ -33,6 +33,16 @@ type Config struct { // ReleaseRegistry is the container registry used to host the release image of the seed cluster. // +optional ReleaseRegistry string `json:"releaseRegistry,omitempty"` + + // ClusterID is the desired cluster ID. + // Will be generated by the installer in case it is not provided. + // +optional + ClusterID string `json:"cluster_id,omitempty"` + + // InfraID is the desired infra ID. + // Will be generated by the installer in case it is not provided. + // +optional + InfraID string `json:"infra_id,omitempty"` } // InstallationConfig is the API for specifying configuration for the