Skip to content

Commit

Permalink
Add script to run controller-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelSpeed committed Aug 4, 2021
1 parent 702c94f commit 8769284
Show file tree
Hide file tree
Showing 8 changed files with 1,067 additions and 818 deletions.
46 changes: 46 additions & 0 deletions hack/gen-crd.sh
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -eu

function annotate_crd() {
script1='/^ annotations:/a\
\ \ \ \ include.release.openshift.io/ibm-cloud-managed: "true"\
\ \ \ \ include.release.openshift.io/self-managed-high-availability: "true"\
\ \ \ \ include.release.openshift.io/single-node-developer: "true"\
\ \ \ labels:\
\ \ \ \ "openshift.io/operator-managed": ""'
script2='/^ controller-gen.kubebuilder.io\/version: (devel)/d'
input="${1}"
output="${2}"
sed -e "${script1}" -e "${script2}" "${input}" > "${output}"
}

echo "Building controller-gen tool..."
go build -o bin/controller-gen github.com/openshift/machine-config-operator/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen

dir=$(mktemp -d -t XXXXXXXX)
echo $dir
mkdir -p $dir/src/github.com/openshift/machine-config-operator/pkg/apis

cp -r pkg/apis/* $dir/src/github.com/openshift/machine-config-operator/pkg/apis
# Some dependencies need to be copied as well. Othwerwise, controller-gen will complain about non-existing kind Unsupported
cp -r vendor $dir/src/github.com/openshift/machine-config-operator/
cp go.mod go.sum $dir/src/github.com/openshift/machine-config-operator/

cwd=$(pwd)
pushd $dir/src/github.com/openshift/machine-config-operator
GOPATH=$dir ${cwd}/bin/controller-gen crd \
crd:crdVersions=v1 \
paths=$dir/src/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/... \
output:crd:dir=$dir/src/github.com/openshift/machine-config-operator/config/crds/

popd

echo "Copying and patching generated CRDs"
annotate_crd $dir/src/github.com/openshift/machine-config-operator/config/crds/machineconfiguration.openshift.io_containerruntimeconfigs.yaml install/0000_80_machine-config-operator_01_containerruntimeconfig.crd.yaml
annotate_crd $dir/src/github.com/openshift/machine-config-operator/config/crds/machineconfiguration.openshift.io_kubeletconfigs.yaml install/0000_80_machine-config-operator_01_kubeletconfig.crd.yaml
annotate_crd $dir/src/github.com/openshift/machine-config-operator/config/crds/machineconfiguration.openshift.io_machineconfigs.yaml install/0000_80_machine-config-operator_01_machineconfig.crd.yaml
annotate_crd $dir/src/github.com/openshift/machine-config-operator/config/crds/machineconfiguration.openshift.io_machineconfigpools.yaml install/0000_80_machine-config-operator_01_machineconfigpool.crd.yaml
annotate_crd $dir/src/github.com/openshift/machine-config-operator/config/crds/machineconfiguration.openshift.io_controllerconfigs.yaml manifests/controllerconfig.crd.yaml

rm -rf $dir
@@ -1,36 +1,32 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: containerruntimeconfigs.machineconfiguration.openshift.io
labels:
"openshift.io/operator-managed": ""
annotations:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
labels:
"openshift.io/operator-managed": ""
creationTimestamp: null
name: containerruntimeconfigs.machineconfiguration.openshift.io
spec:
group: machineconfiguration.openshift.io
names:
kind: ContainerRuntimeConfig
listKind: ContainerRuntimeConfigList
plural: containerruntimeconfigs
singular: containerruntimeconfig
shortNames:
- ctrcfg
singular: containerruntimeconfig
scope: Cluster
versions:
- name: v1
served: true
storage: true
subresources:
status: {}
schema:
openAPIV3Schema:
description: ContainerRuntimeConfig describes a customized Container Runtime
configuration.
type: object
required:
- spec
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -46,108 +42,106 @@ spec:
type: object
spec:
description: ContainerRuntimeConfigSpec defines the desired state of ContainerRuntimeConfig
type: object
required:
- containerRuntimeConfig
properties:
containerRuntimeConfig:
description: ContainerRuntimeConfiguration defines the tuneables of
the container runtime. It's important to note that, since the fields
of the ContainerRuntimeConfiguration are directly read by the upstream
kubernetes golang client, the validation of those values is handled
directly by that golang client which is outside of the controller
for ContainerRuntimeConfiguration. Please ensure the valid values
are used for those fields as invalid values may render cluster nodes
unusable.
type: object
the container runtime
properties:
logLevel:
description: logLevel specifies the verbosity of the logs based
on the level it is set to. Options are fatal, panic, error, warn,
info, and debug.
on the level it is set to. Options are fatal, panic, error,
warn, info, and debug.
type: string
logSizeMax:
description: logSizeMax specifies the Maximum size allowed for the
container log file. Negative numbers indicate that no size limit
is imposed. If it is positive, it must be >= 8192 to match/exceed
anyOf:
- type: integer
- type: string
description: logSizeMax specifies the Maximum size allowed for
the container log file. Negative numbers indicate that no size
limit is imposed. If it is positive, it must be >= 8192 to match/exceed
conmon's read buffer.
type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
overlaySize:
anyOf:
- type: integer
- type: string
description: 'overlaySize specifies the maximum size of a container
image. This flag can be used to set quota on the size of container
images. (default: 10GB)'
type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
pidsLimit:
description: pidsLimit specifies the maximum number of processes
allowed in a container
type: integer
format: int64
type: integer
type: object
machineConfigPoolSelector:
description: A label selector is a label query over a set of resources.
The result of matchLabels and matchExpressions are ANDed. An empty
label selector matches all objects. A null label selector matches
no objects.
type: object
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
type: array
items:
description: A label selector requirement is a selector that contains
values, a key, and an operator that relates the key and values.
type: object
required:
- key
- operator
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to a
set of values. Valid operators are In, NotIn, Exists and
DoesNotExist.
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator
is In or NotIn, the values array must be non-empty. If the
operator is Exists or DoesNotExist, the values array must
be empty. This array is replaced during a strategic merge
patch.
type: array
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator is
"In", and the values array contains only "value". The requirements
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
additionalProperties:
type: string
type: object
type: object
status:
description: ContainerRuntimeConfigStatus defines the observed state of
a ContainerRuntimeConfig
type: object
properties:
conditions:
description: conditions represents the latest available observations
of current state.
type: array
items:
description: ContainerRuntimeConfigCondition defines the state of
the ContainerRuntimeConfig
type: object
properties:
lastTransitionTime:
description: lastTransitionTime is the time of the last update
to the current status object.
type: string
format: date-time
nullable: true
type: string
message:
description: message provides additional information about the
current condition. This is only to be consumed by humans.
Expand All @@ -163,8 +157,28 @@ spec:
description: type specifies the state of the operator's reconciliation
functionality.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
observedGeneration:
description: observedGeneration represents the generation observed by
the controller.
type: integer
description: observedGeneration represents the generation observed
by the controller.
format: int64
type: integer
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

0 comments on commit 8769284

Please sign in to comment.