From 55c8c0d1755526127620bf6de58aa6e1ed6b29a3 Mon Sep 17 00:00:00 2001 From: Imtiaz Uddin Date: Wed, 4 Oct 2023 14:42:38 +0600 Subject: [PATCH 1/2] Add status in project quota api type Signed-off-by: Imtiaz Uddin --- apis/core/v1alpha1/zz_generated.deepcopy.go | 7 ++-- apis/management/v1alpha1/openapi_generated.go | 38 ++++++++++++++++--- .../management/v1alpha1/projectquota_types.go | 8 +++- .../v1alpha1/zz_generated.deepcopy.go | 17 +++++++++ apis/meta/v1alpha1/zz_generated.deepcopy.go | 7 ++-- apis/ui/v1alpha1/zz_generated.deepcopy.go | 3 +- ...gement.k8s.appscode.com_projectquotas.yaml | 19 +++++++--- 7 files changed, 76 insertions(+), 23 deletions(-) diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index c6672a102..f7b596305 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -22,15 +22,14 @@ limitations under the License. package v1alpha1 import ( - apiv1 "kmodules.xyz/client-go/api/v1" - shared "kmodules.xyz/resource-metadata/apis/shared" - api "kmodules.xyz/resource-metrics/api" - v1 "k8s.io/api/core/v1" resource "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" version "k8s.io/apimachinery/pkg/version" + apiv1 "kmodules.xyz/client-go/api/v1" + shared "kmodules.xyz/resource-metadata/apis/shared" + api "kmodules.xyz/resource-metrics/api" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/apis/management/v1alpha1/openapi_generated.go b/apis/management/v1alpha1/openapi_generated.go index c7f2ee926..1aa66837b 100644 --- a/apis/management/v1alpha1/openapi_generated.go +++ b/apis/management/v1alpha1/openapi_generated.go @@ -301,6 +301,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ProjectQuotaList": schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaList(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ProjectQuotaSpec": schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaSpec(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ProjectQuotaStatus": schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaStatus(ref), + "kmodules.xyz/resource-metadata/apis/management/v1alpha1.QuotaStatus": schema_resource_metadata_apis_management_v1alpha1_QuotaStatus(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ResourceQuotaSpec": schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaSpec(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ResourceQuotaStatus": schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaStatus(ref), "kmodules.xyz/resource-metadata/apis/shared.Action": schema_kmodulesxyz_resource_metadata_apis_shared_Action(ref), @@ -14732,6 +14733,32 @@ func schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaStatus(ref co } } +func schema_resource_metadata_apis_management_v1alpha1_QuotaStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "result": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"result"}, + }, + }, + } +} + func schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -14806,11 +14833,10 @@ func schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaStatus(ref c }, }, }, - "result": { + "quotaStatus": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/resource-metadata/apis/management/v1alpha1.QuotaStatus"), }, }, "used": { @@ -14829,11 +14855,11 @@ func schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaStatus(ref c }, }, }, - Required: []string{"result"}, + Required: []string{"quotaStatus"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + "k8s.io/apimachinery/pkg/api/resource.Quantity", "kmodules.xyz/resource-metadata/apis/management/v1alpha1.QuotaStatus"}, } } diff --git a/apis/management/v1alpha1/projectquota_types.go b/apis/management/v1alpha1/projectquota_types.go index 97aa5cb7a..b82b13558 100644 --- a/apis/management/v1alpha1/projectquota_types.go +++ b/apis/management/v1alpha1/projectquota_types.go @@ -65,12 +65,18 @@ type ProjectQuotaStatus struct { type ResourceQuotaStatus struct { ResourceQuotaSpec `json:",inline"` - Result QuotaResult `json:"result"` + QuotaStatus QuotaStatus `json:"quotaStatus"` + // Used is the current observed total usage of the resource in the namespace. // +optional Used core.ResourceList `json:"used,omitempty"` } +type QuotaStatus struct { + Result QuotaResult `json:"result"` + Reason string `json:"reason,omitempty"` +} + // +kubebuilder:validation:Enum=Success;Error type QuotaResult string diff --git a/apis/management/v1alpha1/zz_generated.deepcopy.go b/apis/management/v1alpha1/zz_generated.deepcopy.go index c085f7439..6351d9926 100644 --- a/apis/management/v1alpha1/zz_generated.deepcopy.go +++ b/apis/management/v1alpha1/zz_generated.deepcopy.go @@ -133,6 +133,22 @@ func (in *ProjectQuotaStatus) DeepCopy() *ProjectQuotaStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *QuotaStatus) DeepCopyInto(out *QuotaStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QuotaStatus. +func (in *QuotaStatus) DeepCopy() *QuotaStatus { + if in == nil { + return nil + } + out := new(QuotaStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceQuotaSpec) DeepCopyInto(out *ResourceQuotaSpec) { *out = *in @@ -160,6 +176,7 @@ func (in *ResourceQuotaSpec) DeepCopy() *ResourceQuotaSpec { func (in *ResourceQuotaStatus) DeepCopyInto(out *ResourceQuotaStatus) { *out = *in in.ResourceQuotaSpec.DeepCopyInto(&out.ResourceQuotaSpec) + out.QuotaStatus = in.QuotaStatus if in.Used != nil { in, out := &in.Used, &out.Used *out = make(v1.ResourceList, len(*in)) diff --git a/apis/meta/v1alpha1/zz_generated.deepcopy.go b/apis/meta/v1alpha1/zz_generated.deepcopy.go index 33ebeddbb..e74b1e168 100644 --- a/apis/meta/v1alpha1/zz_generated.deepcopy.go +++ b/apis/meta/v1alpha1/zz_generated.deepcopy.go @@ -22,16 +22,15 @@ limitations under the License. package v1alpha1 import ( - apiv1 "kmodules.xyz/client-go/api/v1" - shared "kmodules.xyz/resource-metadata/apis/shared" - api "kmodules.xyz/resource-metrics/api" - corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" resource "k8s.io/apimachinery/pkg/api/resource" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime "k8s.io/apimachinery/pkg/runtime" + apiv1 "kmodules.xyz/client-go/api/v1" + shared "kmodules.xyz/resource-metadata/apis/shared" + api "kmodules.xyz/resource-metrics/api" chartsv1alpha1 "x-helm.dev/apimachinery/apis/charts/v1alpha1" apisshared "x-helm.dev/apimachinery/apis/shared" ) diff --git a/apis/ui/v1alpha1/zz_generated.deepcopy.go b/apis/ui/v1alpha1/zz_generated.deepcopy.go index 84acea50b..230009269 100644 --- a/apis/ui/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ui/v1alpha1/zz_generated.deepcopy.go @@ -22,11 +22,10 @@ limitations under the License. package v1alpha1 import ( - apisshared "kmodules.xyz/resource-metadata/apis/shared" - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" + apisshared "kmodules.xyz/resource-metadata/apis/shared" releasesv1alpha1 "x-helm.dev/apimachinery/apis/releases/v1alpha1" shared "x-helm.dev/apimachinery/apis/shared" ) diff --git a/crds/management.k8s.appscode.com_projectquotas.yaml b/crds/management.k8s.appscode.com_projectquotas.yaml index e1a3fc7f5..a2eec65e4 100644 --- a/crds/management.k8s.appscode.com_projectquotas.yaml +++ b/crds/management.k8s.appscode.com_projectquotas.yaml @@ -81,11 +81,18 @@ spec: type: object kind: type: string - result: - enum: - - Success - - Error - type: string + quotaStatus: + properties: + reason: + type: string + result: + enum: + - Success + - Error + type: string + required: + - result + type: object used: additionalProperties: anyOf: @@ -97,7 +104,7 @@ spec: resource in the namespace. type: object required: - - result + - quotaStatus type: object type: array required: From 6c18693c3cbd1fe01e1bd09dd38959d578de8a3e Mon Sep 17 00:00:00 2001 From: Imtiaz Uddin Date: Thu, 5 Oct 2023 09:38:01 +0600 Subject: [PATCH 2/2] Change quota status api Signed-off-by: Imtiaz Uddin --- apis/core/v1alpha1/zz_generated.deepcopy.go | 7 +-- apis/management/v1alpha1/openapi_generated.go | 44 +++++-------------- .../management/v1alpha1/projectquota_types.go | 9 ++-- .../v1alpha1/zz_generated.deepcopy.go | 17 ------- apis/meta/v1alpha1/zz_generated.deepcopy.go | 7 +-- apis/ui/v1alpha1/zz_generated.deepcopy.go | 3 +- ...gement.k8s.appscode.com_projectquotas.yaml | 21 ++++----- 7 files changed, 33 insertions(+), 75 deletions(-) diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index f7b596305..c6672a102 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -22,14 +22,15 @@ limitations under the License. package v1alpha1 import ( + apiv1 "kmodules.xyz/client-go/api/v1" + shared "kmodules.xyz/resource-metadata/apis/shared" + api "kmodules.xyz/resource-metrics/api" + v1 "k8s.io/api/core/v1" resource "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" version "k8s.io/apimachinery/pkg/version" - apiv1 "kmodules.xyz/client-go/api/v1" - shared "kmodules.xyz/resource-metadata/apis/shared" - api "kmodules.xyz/resource-metrics/api" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/apis/management/v1alpha1/openapi_generated.go b/apis/management/v1alpha1/openapi_generated.go index 1aa66837b..63830c301 100644 --- a/apis/management/v1alpha1/openapi_generated.go +++ b/apis/management/v1alpha1/openapi_generated.go @@ -301,7 +301,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ProjectQuotaList": schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaList(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ProjectQuotaSpec": schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaSpec(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ProjectQuotaStatus": schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaStatus(ref), - "kmodules.xyz/resource-metadata/apis/management/v1alpha1.QuotaStatus": schema_resource_metadata_apis_management_v1alpha1_QuotaStatus(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ResourceQuotaSpec": schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaSpec(ref), "kmodules.xyz/resource-metadata/apis/management/v1alpha1.ResourceQuotaStatus": schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaStatus(ref), "kmodules.xyz/resource-metadata/apis/shared.Action": schema_kmodulesxyz_resource_metadata_apis_shared_Action(ref), @@ -14733,32 +14732,6 @@ func schema_resource_metadata_apis_management_v1alpha1_ProjectQuotaStatus(ref co } } -func schema_resource_metadata_apis_management_v1alpha1_QuotaStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "result": { - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "reason": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"result"}, - }, - }, - } -} - func schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -14833,10 +14806,17 @@ func schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaStatus(ref c }, }, }, - "quotaStatus": { + "result": { SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("kmodules.xyz/resource-metadata/apis/management/v1alpha1.QuotaStatus"), + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", }, }, "used": { @@ -14855,11 +14835,11 @@ func schema_resource_metadata_apis_management_v1alpha1_ResourceQuotaStatus(ref c }, }, }, - Required: []string{"quotaStatus"}, + Required: []string{"result"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/api/resource.Quantity", "kmodules.xyz/resource-metadata/apis/management/v1alpha1.QuotaStatus"}, + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, } } diff --git a/apis/management/v1alpha1/projectquota_types.go b/apis/management/v1alpha1/projectquota_types.go index b82b13558..b9d08ae26 100644 --- a/apis/management/v1alpha1/projectquota_types.go +++ b/apis/management/v1alpha1/projectquota_types.go @@ -65,18 +65,15 @@ type ProjectQuotaStatus struct { type ResourceQuotaStatus struct { ResourceQuotaSpec `json:",inline"` - QuotaStatus QuotaStatus `json:"quotaStatus"` + Result QuotaResult `json:"result"` + // +optional + Reason string `json:"reason,omitempty"` // Used is the current observed total usage of the resource in the namespace. // +optional Used core.ResourceList `json:"used,omitempty"` } -type QuotaStatus struct { - Result QuotaResult `json:"result"` - Reason string `json:"reason,omitempty"` -} - // +kubebuilder:validation:Enum=Success;Error type QuotaResult string diff --git a/apis/management/v1alpha1/zz_generated.deepcopy.go b/apis/management/v1alpha1/zz_generated.deepcopy.go index 6351d9926..c085f7439 100644 --- a/apis/management/v1alpha1/zz_generated.deepcopy.go +++ b/apis/management/v1alpha1/zz_generated.deepcopy.go @@ -133,22 +133,6 @@ func (in *ProjectQuotaStatus) DeepCopy() *ProjectQuotaStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *QuotaStatus) DeepCopyInto(out *QuotaStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QuotaStatus. -func (in *QuotaStatus) DeepCopy() *QuotaStatus { - if in == nil { - return nil - } - out := new(QuotaStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceQuotaSpec) DeepCopyInto(out *ResourceQuotaSpec) { *out = *in @@ -176,7 +160,6 @@ func (in *ResourceQuotaSpec) DeepCopy() *ResourceQuotaSpec { func (in *ResourceQuotaStatus) DeepCopyInto(out *ResourceQuotaStatus) { *out = *in in.ResourceQuotaSpec.DeepCopyInto(&out.ResourceQuotaSpec) - out.QuotaStatus = in.QuotaStatus if in.Used != nil { in, out := &in.Used, &out.Used *out = make(v1.ResourceList, len(*in)) diff --git a/apis/meta/v1alpha1/zz_generated.deepcopy.go b/apis/meta/v1alpha1/zz_generated.deepcopy.go index e74b1e168..33ebeddbb 100644 --- a/apis/meta/v1alpha1/zz_generated.deepcopy.go +++ b/apis/meta/v1alpha1/zz_generated.deepcopy.go @@ -22,15 +22,16 @@ limitations under the License. package v1alpha1 import ( + apiv1 "kmodules.xyz/client-go/api/v1" + shared "kmodules.xyz/resource-metadata/apis/shared" + api "kmodules.xyz/resource-metrics/api" + corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" resource "k8s.io/apimachinery/pkg/api/resource" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime "k8s.io/apimachinery/pkg/runtime" - apiv1 "kmodules.xyz/client-go/api/v1" - shared "kmodules.xyz/resource-metadata/apis/shared" - api "kmodules.xyz/resource-metrics/api" chartsv1alpha1 "x-helm.dev/apimachinery/apis/charts/v1alpha1" apisshared "x-helm.dev/apimachinery/apis/shared" ) diff --git a/apis/ui/v1alpha1/zz_generated.deepcopy.go b/apis/ui/v1alpha1/zz_generated.deepcopy.go index 230009269..84acea50b 100644 --- a/apis/ui/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ui/v1alpha1/zz_generated.deepcopy.go @@ -22,10 +22,11 @@ limitations under the License. package v1alpha1 import ( + apisshared "kmodules.xyz/resource-metadata/apis/shared" + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" - apisshared "kmodules.xyz/resource-metadata/apis/shared" releasesv1alpha1 "x-helm.dev/apimachinery/apis/releases/v1alpha1" shared "x-helm.dev/apimachinery/apis/shared" ) diff --git a/crds/management.k8s.appscode.com_projectquotas.yaml b/crds/management.k8s.appscode.com_projectquotas.yaml index a2eec65e4..d516eaf66 100644 --- a/crds/management.k8s.appscode.com_projectquotas.yaml +++ b/crds/management.k8s.appscode.com_projectquotas.yaml @@ -81,18 +81,13 @@ spec: type: object kind: type: string - quotaStatus: - properties: - reason: - type: string - result: - enum: - - Success - - Error - type: string - required: - - result - type: object + reason: + type: string + result: + enum: + - Success + - Error + type: string used: additionalProperties: anyOf: @@ -104,7 +99,7 @@ spec: resource in the namespace. type: object required: - - quotaStatus + - result type: object type: array required: