@@ -123,12 +123,10 @@ func (v *Validator) handle(ctx context.Context, log logr.Logger, req *request) a
123123
124124 if why := config .WhyUnmanaged (req .hc .Namespace ); why != "" {
125125 err := fmt .Errorf ("namespace %q is not managed by HNC (%s) and cannot be set as a child of another namespace" , req .hc .Namespace , why )
126- // TODO(erikgb): Invalid field error better?
127126 return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
128127 }
129128 if why := config .WhyUnmanaged (req .hc .Spec .Parent ); why != "" {
130129 err := fmt .Errorf ("namespace %q is not managed by HNC (%s) and cannot be set as the parent of another namespace" , req .hc .Spec .Parent , why )
131- // TODO(erikgb): Invalid field error better?
132130 return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
133131 }
134132
@@ -190,7 +188,6 @@ func (v *Validator) checkNS(ns *forest.Namespace) admission.Response {
190188 haltedRoot := ns .GetHaltedRoot ()
191189 if haltedRoot != "" && haltedRoot != ns .Name () {
192190 err := fmt .Errorf ("ancestor %q of namespace %q has a critical condition, which must be resolved before any changes can be made to the hierarchy configuration" , haltedRoot , ns .Name ())
193- // TODO(erikgb): InternalError better?
194191 return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
195192 }
196193
@@ -201,7 +198,6 @@ func (v *Validator) checkNS(ns *forest.Namespace) admission.Response {
201198func (v * Validator ) checkParent (ns , curParent , newParent * forest.Namespace ) admission.Response {
202199 if ns .IsExternal () && newParent != nil {
203200 err := fmt .Errorf ("namespace %q is managed by %q, not HNC, so it cannot have a parent in HNC" , ns .Name (), ns .Manager )
204- // TODO(erikgb): Invalid field error better?
205201 return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
206202 }
207203
@@ -212,14 +208,12 @@ func (v *Validator) checkParent(ns, curParent, newParent *forest.Namespace) admi
212208 // Prevent changing parent of a subnamespace
213209 if ns .IsSub {
214210 err := fmt .Errorf ("illegal parent: Cannot set the parent of %q to %q because it's a subnamespace of %q" , ns .Name (), newParent .Name (), curParent .Name ())
215- // TODO(erikgb): Invalid field error better?
216211 return webhooks .DenyConflict (api .HierarchyConfigurationGR , api .Singleton , err )
217212 }
218213
219214 // non existence of parent namespace -> not allowed
220215 if newParent != nil && ! newParent .Exists () {
221216 err := fmt .Errorf ("requested parent %q does not exist" , newParent .Name ())
222- // TODO(erikgb): Invalid field error better?
223217 return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
224218 }
225219
@@ -230,7 +224,6 @@ func (v *Validator) checkParent(ns, curParent, newParent *forest.Namespace) admi
230224 // parent conflicts with something in the _existing_ hierarchy.
231225 if reason := ns .CanSetParent (newParent ); reason != "" {
232226 err := fmt .Errorf ("illegal parent: %s" , reason )
233- // TODO(erikgb): Invalid field error better?
234227 return webhooks .DenyConflict (api .HierarchyConfigurationGR , api .Singleton , err )
235228 }
236229
0 commit comments