From b2424d45d43fe2777257a42e41f5346970c634fb Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Mon, 23 Oct 2023 05:48:31 -0700 Subject: [PATCH] Update resource calculator api Signed-off-by: Tamal Saha --- go.mod | 2 +- go.sum | 4 +- .../meta/resourcecalculator/storage.go | 2 +- .../apis/meta/v1alpha1/openapi_generated.go | 30 +++++++- .../meta/v1alpha1/resourcecalculator_types.go | 7 +- .../meta/v1alpha1/zz_generated.deepcopy.go | 23 +++++- ....k8s.appscode.com_resourcecalculators.yaml | 6 ++ .../v1alpha1/clusterstatuses.yaml | 72 +++++++++++++++++++ .../v1alpha1/resourcecalculators.yaml | 6 ++ .../v1alpha1/resourcelayouts.yaml | 7 ++ .../v1alpha1/resourceoutlines.yaml | 3 + .../v1alpha1/resourceeditors.yaml | 7 ++ .../v1alpha1/clusterstatuses.yaml | 17 +++++ .../v1alpha1/clusterstatuses.yaml | 18 +++++ vendor/modules.txt | 2 +- 15 files changed, 197 insertions(+), 9 deletions(-) create mode 100644 vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml create mode 100644 vendor/kmodules.xyz/resource-metadata/hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml create mode 100644 vendor/kmodules.xyz/resource-metadata/hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml diff --git a/go.mod b/go.mod index 08511ad98..fc4401640 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( kmodules.xyz/custom-resources v0.25.2 kmodules.xyz/go-containerregistry v0.0.11 kmodules.xyz/monitoring-agent-api v0.25.4 - kmodules.xyz/resource-metadata v0.17.28-0.20231023060303-45b3cbc5fa91 + kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce kmodules.xyz/resource-metrics v0.25.5 kmodules.xyz/sets v0.25.0 kubeops.dev/scanner v0.0.15 diff --git a/go.sum b/go.sum index a0c7154fe..5955681a7 100644 --- a/go.sum +++ b/go.sum @@ -2151,8 +2151,8 @@ kmodules.xyz/monitoring-agent-api v0.25.4 h1:OwkvtV23QhUy3f7o9lxPWaAW3jiJMGAMPPR kmodules.xyz/monitoring-agent-api v0.25.4/go.mod h1:3LhrLDGQKQXhxYcjA/WNaO4HPpopYQzOutsEp2i3008= kmodules.xyz/offshoot-api v0.25.4 h1:IjJNvkphcdYUG8XO/pBwXpuP8W+jxAWJZ3yH8vgI/as= kmodules.xyz/offshoot-api v0.25.4/go.mod h1:PUk4EuJFhhyQykCflHj7EgXcljGIqs9vi0IN0RpxtY4= -kmodules.xyz/resource-metadata v0.17.28-0.20231023060303-45b3cbc5fa91 h1:KopnF9KtGR1u5iQIVByhvX0kFHf0mYhaa6yuz9AsLmc= -kmodules.xyz/resource-metadata v0.17.28-0.20231023060303-45b3cbc5fa91/go.mod h1:4m4L4/EJ3XasyrN5KFHRJDrWd27WNREeuc3alUKUJ9E= +kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce h1:04+H7IhbihQSxDSoRkD11Hv9tRBZPRJxBKjVZzspRsc= +kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce/go.mod h1:4m4L4/EJ3XasyrN5KFHRJDrWd27WNREeuc3alUKUJ9E= kmodules.xyz/resource-metrics v0.25.5 h1:hQu6r2VtkmeiO7tpR5uYDWj7u7mKloaGZ1j8dH30b24= kmodules.xyz/resource-metrics v0.25.5/go.mod h1:y7pDmTWuVLNGSjwckKCwJFhCgi5fhbwS7PAcH2rmGcY= kmodules.xyz/sets v0.25.0 h1:belY/3trp/M/CKc1TEteA40jb2uCIdwKHhjpvrIxG+8= diff --git a/pkg/registry/meta/resourcecalculator/storage.go b/pkg/registry/meta/resourcecalculator/storage.go index ff9cb27a6..34acc406e 100644 --- a/pkg/registry/meta/resourcecalculator/storage.go +++ b/pkg/registry/meta/resourcecalculator/storage.go @@ -82,7 +82,7 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, createValidati } var u unstructured.Unstructured - err := json.Unmarshal(in.Request.Raw, &u) + err := json.Unmarshal(in.Request.Resource.Raw, &u) if err != nil { return nil, apierrors.NewInternalError(err) } diff --git a/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/openapi_generated.go b/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/openapi_generated.go index ef8712248..19ab7a1c1 100644 --- a/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/openapi_generated.go +++ b/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/openapi_generated.go @@ -349,6 +349,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceBlockDefinitionList": schema_resource_metadata_apis_meta_v1alpha1_ResourceBlockDefinitionList(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceBlockDefinitionSpec": schema_resource_metadata_apis_meta_v1alpha1_ResourceBlockDefinitionSpec(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculator": schema_resource_metadata_apis_meta_v1alpha1_ResourceCalculator(ref), + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculatorRequest": schema_resource_metadata_apis_meta_v1alpha1_ResourceCalculatorRequest(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculatorResponse": schema_resource_metadata_apis_meta_v1alpha1_ResourceCalculatorResponse(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceColumn": schema_resource_metadata_apis_meta_v1alpha1_ResourceColumn(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceColumnDefinition": schema_resource_metadata_apis_meta_v1alpha1_ResourceColumnDefinition(ref), @@ -16825,7 +16826,7 @@ func schema_resource_metadata_apis_meta_v1alpha1_ResourceCalculator(ref common.R }, "request": { SchemaProps: spec.SchemaProps{ - Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + Ref: ref("kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculatorRequest"), }, }, "response": { @@ -16837,7 +16838,32 @@ func schema_resource_metadata_apis_meta_v1alpha1_ResourceCalculator(ref common.R }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/apimachinery/pkg/runtime.RawExtension", "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculatorResponse"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculatorRequest", "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceCalculatorResponse"}, + } +} + +func schema_resource_metadata_apis_meta_v1alpha1_ResourceCalculatorRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "resource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "edit": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.RawExtension"}, } } diff --git a/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/resourcecalculator_types.go b/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/resourcecalculator_types.go index 71d83901a..1016d0fcb 100644 --- a/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/resourcecalculator_types.go +++ b/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/resourcecalculator_types.go @@ -42,11 +42,16 @@ type ResourceCalculator struct { metav1.ObjectMeta `json:"metadata,omitempty"` // +kubebuilder:pruning:PreserveUnknownFields - Request *runtime.RawExtension `json:"request,omitempty"` + Request *ResourceCalculatorRequest `json:"request,omitempty"` // +optional Response *ResourceCalculatorResponse `json:"response,omitempty"` } +type ResourceCalculatorRequest struct { + Resource *runtime.RawExtension `json:"resource,omitempty"` + Edit bool `json:"edit,omitempty"` +} + type ResourceCalculatorResponse struct { APIType kmapi.ResourceID `json:"apiType"` // +optional diff --git a/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/zz_generated.deepcopy.go b/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/zz_generated.deepcopy.go index 18bbd6505..ea118ddc0 100644 --- a/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/kmodules.xyz/resource-metadata/apis/meta/v1alpha1/zz_generated.deepcopy.go @@ -1332,7 +1332,7 @@ func (in *ResourceCalculator) DeepCopyInto(out *ResourceCalculator) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) if in.Request != nil { in, out := &in.Request, &out.Request - *out = new(runtime.RawExtension) + *out = new(ResourceCalculatorRequest) (*in).DeepCopyInto(*out) } if in.Response != nil { @@ -1361,6 +1361,27 @@ func (in *ResourceCalculator) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceCalculatorRequest) DeepCopyInto(out *ResourceCalculatorRequest) { + *out = *in + if in.Resource != nil { + in, out := &in.Resource, &out.Resource + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceCalculatorRequest. +func (in *ResourceCalculatorRequest) DeepCopy() *ResourceCalculatorRequest { + if in == nil { + return nil + } + out := new(ResourceCalculatorRequest) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceCalculatorResponse) DeepCopyInto(out *ResourceCalculatorResponse) { *out = *in diff --git a/vendor/kmodules.xyz/resource-metadata/crds/meta.k8s.appscode.com_resourcecalculators.yaml b/vendor/kmodules.xyz/resource-metadata/crds/meta.k8s.appscode.com_resourcecalculators.yaml index 2a796bd9f..a6d14ba8b 100644 --- a/vendor/kmodules.xyz/resource-metadata/crds/meta.k8s.appscode.com_resourcecalculators.yaml +++ b/vendor/kmodules.xyz/resource-metadata/crds/meta.k8s.appscode.com_resourcecalculators.yaml @@ -31,6 +31,12 @@ spec: metadata: type: object request: + properties: + edit: + type: boolean + resource: + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true response: diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml new file mode 100644 index 000000000..7cde9c868 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml @@ -0,0 +1,72 @@ +apiVersion: meta.k8s.appscode.com/v1alpha1 +kind: ResourceDescriptor +metadata: + creationTimestamp: null + labels: + k8s.io/group: meta.k8s.appscode.com + k8s.io/kind: ClusterStatus + k8s.io/resource: clusterstatuses + k8s.io/version: v1alpha1 + name: meta.k8s.appscode.com-v1alpha1-clusterstatuses +spec: + resource: + group: meta.k8s.appscode.com + kind: ClusterStatus + name: clusterstatuses + scope: Namespaced + version: v1alpha1 + validation: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + properties: + name: + description: 'Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + namespace: + description: "Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. \n Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces" + type: string + labels: + additionalProperties: + type: string + description: 'Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels' + type: object + annotations: + additionalProperties: + type: string + description: 'Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations' + type: object + type: object + response: + properties: + clusterAPI: + description: ClusterAPI contains capi cluster information if the cluster is created by cluster-api + properties: + clusterName: + type: string + namespace: + type: string + provider: + type: string + type: object + clusterManagers: + items: + type: string + type: array + message: + description: Message specifies additional information regarding the possible actions for the user + type: string + phase: + description: Phase represents current status of the cluster + type: string + reason: + description: Reason explains the reason behind the cluster current phase + type: string + type: object + type: object diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcecalculators.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcecalculators.yaml index 93bf27eca..babfd2c95 100644 --- a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcecalculators.yaml +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcecalculators.yaml @@ -44,6 +44,12 @@ spec: type: object type: object request: + properties: + edit: + type: boolean + resource: + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true response: diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcelayouts.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcelayouts.yaml index 695b27786..62eaff782 100644 --- a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcelayouts.yaml +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourcelayouts.yaml @@ -1113,6 +1113,8 @@ spec: - sourceRef - version type: object + enforceQuota: + type: boolean flow: type: string icons: @@ -1137,6 +1139,7 @@ spec: operationId: type: string required: + - enforceQuota - flow - operationId type: object @@ -1175,6 +1178,8 @@ spec: - sourceRef - version type: object + enforceQuota: + type: boolean instanceLabelPaths: description: app.kubernetes.io/instance label must be updated at these paths when refilling metadata items: @@ -1208,6 +1213,8 @@ spec: - sourceRef - version type: object + required: + - enforceQuota type: object required: - defaultLayout diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourceoutlines.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourceoutlines.yaml index 1cb23ec5d..52426bed8 100644 --- a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourceoutlines.yaml +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/meta.k8s.appscode.com/v1alpha1/resourceoutlines.yaml @@ -85,6 +85,8 @@ spec: - sourceRef - version type: object + enforceQuota: + type: boolean flow: type: string icons: @@ -109,6 +111,7 @@ spec: operationId: type: string required: + - enforceQuota - flow - operationId type: object diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/ui.k8s.appscode.com/v1alpha1/resourceeditors.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/ui.k8s.appscode.com/v1alpha1/resourceeditors.yaml index 9b2abe992..40b9450f5 100644 --- a/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/ui.k8s.appscode.com/v1alpha1/resourceeditors.yaml +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourcedescriptors/ui.k8s.appscode.com/v1alpha1/resourceeditors.yaml @@ -156,6 +156,8 @@ spec: - sourceRef - version type: object + enforceQuota: + type: boolean flow: type: string icons: @@ -180,6 +182,7 @@ spec: operationId: type: string required: + - enforceQuota - flow - operationId type: object @@ -218,6 +221,8 @@ spec: - sourceRef - version type: object + enforceQuota: + type: boolean instanceLabelPaths: description: app.kubernetes.io/instance label must be updated at these paths when refilling metadata items: @@ -251,6 +256,8 @@ spec: - sourceRef - version type: object + required: + - enforceQuota type: object variants: description: Kind == VendorChartPreset | ClusterChartPreset diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml new file mode 100644 index 000000000..87f122bc6 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourceeditors/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml @@ -0,0 +1,17 @@ +apiVersion: ui.k8s.appscode.com/v1alpha1 +kind: ResourceEditor +metadata: + creationTimestamp: null + labels: + k8s.io/group: meta.k8s.appscode.com + k8s.io/kind: ClusterStatus + k8s.io/resource: clusterstatuses + k8s.io/version: v1alpha1 + name: meta.k8s.appscode.com-v1alpha1-clusterstatuses +spec: + resource: + group: meta.k8s.appscode.com + kind: ClusterStatus + name: clusterstatuses + scope: Namespaced + version: v1alpha1 diff --git a/vendor/kmodules.xyz/resource-metadata/hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml b/vendor/kmodules.xyz/resource-metadata/hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml new file mode 100644 index 000000000..78722bb9f --- /dev/null +++ b/vendor/kmodules.xyz/resource-metadata/hub/resourcetabledefinitions/meta.k8s.appscode.com/v1alpha1/clusterstatuses.yaml @@ -0,0 +1,18 @@ +apiVersion: meta.k8s.appscode.com/v1alpha1 +kind: ResourceTableDefinition +metadata: + creationTimestamp: null + labels: + k8s.io/group: meta.k8s.appscode.com + k8s.io/kind: ClusterStatus + k8s.io/resource: clusterstatuses + k8s.io/version: v1alpha1 + name: meta.k8s.appscode.com-v1alpha1-clusterstatuses +spec: + defaultView: true + resource: + group: meta.k8s.appscode.com + kind: ClusterStatus + name: clusterstatuses + scope: Namespaced + version: v1alpha1 diff --git a/vendor/modules.txt b/vendor/modules.txt index a35e47eaa..27e0dfaf9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1839,7 +1839,7 @@ kmodules.xyz/monitoring-agent-api/client # kmodules.xyz/offshoot-api v0.25.4 ## explicit; go 1.18 kmodules.xyz/offshoot-api/api/v1 -# kmodules.xyz/resource-metadata v0.17.28-0.20231023060303-45b3cbc5fa91 +# kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce ## explicit; go 1.18 kmodules.xyz/resource-metadata/apis/core/install kmodules.xyz/resource-metadata/apis/core/v1alpha1