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"
This commit manually creates the openAPIV3Schema generated
by operator-sdk crd API.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Sep 2, 2020
1 parent d1a6abc commit 5a87814
Showing 1 changed file with 144 additions and 7 deletions.
151 changes: 144 additions & 7 deletions pkg/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,22 +371,159 @@ 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: "Plugin that manages MAC allocation to Pods and VMs in Kubernetes",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"rangeEnd": extv1.JSONSchemaProps{
Description: "Defines the first mac in range",
Type: "string",
},
"rangeStart": extv1.JSONSchemaProps{
Description: "Defines the last mac in range",
Type: "string",
},
},
},
"linuxBridge": extv1.JSONSchemaProps{
Description: "Plugin that allows users to create a bridge and add the host and the container to it",
Type: "object",
},
"macvtap": extv1.JSONSchemaProps{
Description: "Plugin that allows users to define Kubernetes networks on top of existing host interfaces",
Type: "object",
},
"multus": extv1.JSONSchemaProps{
Description: "Plugin that enables attaching multiple network interfaces to Pods in Kubernetes",
Type: "object",
},
"nmstate": extv1.JSONSchemaProps{
Description: "Declarative node network configuration driven through Kubernetes API",
Type: "object",
},
"ovs": extv1.JSONSchemaProps{
Description: "Plugin that allows users to define Kubernetes networks on top of Open vSwitch bridges available on nodes",
Type: "object",
},
"selfSignConfiguration": extv1.JSONSchemaProps{
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"caRotateInterval": extv1.JSONSchemaProps{
Description: "Defines duration for CA and certificate",
Type: "string",
},
"certRotateInterval": extv1.JSONSchemaProps{
Description: "Defines duration for of service certificate",
Type: "string",
},
"caOverlapInterval": extv1.JSONSchemaProps{
Description: "Defines the duration of CA Certificates at CABundle if not set it will default to CARotateInterval",
Type: "string",
},
},
},
},
},
"status": extv1.JSONSchemaProps{
Type: "object",
Description: "NetworkAddonsConfigStatus defines the observed state of NetworkAddonsConfig",
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{
"conditions": extv1.JSONSchemaProps{
Type: "array",
Items: &extv1.JSONSchemaPropsOrArray{
Schema: &extv1.JSONSchemaProps{
Description: "Condition represents the state of the operator's reconciliation functionality",
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",
},
Type: "object",
},
},
},
"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 Expand Up @@ -416,13 +553,13 @@ func GetCrd() *extv1.CustomResourceDefinition {
Name: "v1",
Served: true,
Storage: true,
Schema: validationSchema,
Schema: validationSchema,
},
{
Name: "v1alpha1",
Served: true,
Storage: false,
Schema: validationSchema,
Schema: validationSchema,
},
},
},
Expand Down

0 comments on commit 5a87814

Please sign in to comment.