You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnerrors.New("invalid capacityReservationId: capacityReservationId cannot be empty")
2284
+
}
2285
+
// It must starts with cr-xxxxxxxxxxxxxxxxx with length of 17 characters excluding cr-
2286
+
re:=regexp.MustCompile(`^cr-[0-9a-f]{17}$`)
2287
+
if!re.MatchString(capacityReservationId) {
2288
+
returnfmt.Errorf("invalid value for capacityReservationId: %q, it must start with 'cr-' and be exactly 20 characters long with 17 hexadecimal characters", capacityReservationId)
name: "with AWS and CapacityReservationID is empty",
157
+
platformType: osconfigv1.AWSPlatformType,
158
+
clusterID: "aws-cluster",
159
+
providerSpecValue: &kruntime.RawExtension{
160
+
Object: &machinev1beta1.AWSMachineProviderConfig{
161
+
AMI: machinev1beta1.AWSResourceReference{
162
+
ID: ptr.To[string]("ami"),
163
+
},
164
+
CapacityReservationID: "",
165
+
},
166
+
},
167
+
expectedError: "",
168
+
},
169
+
{
170
+
name: "with AWS and CapacityReservationID is valid",
171
+
platformType: osconfigv1.AWSPlatformType,
172
+
clusterID: "aws-cluster",
173
+
providerSpecValue: &kruntime.RawExtension{
174
+
Object: &machinev1beta1.AWSMachineProviderConfig{
175
+
AMI: machinev1beta1.AWSResourceReference{
176
+
ID: ptr.To[string]("ami"),
177
+
},
178
+
CapacityReservationID: "cr-12345678901234567",
179
+
},
180
+
},
181
+
expectedError: "",
182
+
},
183
+
{
184
+
name: "with AWS and CapacityReservationID is not valid",
185
+
platformType: osconfigv1.AWSPlatformType,
186
+
clusterID: "aws-cluster",
187
+
providerSpecValue: &kruntime.RawExtension{
188
+
Object: &machinev1beta1.AWSMachineProviderConfig{
189
+
AMI: machinev1beta1.AWSResourceReference{
190
+
ID: ptr.To[string]("ami"),
191
+
},
192
+
CapacityReservationID: "cr-123",
193
+
},
194
+
},
195
+
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: providerSpec.capacityReservationId: Invalid value: \"cr-123\": invalid value for capacityReservationId: \"cr-123\", it must start with 'cr-' and be exactly 20 characters long with 17 hexadecimal characters",
0 commit comments