Skip to content

Commit

Permalink
Update resource calculator api
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 23, 2023
1 parent 0d19b9e commit b2424d4
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/meta/resourcecalculator/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ spec:
- sourceRef
- version
type: object
enforceQuota:
type: boolean
flow:
type: string
icons:
Expand All @@ -1137,6 +1139,7 @@ spec:
operationId:
type: string
required:
- enforceQuota
- flow
- operationId
type: object
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1208,6 +1213,8 @@ spec:
- sourceRef
- version
type: object
required:
- enforceQuota
type: object
required:
- defaultLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ spec:
- sourceRef
- version
type: object
enforceQuota:
type: boolean
flow:
type: string
icons:
Expand All @@ -109,6 +111,7 @@ spec:
operationId:
type: string
required:
- enforceQuota
- flow
- operationId
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ spec:
- sourceRef
- version
type: object
enforceQuota:
type: boolean
flow:
type: string
icons:
Expand All @@ -180,6 +182,7 @@ spec:
operationId:
type: string
required:
- enforceQuota
- flow
- operationId
type: object
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -251,6 +256,8 @@ spec:
- sourceRef
- version
type: object
required:
- enforceQuota
type: object
variants:
description: Kind == VendorChartPreset | ClusterChartPreset
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2424d4

Please sign in to comment.