Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 77978c7

Browse files
committed
Updated facility and metro recommendation errors
1 parent 5976e1a commit 77978c7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

api/v1beta1/packetcluster_webhook.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@ func (c *PacketCluster) ValidateCreate() error {
5353
if len(c.Spec.Facility) == 0 && len(c.Spec.Metro) == 0 {
5454
allErrs = append(allErrs,
5555
field.Invalid(field.NewPath("spec", "Metro"),
56-
c.Spec.Metro, "field is required when Facility is not set"),
56+
c.Spec.Metro, "field is required"),
5757
)
5858
}
5959

60-
// If both Metro and Facility are set, ignore Facility, we'll leave this to
61-
// the controller to deal with - the facility will need to reside in the
62-
// metro.
63-
6460
if len(allErrs) > 0 {
6561
return apierrors.NewInvalid(GroupVersion.WithKind("PacketCluster").GroupKind(), c.Name, allErrs)
6662
}
@@ -92,15 +88,15 @@ func (c *PacketCluster) ValidateUpdate(oldRaw runtime.Object) error {
9288
if len(c.Spec.Facility) == 0 && len(c.Spec.Metro) == 0 {
9389
allErrs = append(allErrs,
9490
field.Invalid(field.NewPath("spec", "Metro"),
95-
c.Spec.Metro, "Metro is required when Facility is not set"),
91+
c.Spec.Metro, "Metro is required"),
9692
)
9793
}
9894

9995
// Must have only one of Metro or Facility
10096
if len(c.Spec.Facility) > 0 && len(c.Spec.Metro) > 0 {
10197
allErrs = append(allErrs,
10298
field.Invalid(field.NewPath("spec", "Facility"),
103-
c.Spec.Facility, "Metro and Facility are mutually exclusive"),
99+
c.Spec.Facility, "Metro and Facility are mutually exclusive, Metro is recommended"),
104100
)
105101
}
106102

0 commit comments

Comments
 (0)