Files
capsule/api/v1beta2/customquota_status.go
Sander TervoertandGitHub d255c33f5d feat: add observedgeneration to status object of all crds (#1930)
* feat: add observedgeneration to status object of all crds

Signed-off-by: sandert-k8s <sandert98@gmail.com>

* chore(api): rename rulestatusspec to rulestatusstatus

Signed-off-by: sandert-k8s <sandert98@gmail.com>

---------

Signed-off-by: sandert-k8s <sandert98@gmail.com>
2026-06-01 06:51:46 +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"`
// Path on 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"`
}