Skip to content

Commit

Permalink
Revise resource calculator api to support edit mode
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 45b3cbc commit f8921a1
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 4 deletions.
30 changes: 28 additions & 2 deletions apis/meta/v1alpha1/openapi_generated.go

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

7 changes: 6 additions & 1 deletion apis/meta/v1alpha1/resourcecalculator_types.go
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
23 changes: 22 additions & 1 deletion apis/meta/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions crds/meta.k8s.appscode.com_resourcecalculators.yaml
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

0 comments on commit f8921a1

Please sign in to comment.