This repository was archived by the owner on Aug 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -88,14 +88,22 @@ func (c *PacketCluster) ValidateUpdate(oldRaw runtime.Object) error {
8888 )
8989 }
9090
91- // Must have either one of Metro or Facility
91+ // Must have at least Metro or Facility specified
9292 if len (c .Spec .Facility ) == 0 && len (c .Spec .Metro ) == 0 {
9393 allErrs = append (allErrs ,
9494 field .Invalid (field .NewPath ("spec" , "Metro" ),
9595 c .Spec .Metro , "field is required when Facility is not set" ),
9696 )
9797 }
9898
99+ // Must have only one of Metro or Facility
100+ if len (c .Spec .Facility ) > 0 && len (c .Spec .Metro ) > 0 {
101+ allErrs = append (allErrs ,
102+ field .Invalid (field .NewPath ("spec" , "Metro" ),
103+ c .Spec .Metro , "field and Facility field are mutually exclusive" ),
104+ )
105+ }
106+
99107 if len (allErrs ) == 0 {
100108 return nil
101109 }
Original file line number Diff line number Diff line change @@ -60,6 +60,14 @@ func (m *PacketMachine) ValidateUpdate(old runtime.Object) error {
6060 machineLog .Info ("validate update" , "name" , m .Name )
6161 var allErrs field.ErrorList
6262
63+ // Must have only one of Metro or Facility specified
64+ if len (m .Spec .Facility ) > 0 && len (m .Spec .Metro ) > 0 {
65+ allErrs = append (allErrs ,
66+ field .Invalid (field .NewPath ("spec" , "Metro" ),
67+ m .Spec .Metro , "field and Facility field are mutually exclusive" ),
68+ )
69+ }
70+
6371 newPacketMachine , err := runtime .DefaultUnstructuredConverter .ToUnstructured (m )
6472 if err != nil {
6573 allErrs = append (allErrs ,
You can’t perform that action at this time.
0 commit comments