@@ -28,6 +28,8 @@ const (
28
28
infraCloudConfKey = "foo"
29
29
30
30
defaultAzureConfig = `{"cloud":"AzurePublicCloud","tenantId":"0000000-0000-0000-0000-000000000000","Entries":null,"subscriptionId":"0000000-0000-0000-0000-000000000000","vmType":"standard","putVMSSVMBatchSize":0,"enableMigrateToIPBasedBackendPoolAPI":false,"clusterServiceLoadBalancerHealthProbeMode":"shared"}`
31
+ defaultAWSConfig = `[Global]
32
+ `
31
33
)
32
34
33
35
func makeInfrastructureResource (platform configv1.PlatformType ) * configv1.Infrastructure {
@@ -84,8 +86,7 @@ func makeInfraStatus(platform configv1.PlatformType) configv1.InfrastructureStat
84
86
}
85
87
86
88
func makeInfraCloudConfig (platform configv1.PlatformType ) * corev1.ConfigMap {
87
- defaultConfig := `[Global]
88
- `
89
+ defaultConfig := defaultAWSConfig
89
90
90
91
if platform == configv1 .AzurePlatformType {
91
92
defaultConfig = defaultAzureConfig
@@ -98,8 +99,7 @@ func makeInfraCloudConfig(platform configv1.PlatformType) *corev1.ConfigMap {
98
99
}
99
100
100
101
func makeManagedCloudConfig (platform configv1.PlatformType ) * corev1.ConfigMap {
101
- defaultConfig := `[Global]
102
- `
102
+ defaultConfig := defaultAWSConfig
103
103
104
104
if platform == configv1 .AzurePlatformType {
105
105
defaultConfig = defaultAzureConfig
@@ -151,12 +151,14 @@ var _ = Describe("prepareSourceConfigMap reconciler method", func() {
151
151
Expect (reconciler .isCloudConfigEqual (preparedConfig , managedCloudConfig )).Should (BeTrue ())
152
152
})
153
153
154
- It ("config preparation should fail if key from infra resource does not found" , func () {
155
- brokenInfraConfig := infraCloudConfig .DeepCopy ()
156
- brokenInfraConfig .Data = map [string ]string {"hehehehehe" : "bar" }
157
- _ , err := reconciler .prepareSourceConfigMap (brokenInfraConfig , infra )
158
- Expect (err ).Should (Not (Succeed ()))
159
- Expect (err .Error ()).Should (BeEquivalentTo ("key foo specified in infra resource does not found in source configmap openshift-config/test-config" ))
154
+ It ("config preparation should create required key if key isn't found in infrastructure" , func () {
155
+ infraConfig := infraCloudConfig .DeepCopy ()
156
+ infraConfig .Data = map [string ]string {"hehehehehe" : "bar" }
157
+ preparedConfig , err := reconciler .prepareSourceConfigMap (infraConfig , infra )
158
+ Expect (err ).Should (Succeed ())
159
+ _ , ok := preparedConfig .Data [defaultConfigKey ]
160
+ Expect (ok ).Should (BeTrue ())
161
+ Expect (len (preparedConfig .Data [defaultConfigKey ])).Should (BeEquivalentTo (0 ))
160
162
})
161
163
162
164
It ("config preparation should not touch extra fields in infra ConfigMap" , func () {
@@ -467,7 +469,7 @@ var _ = Describe("Cloud config sync reconciler", func() {
467
469
Expect (cl .Create (ctx , makeInfraCloudConfig (configv1 .AWSPlatformType ))).To (Succeed ())
468
470
})
469
471
470
- It ("should skip config sync for AWS platform if there is no reference in infra resource" , func () {
472
+ It ("should sync for a default config AWS platform if there is no reference in infra resource" , func () {
471
473
infraResource := makeInfrastructureResource (configv1 .AWSPlatformType )
472
474
infraResource .Spec .CloudConfig .Name = ""
473
475
Expect (cl .Create (ctx , infraResource )).To (Succeed ())
@@ -481,7 +483,10 @@ var _ = Describe("Cloud config sync reconciler", func() {
481
483
allCMs := & corev1.ConfigMapList {}
482
484
Expect (cl .List (ctx , allCMs , & client.ListOptions {Namespace : targetNamespaceName })).To (Succeed ())
483
485
484
- Expect (len (allCMs .Items )).To (BeZero ())
486
+ Expect (len (allCMs .Items )).To (BeEquivalentTo (1 ))
487
+ // Our code ensures that there is at a minimum a global section.
488
+ // The CCM itself may end up defaulting values for us, so don't use exact string matching.
489
+ Expect (allCMs .Items [0 ].Data [defaultConfigKey ]).To (HavePrefix (defaultAWSConfig ))
485
490
})
486
491
487
492
It ("should perform config sync for AWS platform if there is a reference in infra resource" , func () {
0 commit comments