diff --git a/pkg/apis/hive/v1alpha1/installconfig.go b/pkg/apis/hive/v1alpha1/installconfig.go index 18f9f5e9d8f..2b6a7adc643 100644 --- a/pkg/apis/hive/v1alpha1/installconfig.go +++ b/pkg/apis/hive/v1alpha1/installconfig.go @@ -4,6 +4,8 @@ import ( corev1 "k8s.io/api/core/v1" "net" + + "github.com/openshift/installer/pkg/ipnet" ) // InstallConfig is the configuration for an OpenShift install. @@ -72,7 +74,8 @@ type AWSPlatform struct { DefaultMachinePlatform *AWSMachinePoolPlatform `json:"defaultMachinePlatform,omitempty"` // VPCCIDRBlock - VPCCIDRBlock string `json:"vpcCIDRBlock"` + // +optional + VPCCIDRBlock *ipnet.IPNet `json:"vpcCIDRBlock,omitempty"` } // LibvirtPlatform stores all the global configuration that diff --git a/pkg/install/convertconfig.go b/pkg/install/convertconfig.go index 31f22e23447..48cd94d4e12 100644 --- a/pkg/install/convertconfig.go +++ b/pkg/install/convertconfig.go @@ -18,7 +18,6 @@ package install import ( "fmt" - "net" hivev1 "github.com/openshift/hive/pkg/apis/hive/v1alpha1" @@ -97,13 +96,9 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri SSHKey: sshKey, BaseDomain: spec.Config.BaseDomain, Networking: types.Networking{ - Type: networkType, - ServiceCIDR: ipnet.IPNet{ - IPNet: parseCIDR(spec.Config.Networking.ServiceCIDR), - }, - PodCIDR: &ipnet.IPNet{ - IPNet: parseCIDR(spec.Config.Networking.PodCIDR), - }, + Type: networkType, + ServiceCIDR: *parseCIDR(spec.Config.Networking.ServiceCIDR), + PodCIDR: parseCIDR(spec.Config.Networking.PodCIDR), }, PullSecret: pullSecret, Platform: platform, @@ -112,12 +107,11 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri return ic, nil } -func parseCIDR(s string) net.IPNet { +func parseCIDR(s string) *ipnet.IPNet { if s == "" { - return net.IPNet{} + return &ipnet.IPNet{} } - _, cidr, _ := net.ParseCIDR(s) - return *cidr + return ipnet.MustParseCIDR(s) } func convertNetworkingType(hnt hivev1.NetworkType) (netopv1.NetworkType, error) { diff --git a/pkg/install/convertconfig_test.go b/pkg/install/convertconfig_test.go index bd7c722f0aa..b6a8929263b 100644 --- a/pkg/install/convertconfig_test.go +++ b/pkg/install/convertconfig_test.go @@ -43,7 +43,6 @@ const ( adminPassword = "adminpassword" adminSSHKey = "adminSSH" pullSecret = "pullSecret" - vpcCIDRBlock = "10.1.0.0/16" awsInstanceType = "fake-aws-type" awsRegion = "us-east-1" iamRoleName = "rolename" @@ -52,6 +51,10 @@ const ( ec2VolType = "sometype" ) +var ( + vpcCIDRBlock = ipnet.MustParseCIDR("10.1.0.0/16") +) + func buildValidClusterDeployment() *hivev1.ClusterDeployment { replicas := int64(3) return &hivev1.ClusterDeployment{ @@ -137,13 +140,9 @@ func buildBaseExpectedInstallConfig() *installtypes.InstallConfig { PullSecret: pullSecret, Networking: installtypes.Networking{ // TODO: Hardcoded to match installer for now. - Type: "OpenshiftSDN", - ServiceCIDR: ipnet.IPNet{ - IPNet: parseCIDR("172.30.0.0/16"), - }, - PodCIDR: &ipnet.IPNet{ - IPNet: parseCIDR("10.128.0.0/14"), - }, + Type: "OpenshiftSDN", + ServiceCIDR: *ipnet.MustParseCIDR("172.30.0.0/16"), + PodCIDR: ipnet.MustParseCIDR("10.128.0.0/14"), }, Platform: installtypes.Platform{ AWS: &installawstypes.Platform{