Skip to content

Commit ff0e4ad

Browse files
committed
add the ability to use the metro zone
Signed-off-by: Felix Breuer <f.breuer94@gmail.com>
1 parent b2d8e54 commit ff0e4ad

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pkg/provider/apis/validation/validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ var machineTypeRegex = regexp.MustCompile(`^[a-z]+\d+[a-z]*\.\d+[a-z]*(\.[a-z]+\
3535
var regionRegex = regexp.MustCompile(`^[a-z0-9]+$`)
3636

3737
// availabilityZoneRegex is a regex pattern for validating STACKIT availability zone format
38-
// Pattern: lowercase letters/digits followed by digits, dash, then digit(s) (e.g., eu01-1, eu01-2)
39-
var availabilityZoneRegex = regexp.MustCompile(`^[a-z0-9]+-\d+$`)
38+
// Pattern: lowercase letters/digits followed by dash, then digits or letter 'm' (e.g., eu01-1, eu01-2, eu01-m)
39+
var availabilityZoneRegex = regexp.MustCompile(`^[a-z0-9]+-(?:\d+|m)$`)
4040

4141
// labelKeyRegex validates Kubernetes label keys (must start/end with alphanumeric, can contain -, _, ., /)
4242
// Maximum length: 63 characters

pkg/provider/apis/validation/validation_fields_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,32 @@ var _ = Describe("ValidateProviderSpecNSecret", func() {
129129
"eu01-2",
130130
"eu02-1",
131131
"eu02-4",
132+
"eu01-m",
133+
"eu02-m",
132134
}
133135
for _, az := range testCases {
134136
providerSpec.AvailabilityZone = az
135137
errors := ValidateProviderSpecNSecret(providerSpec, secret)
136138
Expect(errors).To(BeEmpty(), "AvailabilityZone %q should be valid", az)
137139
}
138140
})
141+
142+
It("should fail with invalid availabilityZone formats", func() {
143+
invalidCases := []string{
144+
"eu01-a", // letter other than 'm'
145+
"eu01-m1", // 'm' followed by digit
146+
"eu01", // missing dash and suffix
147+
"eu01-", // missing suffix
148+
"-1", // missing prefix
149+
"eu01-mm", // multiple letters
150+
}
151+
for _, az := range invalidCases {
152+
providerSpec.AvailabilityZone = az
153+
errors := ValidateProviderSpecNSecret(providerSpec, secret)
154+
Expect(errors).NotTo(BeEmpty(), "AvailabilityZone %q should be invalid", az)
155+
Expect(errors[0].Error()).To(ContainSubstring("invalid format"))
156+
}
157+
})
139158
})
140159

141160
Context("AffinityGroup validation", func() {

0 commit comments

Comments
 (0)