@@ -101,6 +101,38 @@ var _ = Describe("CloudProfileConfig validation", func() {
101101 }))))
102102 })
103103
104+ It ("should forbid images with empty regions" , func () {
105+ var fieldMatcher string
106+ if isCapabilitiesCloudProfile {
107+ fieldMatcher = "machineImages[0].versions[0].capabilityFlavors[0].regions"
108+ cloudProfileConfig .MachineImages [0 ].Versions [0 ].CapabilityFlavors [0 ].Regions = []apisaws.RegionAMIMapping {}
109+ } else {
110+ fieldMatcher = "machineImages[0].versions[0].regions"
111+ cloudProfileConfig .MachineImages [0 ].Versions [0 ].Regions = []apisaws.RegionAMIMapping {}
112+ }
113+
114+ errorList := ValidateCloudProfileConfig (cloudProfileConfig , machineImages , capabilityDefinitions , fldPath )
115+ if isCapabilitiesCloudProfile {
116+ Expect (errorList ).To (ConsistOf (PointTo (MatchFields (IgnoreExtras , Fields {
117+ "Type" : Equal (field .ErrorTypeRequired ),
118+ "Detail" : Equal ("must provide at least one region for machine image \" ubuntu\" and version \" 1.2.3\" " ),
119+ "Field" : Equal (fieldMatcher ),
120+ }))))
121+ } else {
122+ Expect (errorList ).To (ConsistOf (PointTo (MatchFields (IgnoreExtras , Fields {
123+ "Type" : Equal (field .ErrorTypeRequired ),
124+ "Detail" : Equal ("missing providerConfig mapping for machine image version ubuntu@1.2.3 and architecture: amd64" ),
125+ "Field" : Equal ("spec.machineImages[0].versions[0]" ),
126+ })),
127+ PointTo (MatchFields (IgnoreExtras , Fields {
128+ "Type" : Equal (field .ErrorTypeRequired ),
129+ "Detail" : Equal ("must provide at least one region for machine image \" ubuntu\" and version \" 1.2.3\" " ),
130+ "Field" : Equal (fieldMatcher ),
131+ })),
132+ ))
133+ }
134+ })
135+
104136 It ("should forbid unsupported machine image configuration" , func () {
105137 cloudProfileConfig .MachineImages = []apisaws.MachineImages {{}}
106138
0 commit comments