Skip to content

Commit

Permalink
add openAPIV3Schema validation parameters
Browse files Browse the repository at this point in the history
Let's add openAPIV3Schema detail for "kubectl explain crd"
Since operator-sdk crd cannot run. this commit manually creates the openAPIV3Schema
that should've been generated by operator-sdk crd API.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Sep 6, 2020
1 parent 6a2c34c commit d7b29f8
Showing 1 changed file with 157 additions and 5 deletions.
162 changes: 157 additions & 5 deletions pkg/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,174 @@ func GetClusterRole() *rbacv1.ClusterRole {
func GetCrd() *extv1.CustomResourceDefinition {
validationSchema := &extv1.CustomResourceValidation{
OpenAPIV3Schema: &extv1.JSONSchemaProps{
Type: "object",
Description: "NetworkAddonsConfig is the Schema for the networkaddonsconfigs API",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"apiVersion": extv1.JSONSchemaProps{
Type: "string",
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": extv1.JSONSchemaProps{
Type: "string",
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": extv1.JSONSchemaProps{
Type: "object",
},
"spec": extv1.JSONSchemaProps{
Type: "object",
Description: "NetworkAddonsConfigSpec defines the desired state of NetworkAddonsConfig",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"imagePullPolicy": extv1.JSONSchemaProps{
Description: "PullPolicy describes a policy for if/when to pull a container image",
Type: "string",
},
"kubeMacPool": extv1.JSONSchemaProps{
Description: "KubeMacPool plugin manages MAC allocation to Pods and VMs in Kubernetes",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"rangeEnd": extv1.JSONSchemaProps{
Description: "Defines the last mac in range",
Type: "string",
},
"rangeStart": extv1.JSONSchemaProps{
Description: "Defines the first mac in range",
Type: "string",
},
},
},
"linuxBridge": extv1.JSONSchemaProps{
Description: "LinuxBridge plugin allows users to create a bridge and add the host and the container to it",
Type: "object",
},
"macvtap": extv1.JSONSchemaProps{
Description: "MacvtapCni plugin allows users to define Kubernetes networks on top of existing host interfaces",
Type: "object",
},
"multus": extv1.JSONSchemaProps{
Description: "Multus plugin enables attaching multiple network interfaces to Pods in Kubernetes",
Type: "object",
},
"nmstate": extv1.JSONSchemaProps{
Description: "NMState is a declarative node network configuration driven through Kubernetes API",
Type: "object",
},
"ovs": extv1.JSONSchemaProps{
Description: "Ovs plugin allows users to define Kubernetes networks on top of Open vSwitch bridges available on nodes",
Type: "object",
},
"selfSignConfiguration": extv1.JSONSchemaProps{
Description: "SelfSignConfiguration defines self sign configuration",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"caRotateInterval": extv1.JSONSchemaProps{
Description: "CARotateInterval defines duration for CA and certificate",
Type: "string",
},
"certRotateInterval": extv1.JSONSchemaProps{
Description: "CertRotateInterval defines duration for of service certificate",
Type: "string",
},
"caOverlapInterval": extv1.JSONSchemaProps{
Description: "CAOverlapInterval defines the duration of CA Certificates at CABundle if not set it will default to CARotateInterval",
Type: "string",
},
},
},
"PlacementConfiguration": extv1.JSONSchemaProps{
Description: "PlacementConfiguration defines node placement configuration",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"Infra": extv1.JSONSchemaProps{
Description: "Infra defines placement configuration for master nodes",
Type: "object",
},
"Workloads": extv1.JSONSchemaProps{
Description: "Workloads defines placement configuration for worker nodes",
Type: "object",
},
},
},
},
},
"status": extv1.JSONSchemaProps{
Type: "object",
Description: "NetworkAddonsConfigStatus defines the observed state of NetworkAddonsConfig",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"conditions": extv1.JSONSchemaProps{
//Description: "Condition represents the state of the operator's reconciliation functionality.",
Type: "array",
Items: &extv1.JSONSchemaPropsOrArray{
Schema: &extv1.JSONSchemaProps{
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"lastHeartbeatTime": extv1.JSONSchemaProps{
Format: "date-time",
Type: "string",
},
"lastTransitionTime": extv1.JSONSchemaProps{
Format: "date-time",
Type: "string",
},
"message": extv1.JSONSchemaProps{
Type: "string",
},
"reason": extv1.JSONSchemaProps{
Type: "string",
},
"status": extv1.JSONSchemaProps{
Type: "string",
},
"type": extv1.JSONSchemaProps{
Description: "ConditionType is the state of the operator's reconciliation functionality.",
Type: "string",
},
},
Required: []string{
"status",
"type",
},
},
},
},
"containers": extv1.JSONSchemaProps{
Type: "array",
Items: &extv1.JSONSchemaPropsOrArray{
Schema: &extv1.JSONSchemaProps{
Properties: map[string]extv1.JSONSchemaProps{
"image": extv1.JSONSchemaProps{
Type: "string",
},
"name": extv1.JSONSchemaProps{
Type: "string",
},
"parentKind": extv1.JSONSchemaProps{
Type: "string",
},
"parentName": extv1.JSONSchemaProps{
Type: "string",
},
},
Required: []string{
"image",
"name",
"parentKind",
"parentName",
},
Type: "object",
},
},
},
"observedVersion": extv1.JSONSchemaProps{
Type: "string",
},
"operatorVersion": extv1.JSONSchemaProps{
Type: "string",
},
"targetVersion": extv1.JSONSchemaProps{
Type: "string",
},
},
},
},
},
Expand Down

0 comments on commit d7b29f8

Please sign in to comment.