Files
capsule/api/v1beta2/customquota_status.go
Oliver BählerandGitHub 2252c530f4 feat(performance): removed duplicate client calls from all admission paths (#2054)
* chore

* perfromance improvements

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* perfromance improvements

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

---------

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
2026-07-28 14:32:42 +02:00

66 lines
1.9 KiB
Go

// Copyright 2020-2026 Project Capsule Authors
// SPDX-License-Identifier: Apache-2.0
package v1beta2
import (
k8smeta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/projectcapsule/capsule/pkg/api/meta"
)
// CustomQuotaStatus defines the observed state of GlobalResourceQuota.
type CustomQuotaStatus struct {
// ObservedGeneration is the most recent generation the controller has observed.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Usage measurements
// +optional
Usage CustomQuotaStatusUsage `json:"usage,omitempty"`
// Objects regarding this policy
Claims []CustomQuotaClaimItem `json:"claims,omitempty"`
// Targeting GVK
Targets []CustomQuotaStatusTarget `json:"targets"`
// Conditions
Conditions meta.ConditionList `json:"conditions"`
}
func (s *CustomQuotaStatus) HasClaimUID(uid types.UID) bool {
for i := range s.Claims {
if s.Claims[i].UID == uid {
return true
}
}
return false
}
type CustomQuotaClaimItem struct {
metav1.GroupVersionKind `json:",inline"`
meta.NamespacedObjectWithUIDReference `json:",inline"`
// Resource Quantity for given item
Usage resource.Quantity `json:"usage"`
}
type CustomQuotaStatusTarget struct {
metav1.GroupVersionKind `json:",inline"`
CustomQuotaSpecSourceConfig `json:",inline"`
// Scope of the GVK where usage is evaluated.
Scope k8smeta.RESTScopeName `json:"scope,omitempty"`
}
// CustomQuotaStatus defines the observed state of GlobalResourceQuota.
type CustomQuotaStatusUsage struct {
// Used is the current observed total usage of the resource.
// +optional
Used resource.Quantity `json:"used"`
// Used is the current observed total available of the resource (limit - used).
// +optional
Available resource.Quantity `json:"available"`
}