diff --git a/api/v1alpha3/azureimage_validation.go b/api/v1alpha3/azureimage_validation.go index 82e44795776..bc3651162e3 100644 --- a/api/v1alpha3/azureimage_validation.go +++ b/api/v1alpha3/azureimage_validation.go @@ -25,7 +25,7 @@ func ValidateImage(image *Image, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} if image == nil { - allErrs = append(allErrs, field.Required(fldPath, "an image must be specified")) + // allow empty image as it is defaulted in the AzureMachine controller return allErrs } diff --git a/api/v1alpha3/azureimage_validation_test.go b/api/v1alpha3/azureimage_validation_test.go index 5a198be1f2b..bf1b7ef3cbb 100644 --- a/api/v1alpha3/azureimage_validation_test.go +++ b/api/v1alpha3/azureimage_validation_test.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" ) -func TestImageRequired(t *testing.T) { +func TestImageOptional(t *testing.T) { g := NewWithT(t) type test struct { @@ -34,10 +34,7 @@ func TestImageRequired(t *testing.T) { extension := test{} errs := ValidateImage(extension.Image, field.NewPath("image")) - g.Expect(errs).To(HaveLen(1)) - g.Expect(errs[0].Type).To(Equal(field.ErrorTypeRequired)) - g.Expect(errs[0].Field).To(Equal("image")) - g.Expect(errs[0].Detail).NotTo(BeEmpty()) + g.Expect(errs).To(HaveLen(0)) } func TestImageTooManyDetails(t *testing.T) {