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 {
88
88
)
89
89
}
90
90
91
- // Must have either one of Metro or Facility
91
+ // Must have at least Metro or Facility specified
92
92
if len (c .Spec .Facility ) == 0 && len (c .Spec .Metro ) == 0 {
93
93
allErrs = append (allErrs ,
94
94
field .Invalid (field .NewPath ("spec" , "Metro" ),
95
95
c .Spec .Metro , "field is required when Facility is not set" ),
96
96
)
97
97
}
98
98
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
+
99
107
if len (allErrs ) == 0 {
100
108
return nil
101
109
}
Original file line number Diff line number Diff line change @@ -60,6 +60,14 @@ func (m *PacketMachine) ValidateUpdate(old runtime.Object) error {
60
60
machineLog .Info ("validate update" , "name" , m .Name )
61
61
var allErrs field.ErrorList
62
62
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
+
63
71
newPacketMachine , err := runtime .DefaultUnstructuredConverter .ToUnstructured (m )
64
72
if err != nil {
65
73
allErrs = append (allErrs ,
You can’t perform that action at this time.
0 commit comments