mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-05-02 23:46:41 +00:00
fix: bypass resourepool limits (#1669)
* fix: bypass resourepool limits Signed-off-by: Hristo Hristov <me@hhristov.info> * fix: bypass resourepool limits Signed-off-by: Hristo Hristov <me@hhristov.info> --------- Signed-off-by: Hristo Hristov <me@hhristov.info>
This commit is contained in:
@@ -32,8 +32,20 @@ func (h *claimValidationHandler) OnCreate(client.Client, admission.Decoder, reco
|
||||
}
|
||||
}
|
||||
|
||||
func (h *claimValidationHandler) OnDelete(client.Client, admission.Decoder, record.EventRecorder) capsulewebhook.Func {
|
||||
return func(context.Context, admission.Request) *admission.Response {
|
||||
func (h *claimValidationHandler) OnDelete(_ client.Client, decoder admission.Decoder, _ record.EventRecorder) capsulewebhook.Func {
|
||||
return func(_ context.Context, req admission.Request) *admission.Response {
|
||||
claim := &capsulev1beta2.ResourcePoolClaim{}
|
||||
|
||||
if err := decoder.DecodeRaw(req.OldObject, claim); err != nil {
|
||||
return utils.ErroredResponse(fmt.Errorf("failed to decode old object: %w", err))
|
||||
}
|
||||
|
||||
if claim.IsBoundToResourcePool() {
|
||||
response := admission.Denied(fmt.Sprintf("cannot delete the pool while claim is bound to a resourcepool %s", claim.Status.Pool.Name))
|
||||
|
||||
return &response
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user