@@ -123,12 +123,10 @@ func (v *Validator) handle(ctx context.Context, log logr.Logger, req *request) a
123
123
124
124
if why := config .WhyUnmanaged (req .hc .Namespace ); why != "" {
125
125
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?
127
126
return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
128
127
}
129
128
if why := config .WhyUnmanaged (req .hc .Spec .Parent ); why != "" {
130
129
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?
132
130
return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
133
131
}
134
132
@@ -190,7 +188,6 @@ func (v *Validator) checkNS(ns *forest.Namespace) admission.Response {
190
188
haltedRoot := ns .GetHaltedRoot ()
191
189
if haltedRoot != "" && haltedRoot != ns .Name () {
192
190
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?
194
191
return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
195
192
}
196
193
@@ -201,7 +198,6 @@ func (v *Validator) checkNS(ns *forest.Namespace) admission.Response {
201
198
func (v * Validator ) checkParent (ns , curParent , newParent * forest.Namespace ) admission.Response {
202
199
if ns .IsExternal () && newParent != nil {
203
200
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?
205
201
return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
206
202
}
207
203
@@ -212,14 +208,12 @@ func (v *Validator) checkParent(ns, curParent, newParent *forest.Namespace) admi
212
208
// Prevent changing parent of a subnamespace
213
209
if ns .IsSub {
214
210
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?
216
211
return webhooks .DenyConflict (api .HierarchyConfigurationGR , api .Singleton , err )
217
212
}
218
213
219
214
// non existence of parent namespace -> not allowed
220
215
if newParent != nil && ! newParent .Exists () {
221
216
err := fmt .Errorf ("requested parent %q does not exist" , newParent .Name ())
222
- // TODO(erikgb): Invalid field error better?
223
217
return webhooks .DenyForbidden (api .HierarchyConfigurationGR , api .Singleton , err )
224
218
}
225
219
@@ -230,7 +224,6 @@ func (v *Validator) checkParent(ns, curParent, newParent *forest.Namespace) admi
230
224
// parent conflicts with something in the _existing_ hierarchy.
231
225
if reason := ns .CanSetParent (newParent ); reason != "" {
232
226
err := fmt .Errorf ("illegal parent: %s" , reason )
233
- // TODO(erikgb): Invalid field error better?
234
227
return webhooks .DenyConflict (api .HierarchyConfigurationGR , api .Singleton , err )
235
228
}
236
229
0 commit comments