Skip to content

Commit edaee99

Browse files
authored
Merge pull request #626 from CecileRobertMichon/fix-image-validation
🐛 fix: allow nil image in AzureMachine webhook validation
2 parents db93854 + b9b11aa commit edaee99

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

api/v1alpha3/azureimage_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ValidateImage(image *Image, fldPath *field.Path) field.ErrorList {
2525
allErrs := field.ErrorList{}
2626

2727
if image == nil {
28-
allErrs = append(allErrs, field.Required(fldPath, "an image must be specified"))
28+
// allow empty image as it is defaulted in the AzureMachine controller
2929
return allErrs
3030
}
3131

api/v1alpha3/azureimage_validation_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"k8s.io/apimachinery/pkg/util/validation/field"
2525
)
2626

27-
func TestImageRequired(t *testing.T) {
27+
func TestImageOptional(t *testing.T) {
2828
g := NewWithT(t)
2929

3030
type test struct {
@@ -34,10 +34,7 @@ func TestImageRequired(t *testing.T) {
3434
extension := test{}
3535

3636
errs := ValidateImage(extension.Image, field.NewPath("image"))
37-
g.Expect(errs).To(HaveLen(1))
38-
g.Expect(errs[0].Type).To(Equal(field.ErrorTypeRequired))
39-
g.Expect(errs[0].Field).To(Equal("image"))
40-
g.Expect(errs[0].Detail).NotTo(BeEmpty())
37+
g.Expect(errs).To(HaveLen(0))
4138
}
4239

4340
func TestImageTooManyDetails(t *testing.T) {

0 commit comments

Comments
 (0)