Skip to content

Commit

Permalink
api/v1beta1: improve error messages text
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Gozdek <[email protected]>
  • Loading branch information
invidian committed Jun 15, 2022
1 parent fed4245 commit cd0350d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/v1beta1/azureimage_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ func validateSingleDetailsOnly(image *Image, fldPath *field.Path) field.ErrorLis

if image.SharedGallery != nil {
if imageDetailsFound {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("SharedGallery"), "SharedGallery cannot be used as an image ID, Marketplace or ComputeGallery images has been specified"))
allErrs = append(allErrs, field.Forbidden(fldPath.Child("SharedGallery"), "SharedGallery cannot be used as an image ID. Marketplace or ComputeGallery images has been specified"))
} else {
imageDetailsFound = true
}
}

if image.ComputeGallery != nil {
if imageDetailsFound {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("ComputeGallery"), "ComputeGallery cannot be used as an image ID, Marketplace or SharedGallery images has been specified"))
allErrs = append(allErrs, field.Forbidden(fldPath.Child("ComputeGallery"), "ComputeGallery cannot be used as an image ID. Marketplace or SharedGallery images has been specified"))
} else {
imageDetailsFound = true
}
}

if !imageDetailsFound {
allErrs = append(allErrs, field.Required(fldPath, "You must supply a ID, Marketplace or ComputeGallery image details"))
allErrs = append(allErrs, field.Required(fldPath, "You must supply an ID, Marketplace or ComputeGallery image details"))
}

return allErrs
Expand Down
2 changes: 1 addition & 1 deletion exp/api/v1beta1/azuremachinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestAzureMachinePool_Validate(t *testing.T) {
},
Expect: func(g *gomega.GomegaWithT, actual error) {
g.Expect(actual).To(gomega.HaveOccurred())
g.Expect(actual.Error()).To(gomega.ContainSubstring("You must supply a ID, Marketplace or ComputeGallery image details"))
g.Expect(actual.Error()).To(gomega.ContainSubstring("You must supply an ID, Marketplace or ComputeGallery image details"))
},
},
{
Expand Down

0 comments on commit cd0350d

Please sign in to comment.