From 141033e5c5c1ba45068c31c44deda26ef244bf88 Mon Sep 17 00:00:00 2001 From: Roberto Alfieri Date: Mon, 23 Oct 2023 16:23:19 +0200 Subject: [PATCH] Add v1beta1 api Signed-off-by: Roberto Alfieri --- PROJECT | 8 + ...eee.openstack.org_openstackansibleees.yaml | 1557 +++++++++++++++++ api/v1alpha1/openstackansibleee_webhook.go | 4 +- api/v1beta1/conditions.go | 47 + api/v1beta1/groupversion_info.go | 36 + api/v1beta1/openstackansibleee_types.go | 189 ++ api/v1beta1/openstackansibleee_webhook.go | 100 ++ api/v1beta1/webhook_suite_test.go | 132 ++ api/v1beta1/zz_generated.deepcopy.go | 218 +++ ...eee.openstack.org_openstackansibleees.yaml | 1557 +++++++++++++++++ config/crd/kustomization.yaml | 2 + .../cainjection_in_openstackansibleees.yaml | 7 + .../webhook_in_openstackansibleees.yaml | 16 + .../rbac/openstackansibleee_editor_role.yaml | 31 + .../rbac/openstackansibleee_viewer_role.yaml | 27 + config/samples/_v1beta1_ansibleee.yaml | 12 + config/samples/kustomization.yaml | 1 + config/webhook/manifests.yaml | 44 +- controllers/openstack_ansibleee_controller.go | 38 +- main.go | 3 + tests/functional/ansibleee_controller_test.go | 30 +- tests/functional/base_test.go | 10 +- tests/functional/suite_test.go | 4 +- .../tests/run_simple_playbook/01-assert.yaml | 66 +- .../01-run-hello-world.yaml | 2 +- .../tests/run_simple_playbook/02-cleanup.yaml | 2 +- .../run_simple_playbook_debug/01-assert.yaml | 66 +- .../01-run-debug.yaml | 2 +- .../run_simple_playbook_debug/02-cleanup.yaml | 2 +- .../01-assert.yaml | 78 +- .../01-run-debug.yaml | 2 +- .../02-cleanup.yaml | 2 +- 32 files changed, 4139 insertions(+), 156 deletions(-) create mode 100644 api/v1beta1/conditions.go create mode 100644 api/v1beta1/groupversion_info.go create mode 100644 api/v1beta1/openstackansibleee_types.go create mode 100644 api/v1beta1/openstackansibleee_webhook.go create mode 100644 api/v1beta1/webhook_suite_test.go create mode 100644 api/v1beta1/zz_generated.deepcopy.go create mode 100644 config/crd/patches/cainjection_in_openstackansibleees.yaml create mode 100644 config/crd/patches/webhook_in_openstackansibleees.yaml create mode 100644 config/rbac/openstackansibleee_editor_role.yaml create mode 100644 config/rbac/openstackansibleee_viewer_role.yaml create mode 100644 config/samples/_v1beta1_ansibleee.yaml diff --git a/PROJECT b/PROJECT index 65b7cf62..1185f310 100644 --- a/PROJECT +++ b/PROJECT @@ -20,4 +20,12 @@ resources: defaulting: true validation: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + domain: openstack.org + group: ansibleee + kind: OpenStackAnsibleEE + path: github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1beta1 + version: v1beta1 version: "3" diff --git a/api/bases/ansibleee.openstack.org_openstackansibleees.yaml b/api/bases/ansibleee.openstack.org_openstackansibleees.yaml index 450bc56f..5d8f52a8 100644 --- a/api/bases/ansibleee.openstack.org_openstackansibleees.yaml +++ b/api/bases/ansibleee.openstack.org_openstackansibleees.yaml @@ -1574,6 +1574,1563 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - description: NetworkAttachments + jsonPath: .spec.networkAttachments + name: NetworkAttachments + type: string + - description: Status + jsonPath: .status.conditions[0].status + name: Status + type: string + - description: Message + jsonPath: .status.conditions[0].message + name: Message + type: string + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + args: + items: + type: string + type: array + backoffLimit: + default: 6 + format: int32 + type: integer + cmdLine: + type: string + debug: + default: false + type: boolean + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envConfigMapName: + default: openstack-aee-default-env + type: string + extraMounts: + items: + properties: + extraVolType: + type: string + mounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + propagation: + items: + type: string + type: array + volumes: + items: + properties: + awsElasticBlockStore: + properties: + fsType: + type: string + partition: + format: int32 + type: integer + readOnly: + type: boolean + volumeID: + type: string + required: + - volumeID + type: object + azureDisk: + properties: + cachingMode: + type: string + diskName: + type: string + diskURI: + type: string + fsType: + type: string + kind: + type: string + readOnly: + type: boolean + required: + - diskName + - diskURI + type: object + azureFile: + properties: + readOnly: + type: boolean + secretName: + type: string + shareName: + type: string + required: + - secretName + - shareName + type: object + cephfs: + properties: + monitors: + items: + type: string + type: array + path: + type: string + readOnly: + type: boolean + secretFile: + type: string + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + user: + type: string + required: + - monitors + type: object + cinder: + properties: + fsType: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + volumeID: + type: string + required: + - volumeID + type: object + configMap: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + csi: + properties: + driver: + type: string + fsType: + type: string + nodePublishSecretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + readOnly: + type: boolean + volumeAttributes: + additionalProperties: + type: string + type: object + required: + - driver + type: object + downwardAPI: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + format: int32 + type: integer + path: + type: string + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + emptyDir: + properties: + medium: + type: string + sizeLimit: + anyOf: + - type: integer + - 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 + type: object + ephemeral: + properties: + volumeClaimTemplate: + properties: + metadata: + type: object + spec: + properties: + accessModes: + items: + type: string + type: array + dataSource: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + type: object + selector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + type: string + volumeMode: + type: string + volumeName: + type: string + type: object + required: + - spec + type: object + type: object + fc: + properties: + fsType: + type: string + lun: + format: int32 + type: integer + readOnly: + type: boolean + targetWWNs: + items: + type: string + type: array + wwids: + items: + type: string + type: array + type: object + flexVolume: + properties: + driver: + type: string + fsType: + type: string + options: + additionalProperties: + type: string + type: object + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + required: + - driver + type: object + flocker: + properties: + datasetName: + type: string + datasetUUID: + type: string + type: object + gcePersistentDisk: + properties: + fsType: + type: string + partition: + format: int32 + type: integer + pdName: + type: string + readOnly: + type: boolean + required: + - pdName + type: object + gitRepo: + properties: + directory: + type: string + repository: + type: string + revision: + type: string + required: + - repository + type: object + glusterfs: + properties: + endpoints: + type: string + path: + type: string + readOnly: + type: boolean + required: + - endpoints + - path + type: object + hostPath: + properties: + path: + type: string + type: + type: string + required: + - path + type: object + iscsi: + properties: + chapAuthDiscovery: + type: boolean + chapAuthSession: + type: boolean + fsType: + type: string + initiatorName: + type: string + iqn: + type: string + iscsiInterface: + type: string + lun: + format: int32 + type: integer + portals: + items: + type: string + type: array + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + targetPortal: + type: string + required: + - iqn + - lun + - targetPortal + type: object + name: + type: string + nfs: + properties: + path: + type: string + readOnly: + type: boolean + server: + type: string + required: + - path + - server + type: object + persistentVolumeClaim: + properties: + claimName: + type: string + readOnly: + type: boolean + required: + - claimName + type: object + photonPersistentDisk: + properties: + fsType: + type: string + pdID: + type: string + required: + - pdID + type: object + portworxVolume: + properties: + fsType: + type: string + readOnly: + type: boolean + volumeID: + type: string + required: + - volumeID + type: object + projected: + properties: + defaultMode: + format: int32 + type: integer + sources: + items: + properties: + configMap: + properties: + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + downwardAPI: + properties: + items: + items: + properties: + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + format: int32 + type: integer + path: + type: string + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + secret: + properties: + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + serviceAccountToken: + properties: + audience: + type: string + expirationSeconds: + format: int64 + type: integer + path: + type: string + required: + - path + type: object + type: object + type: array + type: object + quobyte: + properties: + group: + type: string + readOnly: + type: boolean + registry: + type: string + tenant: + type: string + user: + type: string + volume: + type: string + required: + - registry + - volume + type: object + rbd: + properties: + fsType: + type: string + image: + type: string + keyring: + type: string + monitors: + items: + type: string + type: array + pool: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + user: + type: string + required: + - image + - monitors + type: object + scaleIO: + properties: + fsType: + type: string + gateway: + type: string + protectionDomain: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + sslEnabled: + type: boolean + storageMode: + type: string + storagePool: + type: string + system: + type: string + volumeName: + type: string + required: + - gateway + - secretRef + - system + type: object + secret: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + optional: + type: boolean + secretName: + type: string + type: object + storageos: + properties: + fsType: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + volumeName: + type: string + volumeNamespace: + type: string + type: object + vsphereVolume: + properties: + fsType: + type: string + storagePolicyID: + type: string + storagePolicyName: + type: string + volumePath: + type: string + required: + - volumePath + type: object + required: + - name + type: object + type: array + required: + - mounts + - volumes + type: object + type: array + image: + type: string + initContainers: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + type: object + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + inventory: + type: string + name: + default: openstackansibleee + type: string + networkAttachments: + items: + type: string + type: array + play: + type: string + playbook: + type: string + preserveJobs: + default: true + enum: + - true + - false + type: boolean + restartPolicy: + default: Never + enum: + - OnFailure + - Never + type: string + serviceAccountName: + type: string + uid: + default: 1001 + format: int64 + type: integer + type: object + status: + properties: + JobStatus: + default: Pending + enum: + - Pending + - Running + - Succeeded + - Failed + type: string + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + type: string + reason: + type: string + severity: + type: string + status: + type: string + type: + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + hash: + additionalProperties: + type: string + type: object + networkAttachments: + additionalProperties: + items: + type: string + type: array + type: object + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/api/v1alpha1/openstackansibleee_webhook.go b/api/v1alpha1/openstackansibleee_webhook.go index e1cfe6f8..4786ff10 100644 --- a/api/v1alpha1/openstackansibleee_webhook.go +++ b/api/v1alpha1/openstackansibleee_webhook.go @@ -52,7 +52,7 @@ func (r *OpenStackAnsibleEE) SetupWebhookWithManager(mgr ctrl.Manager) error { Complete() } -//+kubebuilder:webhook:path=/mutate-ansibleee-openstack-org-v1alpha1-openstackansibleee,mutating=true,failurePolicy=fail,sideEffects=None,groups=ansibleee.openstack.org,resources=openstackansibleees,verbs=create;update,versions=v1alpha1,name=mopenstackansibleee.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/mutate-ansibleee-openstack-org-v1alpha1-openstackansibleee,mutating=true,failurePolicy=fail,sideEffects=None,groups=ansibleee.openstack.org,resources=openstackansibleees,verbs=create;update,versions=v1alpha1,name=alpha.mopenstackansibleee.kb.io,admissionReviewVersions=v1 var _ webhook.Defaulter = &OpenStackAnsibleEE{} @@ -71,7 +71,7 @@ func (spec *OpenStackAnsibleEESpec) Default() { } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-ansibleee-openstack-org-v1alpha1-openstackansibleee,mutating=false,failurePolicy=fail,sideEffects=None,groups=ansibleee.openstack.org,resources=openstackansibleees,verbs=create;update,versions=v1alpha1,name=vopenstackansibleee.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/validate-ansibleee-openstack-org-v1alpha1-openstackansibleee,mutating=false,failurePolicy=fail,sideEffects=None,groups=ansibleee.openstack.org,resources=openstackansibleees,verbs=create;update,versions=v1alpha1,name=alpha.vopenstackansibleee.kb.io,admissionReviewVersions=v1 var _ webhook.Validator = &OpenStackAnsibleEE{} diff --git a/api/v1beta1/conditions.go b/api/v1beta1/conditions.go new file mode 100644 index 00000000..7b7bcd90 --- /dev/null +++ b/api/v1beta1/conditions.go @@ -0,0 +1,47 @@ +/* +Copyright 2023. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + +// AnsibleEE Condition Types. +const ( + // AnsibleExecutionJobReadyCondition Status=True condition indicates + // AnsibleExecutionJob is ready. + AnsibleExecutionJobReadyCondition condition.Type = "AnsibleExecutionJobReady" +) + +// Common Messages used by AnsibleEE objects. +const ( + // + // AnsibleExecutionJob condition messages + // + // AnsibleExecutionJobInitMessage + AnsibleExecutionJobInitMessage = "AnsibleExecutionJob not started" + + // AnsibleExecutionJobReadyMessage + AnsibleExecutionJobReadyMessage = "AnsibleExecutionJob complete" + + // AnsibleExecutionJobNotFoundMessage + AnsibleExecutionJobNotFoundMessage = "AnsibleExecutionJob not found" + + // AnsibleExecutionJobWaitingMessage + AnsibleExecutionJobWaitingMessage = "AnsibleExecutionJob is running" + + // AnsibleExecutionJobErrorMessage + AnsibleExecutionJobErrorMessage = "AnsibleExecutionJob error occured %s" +) diff --git a/api/v1beta1/groupversion_info.go b/api/v1beta1/groupversion_info.go new file mode 100644 index 00000000..04745457 --- /dev/null +++ b/api/v1beta1/groupversion_info.go @@ -0,0 +1,36 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1beta1 contains API Schema definitions for the v1beta1 API group +// +kubebuilder:object:generate=true +// +groupName=ansibleee.openstack.org +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "ansibleee.openstack.org", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/api/v1beta1/openstackansibleee_types.go b/api/v1beta1/openstackansibleee_types.go new file mode 100644 index 00000000..d8a12791 --- /dev/null +++ b/api/v1beta1/openstackansibleee_types.go @@ -0,0 +1,189 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + "github.com/openstack-k8s-operators/lib-common/modules/common/util" + "github.com/openstack-k8s-operators/lib-common/modules/storage" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // Container image fall-back defaults + + // OpenStackAnsibleEEContainerImage is the fall-back container image for OpenStackAnsibleEE + OpenStackAnsibleEEContainerImage = "quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest" +) + +const ( + // JobStatusSucceeded - + JobStatusSucceeded = "Succeeded" + + // JobStatusFailed - + JobStatusFailed = "Failed" + + // JobStatusRunning - + JobStatusRunning = "Running" + + // JobStatusPending - + JobStatusPending = "Pending" +) + +// OpenStackAnsibleEESpec defines the desired state of OpenStackAnsibleEE +// +kubebuilder:storageversion +type OpenStackAnsibleEESpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Play is an inline playbook contents that ansible will run on execution. + // If both Play and Roles are specified, Play takes precedence + Play string `json:"play,omitempty"` + // Playbook is the playbook that ansible will run on this execution, accepts path or FQN from collection + Playbook string `json:"playbook,omitempty"` + // Image is the container image that will execute the ansible command + Image string `json:"image,omitempty"` + // Args are the command plus the playbook executed by the image. If args is passed, Playbook is ignored. + Args []string `json:"args,omitempty"` + // Name is the name of the internal container inside the pod + // +kubebuilder:default:="openstackansibleee" + Name string `json:"name,omitempty"` + // EnvConfigMapName is the name of the k8s config map that contains the ansible env variables + // +kubebuilder:default:="openstack-aee-default-env" + EnvConfigMapName string `json:"envConfigMapName,omitempty"` + // Env is a list containing the environment variables to pass to the pod + Env []corev1.EnvVar `json:"env,omitempty"` + // RestartPolicy is the policy applied to the Job on whether it needs to restart the Pod. It can be "OnFailure" or "Never". + // RestartPolicy default: Never + // +kubebuilder:validation:Enum:=OnFailure;Never + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:select:OnFailure","urn:alm:descriptor:com.tectonic.ui:select:Never"} + // +kubebuilder:default:="Never" + RestartPolicy string `json:"restartPolicy,omitempty"` + // PreserveJobs - do not delete jobs after they finished e.g. to check logs + // PreserveJobs default: true + // +kubebuilder:validation:Enum:=true;false + // +kubebuilder:default:=true + PreserveJobs bool `json:"preserveJobs,omitempty"` + // UID is the userid that will be used to run the container. + // +kubebuilder:default:=1001 + UID int64 `json:"uid,omitempty"` + // Inventory is the inventory that the ansible playbook will use to launch the job. + Inventory string `json:"inventory,omitempty"` + // +kubebuilder:validation:Optional + // ExtraMounts containing conf files and credentials + ExtraMounts []storage.VolMounts `json:"extraMounts,omitempty"` + // BackoffLimit allows to define the maximum number of retried executions (defaults to 6). + // +kubebuilder:default:=6 + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"} + BackoffLimit *int32 `json:"backoffLimit,omitempty"` + // +kubebuilder:validation:Optional + // NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network + NetworkAttachments []string `json:"networkAttachments,omitempty"` + // +kubebuilder:validation:Optional + // CmdLine is the command line passed to ansible-runner + CmdLine string `json:"cmdLine,omitempty"` + // +kubebuilder:validation:Optional + // InitContainers allows the passing of an array of containers that will be executed before the ansibleee execution itself + InitContainers []corev1.Container `json:"initContainers,omitempty"` + // +kubebuilder:validation:Optional + // ServiceAccountName allows to specify what ServiceAccountName do we want the ansible execution run with. Without specifying, + // it will run with default serviceaccount + ServiceAccountName string `json:"serviceAccountName,omitempty"` + // DNSConfig allows to specify custom dnsservers and search domains + // +kubebuilder:validation:Optional + DNSConfig *corev1.PodDNSConfig `json:"dnsConfig,omitempty"` + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Debug run the pod in debug mode without executing the ansible-runner commands + Debug bool `json:"debug"` +} + +// OpenStackAnsibleEEStatus defines the observed state of OpenStackAnsibleEE +type OpenStackAnsibleEEStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Map of hashes to track e.g. job status + Hash map[string]string `json:"hash,omitempty"` + + // +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:io.kubernetes.conditions"} + // Conditions + Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"` + + // NetworkAttachments status of the deployment pods + NetworkAttachments map[string][]string `json:"networkAttachments,omitempty"` + + // +kubebuilder:validation:Enum:=Pending;Running;Succeeded;Failed + // +kubebuilder:default:=Pending + // JobStatus status of the executed job (Pending/Running/Succeeded/Failed) + JobStatus string `json:"JobStatus,omitempty" optional:"true"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:storageversion +//+operator-sdk:csv:customresourcedefinitions:displayName="OpenStack Ansible EE" +//+kubebuilder:resource:shortName=osaee;osaees;osansible;osansibles +//+kubebuilder:printcolumn:name="NetworkAttachments",type="string",JSONPath=".spec.networkAttachments",description="NetworkAttachments" +//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status" +//+kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[0].message",description="Message" + +// OpenStackAnsibleEE is the Schema for the openstackansibleees API +type OpenStackAnsibleEE struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec OpenStackAnsibleEESpec `json:"spec,omitempty"` + Status OpenStackAnsibleEEStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// OpenStackAnsibleEEList contains a list of OpenStackAnsibleEE +type OpenStackAnsibleEEList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []OpenStackAnsibleEE `json:"items"` +} + +// Config is a specification of where to mount a certain ConfigMap object +type Config struct { + // Name is the name of the ConfigMap that we want to mount + Name string `json:"name"` + // MountPoint is the directory of the container where the ConfigMap will be mounted + MountPath string `json:"mountpath"` +} + +func init() { + SchemeBuilder.Register(&OpenStackAnsibleEE{}, &OpenStackAnsibleEEList{}) +} + +// IsReady - returns true if the OpenStackAnsibleEE is ready +func (instance OpenStackAnsibleEE) IsReady() bool { + return instance.Status.Conditions.IsTrue(AnsibleExecutionJobReadyCondition) +} + +// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks) +func SetupDefaults() { + // Acquire environmental defaults and initialize OpenStackAnsibleEE defaults with them + openstackAnsibleEEDefaults := OpenStackAnsibleEEDefaults{ + ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_ANSIBLEEE_IMAGE_URL_DEFAULT", OpenStackAnsibleEEContainerImage), + } + + SetupOpenStackAnsibleEEDefaults(openstackAnsibleEEDefaults) +} diff --git a/api/v1beta1/openstackansibleee_webhook.go b/api/v1beta1/openstackansibleee_webhook.go new file mode 100644 index 00000000..0173e815 --- /dev/null +++ b/api/v1beta1/openstackansibleee_webhook.go @@ -0,0 +1,100 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +// Generated by: +// +// operator-sdk create webhook --group ansibleee --version v1beta1 --kind OpenStackAnsibleEE --programmatic-validation --defaulting +// + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" +) + +// OpenStackAnsibleEEDefaults - +type OpenStackAnsibleEEDefaults struct { + ContainerImageURL string +} + +var openstackAnsibleEEDefaults OpenStackAnsibleEEDefaults + +// log is for logging in this package. +var openstackansibleeelog = logf.Log.WithName("openstackansibleee-resource") + +// SetupOpenStackAnsibleEEDefaults - initialize OpenStackAnsibleEE spec defaults for use with either internal or external webhooks +func SetupOpenStackAnsibleEEDefaults(defaults OpenStackAnsibleEEDefaults) { + openstackAnsibleEEDefaults = defaults + openstackansibleeelog.Info("OpenStackAnsibleEE defaults initialized", "defaults", defaults) +} + +// SetupWebhookWithManager sets up the webhook with the Manager +func (r *OpenStackAnsibleEE) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +//+kubebuilder:webhook:path=/mutate-ansibleee-openstack-org-v1beta1-openstackansibleee,mutating=true,failurePolicy=fail,sideEffects=None,groups=ansibleee.openstack.org,resources=openstackansibleees,verbs=create;update,versions=v1beta1,name=mopenstackansibleee.kb.io,admissionReviewVersions=v1 + +var _ webhook.Defaulter = &OpenStackAnsibleEE{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (r *OpenStackAnsibleEE) Default() { + openstackansibleeelog.Info("default", "name", r.Name) + + r.Spec.Default() +} + +// Default - set defaults for this OpenStackAnsibleEE spec +func (spec *OpenStackAnsibleEESpec) Default() { + if spec.Image == "" { + spec.Image = openstackAnsibleEEDefaults.ContainerImageURL + } +} + +// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. +//+kubebuilder:webhook:path=/validate-ansibleee-openstack-org-v1beta1-openstackansibleee,mutating=false,failurePolicy=fail,sideEffects=None,groups=ansibleee.openstack.org,resources=openstackansibleees,verbs=create;update,versions=v1beta1,name=vopenstackansibleee.kb.io,admissionReviewVersions=v1 + +var _ webhook.Validator = &OpenStackAnsibleEE{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (r *OpenStackAnsibleEE) ValidateCreate() error { + openstackansibleeelog.Info("validate create", "name", r.Name) + + // TODO(user): fill in your validation logic upon object creation. + return nil +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (r *OpenStackAnsibleEE) ValidateUpdate(old runtime.Object) error { + openstackansibleeelog.Info("validate update", "name", r.Name) + + // TODO(user): fill in your validation logic upon object update. + return nil +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (r *OpenStackAnsibleEE) ValidateDelete() error { + openstackansibleeelog.Info("validate delete", "name", r.Name) + + // TODO(user): fill in your validation logic upon object deletion. + return nil +} diff --git a/api/v1beta1/webhook_suite_test.go b/api/v1beta1/webhook_suite_test.go new file mode 100644 index 00000000..e102f53e --- /dev/null +++ b/api/v1beta1/webhook_suite_test.go @@ -0,0 +1,132 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "crypto/tls" + "fmt" + "net" + "path/filepath" + "testing" + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + admissionv1beta1 "k8s.io/api/admission/v1beta1" + //+kubebuilder:scaffold:imports + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/rest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var cfg *rest.Config +var k8sClient client.Client +var testEnv *envtest.Environment +var ctx context.Context +var cancel context.CancelFunc + +func TestAPIs(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecs(t, "Webhook Suite") +} + +var _ = BeforeSuite(func() { + logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + + ctx, cancel = context.WithCancel(context.TODO()) + + By("bootstrapping test environment") + testEnv = &envtest.Environment{ + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, + WebhookInstallOptions: envtest.WebhookInstallOptions{ + Paths: []string{filepath.Join("..", "..", "config", "webhook")}, + }, + } + + var err error + // cfg is defined in this file globally. + cfg, err = testEnv.Start() + Expect(err).NotTo(HaveOccurred()) + Expect(cfg).NotTo(BeNil()) + + scheme := runtime.NewScheme() + err = AddToScheme(scheme) + Expect(err).NotTo(HaveOccurred()) + + err = admissionv1beta1.AddToScheme(scheme) + Expect(err).NotTo(HaveOccurred()) + + //+kubebuilder:scaffold:scheme + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + + // start webhook server using Manager + webhookInstallOptions := &testEnv.WebhookInstallOptions + mgr, err := ctrl.NewManager(cfg, ctrl.Options{ + Scheme: scheme, + Host: webhookInstallOptions.LocalServingHost, + Port: webhookInstallOptions.LocalServingPort, + CertDir: webhookInstallOptions.LocalServingCertDir, + LeaderElection: false, + MetricsBindAddress: "0", + }) + Expect(err).NotTo(HaveOccurred()) + + err = (&OpenStackAnsibleEE{}).SetupWebhookWithManager(mgr) + Expect(err).NotTo(HaveOccurred()) + + //+kubebuilder:scaffold:webhook + + go func() { + defer GinkgoRecover() + err = mgr.Start(ctx) + Expect(err).NotTo(HaveOccurred()) + }() + + // wait for the webhook server to get ready + dialer := &net.Dialer{Timeout: time.Second} + addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) + Eventually(func() error { + conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) + if err != nil { + return err + } + conn.Close() + return nil + }).Should(Succeed()) + +}) + +var _ = AfterSuite(func() { + cancel() + By("tearing down the test environment") + err := testEnv.Stop() + Expect(err).NotTo(HaveOccurred()) +}) diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000..88b2a1cf --- /dev/null +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,218 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + "github.com/openstack-k8s-operators/lib-common/modules/storage" + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Config) DeepCopyInto(out *Config) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. +func (in *Config) DeepCopy() *Config { + if in == nil { + return nil + } + out := new(Config) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenStackAnsibleEE) DeepCopyInto(out *OpenStackAnsibleEE) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenStackAnsibleEE. +func (in *OpenStackAnsibleEE) DeepCopy() *OpenStackAnsibleEE { + if in == nil { + return nil + } + out := new(OpenStackAnsibleEE) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OpenStackAnsibleEE) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenStackAnsibleEEDefaults) DeepCopyInto(out *OpenStackAnsibleEEDefaults) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenStackAnsibleEEDefaults. +func (in *OpenStackAnsibleEEDefaults) DeepCopy() *OpenStackAnsibleEEDefaults { + if in == nil { + return nil + } + out := new(OpenStackAnsibleEEDefaults) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenStackAnsibleEEList) DeepCopyInto(out *OpenStackAnsibleEEList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OpenStackAnsibleEE, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenStackAnsibleEEList. +func (in *OpenStackAnsibleEEList) DeepCopy() *OpenStackAnsibleEEList { + if in == nil { + return nil + } + out := new(OpenStackAnsibleEEList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OpenStackAnsibleEEList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenStackAnsibleEESpec) DeepCopyInto(out *OpenStackAnsibleEESpec) { + *out = *in + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ExtraMounts != nil { + in, out := &in.ExtraMounts, &out.ExtraMounts + *out = make([]storage.VolMounts, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.BackoffLimit != nil { + in, out := &in.BackoffLimit, &out.BackoffLimit + *out = new(int32) + **out = **in + } + if in.NetworkAttachments != nil { + in, out := &in.NetworkAttachments, &out.NetworkAttachments + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.InitContainers != nil { + in, out := &in.InitContainers, &out.InitContainers + *out = make([]v1.Container, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.DNSConfig != nil { + in, out := &in.DNSConfig, &out.DNSConfig + *out = new(v1.PodDNSConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenStackAnsibleEESpec. +func (in *OpenStackAnsibleEESpec) DeepCopy() *OpenStackAnsibleEESpec { + if in == nil { + return nil + } + out := new(OpenStackAnsibleEESpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenStackAnsibleEEStatus) DeepCopyInto(out *OpenStackAnsibleEEStatus) { + *out = *in + if in.Hash != nil { + in, out := &in.Hash, &out.Hash + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(condition.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NetworkAttachments != nil { + in, out := &in.NetworkAttachments, &out.NetworkAttachments + *out = make(map[string][]string, len(*in)) + for key, val := range *in { + var outVal []string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make([]string, len(*in)) + copy(*out, *in) + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenStackAnsibleEEStatus. +func (in *OpenStackAnsibleEEStatus) DeepCopy() *OpenStackAnsibleEEStatus { + if in == nil { + return nil + } + out := new(OpenStackAnsibleEEStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crd/bases/ansibleee.openstack.org_openstackansibleees.yaml b/config/crd/bases/ansibleee.openstack.org_openstackansibleees.yaml index 450bc56f..5d8f52a8 100644 --- a/config/crd/bases/ansibleee.openstack.org_openstackansibleees.yaml +++ b/config/crd/bases/ansibleee.openstack.org_openstackansibleees.yaml @@ -1574,6 +1574,1563 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - description: NetworkAttachments + jsonPath: .spec.networkAttachments + name: NetworkAttachments + type: string + - description: Status + jsonPath: .status.conditions[0].status + name: Status + type: string + - description: Message + jsonPath: .status.conditions[0].message + name: Message + type: string + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + args: + items: + type: string + type: array + backoffLimit: + default: 6 + format: int32 + type: integer + cmdLine: + type: string + debug: + default: false + type: boolean + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envConfigMapName: + default: openstack-aee-default-env + type: string + extraMounts: + items: + properties: + extraVolType: + type: string + mounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + propagation: + items: + type: string + type: array + volumes: + items: + properties: + awsElasticBlockStore: + properties: + fsType: + type: string + partition: + format: int32 + type: integer + readOnly: + type: boolean + volumeID: + type: string + required: + - volumeID + type: object + azureDisk: + properties: + cachingMode: + type: string + diskName: + type: string + diskURI: + type: string + fsType: + type: string + kind: + type: string + readOnly: + type: boolean + required: + - diskName + - diskURI + type: object + azureFile: + properties: + readOnly: + type: boolean + secretName: + type: string + shareName: + type: string + required: + - secretName + - shareName + type: object + cephfs: + properties: + monitors: + items: + type: string + type: array + path: + type: string + readOnly: + type: boolean + secretFile: + type: string + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + user: + type: string + required: + - monitors + type: object + cinder: + properties: + fsType: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + volumeID: + type: string + required: + - volumeID + type: object + configMap: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + csi: + properties: + driver: + type: string + fsType: + type: string + nodePublishSecretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + readOnly: + type: boolean + volumeAttributes: + additionalProperties: + type: string + type: object + required: + - driver + type: object + downwardAPI: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + format: int32 + type: integer + path: + type: string + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + emptyDir: + properties: + medium: + type: string + sizeLimit: + anyOf: + - type: integer + - 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 + type: object + ephemeral: + properties: + volumeClaimTemplate: + properties: + metadata: + type: object + spec: + properties: + accessModes: + items: + type: string + type: array + dataSource: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + type: object + selector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + type: string + volumeMode: + type: string + volumeName: + type: string + type: object + required: + - spec + type: object + type: object + fc: + properties: + fsType: + type: string + lun: + format: int32 + type: integer + readOnly: + type: boolean + targetWWNs: + items: + type: string + type: array + wwids: + items: + type: string + type: array + type: object + flexVolume: + properties: + driver: + type: string + fsType: + type: string + options: + additionalProperties: + type: string + type: object + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + required: + - driver + type: object + flocker: + properties: + datasetName: + type: string + datasetUUID: + type: string + type: object + gcePersistentDisk: + properties: + fsType: + type: string + partition: + format: int32 + type: integer + pdName: + type: string + readOnly: + type: boolean + required: + - pdName + type: object + gitRepo: + properties: + directory: + type: string + repository: + type: string + revision: + type: string + required: + - repository + type: object + glusterfs: + properties: + endpoints: + type: string + path: + type: string + readOnly: + type: boolean + required: + - endpoints + - path + type: object + hostPath: + properties: + path: + type: string + type: + type: string + required: + - path + type: object + iscsi: + properties: + chapAuthDiscovery: + type: boolean + chapAuthSession: + type: boolean + fsType: + type: string + initiatorName: + type: string + iqn: + type: string + iscsiInterface: + type: string + lun: + format: int32 + type: integer + portals: + items: + type: string + type: array + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + targetPortal: + type: string + required: + - iqn + - lun + - targetPortal + type: object + name: + type: string + nfs: + properties: + path: + type: string + readOnly: + type: boolean + server: + type: string + required: + - path + - server + type: object + persistentVolumeClaim: + properties: + claimName: + type: string + readOnly: + type: boolean + required: + - claimName + type: object + photonPersistentDisk: + properties: + fsType: + type: string + pdID: + type: string + required: + - pdID + type: object + portworxVolume: + properties: + fsType: + type: string + readOnly: + type: boolean + volumeID: + type: string + required: + - volumeID + type: object + projected: + properties: + defaultMode: + format: int32 + type: integer + sources: + items: + properties: + configMap: + properties: + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + downwardAPI: + properties: + items: + items: + properties: + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + format: int32 + type: integer + path: + type: string + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + secret: + properties: + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + serviceAccountToken: + properties: + audience: + type: string + expirationSeconds: + format: int64 + type: integer + path: + type: string + required: + - path + type: object + type: object + type: array + type: object + quobyte: + properties: + group: + type: string + readOnly: + type: boolean + registry: + type: string + tenant: + type: string + user: + type: string + volume: + type: string + required: + - registry + - volume + type: object + rbd: + properties: + fsType: + type: string + image: + type: string + keyring: + type: string + monitors: + items: + type: string + type: array + pool: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + user: + type: string + required: + - image + - monitors + type: object + scaleIO: + properties: + fsType: + type: string + gateway: + type: string + protectionDomain: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + sslEnabled: + type: boolean + storageMode: + type: string + storagePool: + type: string + system: + type: string + volumeName: + type: string + required: + - gateway + - secretRef + - system + type: object + secret: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + optional: + type: boolean + secretName: + type: string + type: object + storageos: + properties: + fsType: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + volumeName: + type: string + volumeNamespace: + type: string + type: object + vsphereVolume: + properties: + fsType: + type: string + storagePolicyID: + type: string + storagePolicyName: + type: string + volumePath: + type: string + required: + - volumePath + type: object + required: + - name + type: object + type: array + required: + - mounts + - volumes + type: object + type: array + image: + type: string + initContainers: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - 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 + type: object + type: object + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + inventory: + type: string + name: + default: openstackansibleee + type: string + networkAttachments: + items: + type: string + type: array + play: + type: string + playbook: + type: string + preserveJobs: + default: true + enum: + - true + - false + type: boolean + restartPolicy: + default: Never + enum: + - OnFailure + - Never + type: string + serviceAccountName: + type: string + uid: + default: 1001 + format: int64 + type: integer + type: object + status: + properties: + JobStatus: + default: Pending + enum: + - Pending + - Running + - Succeeded + - Failed + type: string + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + type: string + reason: + type: string + severity: + type: string + status: + type: string + type: + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + hash: + additionalProperties: + type: string + type: object + networkAttachments: + additionalProperties: + items: + type: string + type: array + type: object + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 0fe2c4e4..b19cf365 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -9,11 +9,13 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_ansibleees.yaml +#- patches/webhook_in_openstackansibleees.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_ansibleees.yaml +#- patches/cainjection_in_openstackansibleees.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_openstackansibleees.yaml b/config/crd/patches/cainjection_in_openstackansibleees.yaml new file mode 100644 index 00000000..334c8548 --- /dev/null +++ b/config/crd/patches/cainjection_in_openstackansibleees.yaml @@ -0,0 +1,7 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: openstackansibleees.ansibleee.openstack.org diff --git a/config/crd/patches/webhook_in_openstackansibleees.yaml b/config/crd/patches/webhook_in_openstackansibleees.yaml new file mode 100644 index 00000000..996b1265 --- /dev/null +++ b/config/crd/patches/webhook_in_openstackansibleees.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: openstackansibleees.ansibleee.openstack.org +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/config/rbac/openstackansibleee_editor_role.yaml b/config/rbac/openstackansibleee_editor_role.yaml new file mode 100644 index 00000000..20572899 --- /dev/null +++ b/config/rbac/openstackansibleee_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit openstackansibleees. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: openstackansibleee-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: openstack-ansibleee-operator + app.kubernetes.io/part-of: openstack-ansibleee-operator + app.kubernetes.io/managed-by: kustomize + name: openstackansibleee-editor-role +rules: +- apiGroups: + - ansibleee.openstack.org + resources: + - openstackansibleees + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - ansibleee.openstack.org + resources: + - openstackansibleees/status + verbs: + - get diff --git a/config/rbac/openstackansibleee_viewer_role.yaml b/config/rbac/openstackansibleee_viewer_role.yaml new file mode 100644 index 00000000..a4d0aff6 --- /dev/null +++ b/config/rbac/openstackansibleee_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view openstackansibleees. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: openstackansibleee-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: openstack-ansibleee-operator + app.kubernetes.io/part-of: openstack-ansibleee-operator + app.kubernetes.io/managed-by: kustomize + name: openstackansibleee-viewer-role +rules: +- apiGroups: + - ansibleee.openstack.org + resources: + - openstackansibleees + verbs: + - get + - list + - watch +- apiGroups: + - ansibleee.openstack.org + resources: + - openstackansibleees/status + verbs: + - get diff --git a/config/samples/_v1beta1_ansibleee.yaml b/config/samples/_v1beta1_ansibleee.yaml new file mode 100644 index 00000000..dc1f3fe0 --- /dev/null +++ b/config/samples/_v1beta1_ansibleee.yaml @@ -0,0 +1,12 @@ +apiVersion: ansibleee.openstack.org/v1beta1 +kind: OpenStackAnsibleEE +metadata: + labels: + app.kubernetes.io/name: openstackansibleee + app.kubernetes.io/instance: openstackansibleee-sample + app.kubernetes.io/part-of: openstack-ansibleee-operator + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: openstack-ansibleee-operator + name: openstackansibleee-sample +spec: + # TODO(user): Add fields here diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 6970aac5..6726d44c 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,4 +1,5 @@ ## Append samples you want in your CSV to this file as resources ## resources: - _v1alpha1_ansibleee.yaml +- _v1beta1_ansibleee.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 1270a46e..6a2032eb 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -13,7 +13,7 @@ webhooks: namespace: system path: /mutate-ansibleee-openstack-org-v1alpha1-openstackansibleee failurePolicy: Fail - name: mopenstackansibleee.kb.io + name: alpha.mopenstackansibleee.kb.io rules: - apiGroups: - ansibleee.openstack.org @@ -25,6 +25,26 @@ webhooks: resources: - openstackansibleees sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-ansibleee-openstack-org-v1beta1-openstackansibleee + failurePolicy: Fail + name: mopenstackansibleee.kb.io + rules: + - apiGroups: + - ansibleee.openstack.org + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - openstackansibleees + sideEffects: None --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration @@ -40,7 +60,7 @@ webhooks: namespace: system path: /validate-ansibleee-openstack-org-v1alpha1-openstackansibleee failurePolicy: Fail - name: vopenstackansibleee.kb.io + name: alpha.vopenstackansibleee.kb.io rules: - apiGroups: - ansibleee.openstack.org @@ -52,3 +72,23 @@ webhooks: resources: - openstackansibleees sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-ansibleee-openstack-org-v1beta1-openstackansibleee + failurePolicy: Fail + name: vopenstackansibleee.kb.io + rules: + - apiGroups: + - ansibleee.openstack.org + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - openstackansibleees + sideEffects: None diff --git a/controllers/openstack_ansibleee_controller.go b/controllers/openstack_ansibleee_controller.go index cc5ebbb2..bf52989a 100644 --- a/controllers/openstack_ansibleee_controller.go +++ b/controllers/openstack_ansibleee_controller.go @@ -44,7 +44,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/openstack-k8s-operators/lib-common/modules/storage" - redhatcomv1alpha1 "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1alpha1" + ansibleeev1 "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1beta1" ) const ( @@ -103,7 +103,7 @@ func (r *OpenStackAnsibleEEReconciler) Reconcile(ctx context.Context, req ctrl.R defer func() { // update the overall status condition if service is ready if instance.IsReady() { - instance.Status.Conditions.MarkTrue(condition.ReadyCondition, redhatcomv1alpha1.AnsibleExecutionJobReadyMessage) + instance.Status.Conditions.MarkTrue(condition.ReadyCondition, ansibleeev1.AnsibleExecutionJobReadyMessage) } else { // something is not ready so reset the Ready condition instance.Status.Conditions.MarkUnknown( @@ -125,7 +125,7 @@ func (r *OpenStackAnsibleEEReconciler) Reconcile(ctx context.Context, req ctrl.R instance.Status.Conditions = condition.Conditions{} cl := condition.CreateList( - condition.UnknownCondition(redhatcomv1alpha1.AnsibleExecutionJobReadyCondition, condition.InitReason, redhatcomv1alpha1.AnsibleExecutionJobInitMessage), + condition.UnknownCondition(ansibleeev1.AnsibleExecutionJobReadyCondition, condition.InitReason, ansibleeev1.AnsibleExecutionJobInitMessage), ) instance.Status.Conditions.Init(&cl) @@ -202,22 +202,22 @@ func (r *OpenStackAnsibleEEReconciler) Reconcile(ctx context.Context, req ctrl.R if (ctrlResult != ctrl.Result{}) { instance.Status.Conditions.Set(condition.FalseCondition( - redhatcomv1alpha1.AnsibleExecutionJobReadyCondition, + ansibleeev1.AnsibleExecutionJobReadyCondition, condition.RequestedReason, condition.SeverityInfo, - redhatcomv1alpha1.AnsibleExecutionJobWaitingMessage)) - instance.Status.JobStatus = redhatcomv1alpha1.JobStatusRunning + ansibleeev1.AnsibleExecutionJobWaitingMessage)) + instance.Status.JobStatus = ansibleeev1.JobStatusRunning return ctrlResult, nil } if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - redhatcomv1alpha1.AnsibleExecutionJobReadyCondition, + ansibleeev1.AnsibleExecutionJobReadyCondition, condition.ErrorReason, condition.SeverityWarning, - redhatcomv1alpha1.AnsibleExecutionJobErrorMessage, + ansibleeev1.AnsibleExecutionJobErrorMessage, err.Error())) - instance.Status.JobStatus = redhatcomv1alpha1.JobStatusFailed + instance.Status.JobStatus = ansibleeev1.JobStatusFailed return ctrl.Result{}, err } @@ -226,16 +226,16 @@ func (r *OpenStackAnsibleEEReconciler) Reconcile(ctx context.Context, req ctrl.R r.Log.Info(fmt.Sprintf("AnsibleEE CR '%s' - Job %s hash added - %s", instance.Name, jobDef.Name, instance.Status.Hash[ansibleeeJobType])) } - instance.Status.Conditions.MarkTrue(redhatcomv1alpha1.AnsibleExecutionJobReadyCondition, redhatcomv1alpha1.AnsibleExecutionJobReadyMessage) - instance.Status.JobStatus = redhatcomv1alpha1.JobStatusSucceeded + instance.Status.Conditions.MarkTrue(ansibleeev1.AnsibleExecutionJobReadyCondition, ansibleeev1.AnsibleExecutionJobReadyMessage) + instance.Status.JobStatus = ansibleeev1.JobStatusSucceeded r.Log.Info(fmt.Sprintf("Reconciled AnsibleEE '%s' successfully", instance.Name)) return ctrl.Result{}, nil } -func (r *OpenStackAnsibleEEReconciler) getOpenStackAnsibleeeInstance(ctx context.Context, req ctrl.Request) (*redhatcomv1alpha1.OpenStackAnsibleEE, error) { +func (r *OpenStackAnsibleEEReconciler) getOpenStackAnsibleeeInstance(ctx context.Context, req ctrl.Request) (*ansibleeev1.OpenStackAnsibleEE, error) { // Fetch the OpenStackAnsibleEE instance - instance := &redhatcomv1alpha1.OpenStackAnsibleEE{} + instance := &ansibleeev1.OpenStackAnsibleEE{} err := r.Get(ctx, req.NamespacedName, instance) if err != nil { @@ -244,7 +244,7 @@ func (r *OpenStackAnsibleEEReconciler) getOpenStackAnsibleeeInstance(ctx context // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers. // Return and don't requeue r.Log.Info("OpenStackAnsibleEE resource not found. Ignoring since object must be deleted") - return &redhatcomv1alpha1.OpenStackAnsibleEE{}, nil + return &ansibleeev1.OpenStackAnsibleEE{}, nil } // Error reading the object - requeue the request. r.Log.Error(err, err.Error()) @@ -256,7 +256,7 @@ func (r *OpenStackAnsibleEEReconciler) getOpenStackAnsibleeeInstance(ctx context // jobForOpenStackAnsibleEE returns a openstackansibleee Job object func (r *OpenStackAnsibleEEReconciler) jobForOpenStackAnsibleEE( - instance *redhatcomv1alpha1.OpenStackAnsibleEE, + instance *ansibleeev1.OpenStackAnsibleEE, h *helper.Helper, annotations map[string]string) (*batchv1.Job, error) { labels := instance.GetObjectMeta().GetLabels() @@ -412,7 +412,7 @@ func labelsForOpenStackAnsibleEE(name string, deployIdentifier string) map[strin } } -func addEnvFrom(instance *redhatcomv1alpha1.OpenStackAnsibleEE, job *batchv1.Job) { +func addEnvFrom(instance *ansibleeev1.OpenStackAnsibleEE, job *batchv1.Job) { job.Spec.Template.Spec.Containers[0].EnvFrom = []corev1.EnvFromSource{ { ConfigMapRef: &corev1.ConfigMapEnvSource{ @@ -422,7 +422,7 @@ func addEnvFrom(instance *redhatcomv1alpha1.OpenStackAnsibleEE, job *batchv1.Job } } -func addMounts(instance *redhatcomv1alpha1.OpenStackAnsibleEE, job *batchv1.Job) { +func addMounts(instance *ansibleeev1.OpenStackAnsibleEE, job *batchv1.Job) { var volumeMounts []corev1.VolumeMount var volumes []corev1.Volume @@ -456,7 +456,7 @@ func hashPodSpec( } // set value of runner environment variable and compute the hash -func setRunnerEnvVar(instance *redhatcomv1alpha1.OpenStackAnsibleEE, +func setRunnerEnvVar(instance *ansibleeev1.OpenStackAnsibleEE, helper *helper.Helper, varName string, varValue string, @@ -506,7 +506,7 @@ func hashOfInputHashes(hashes map[string]string) (string, error) { // SetupWithManager sets up the controller with the Manager. func (r *OpenStackAnsibleEEReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&redhatcomv1alpha1.OpenStackAnsibleEE{}). + For(&ansibleeev1.OpenStackAnsibleEE{}). Owns(&batchv1.Job{}). Complete(r) } diff --git a/main.go b/main.go index 9f5c7e4c..45d748ee 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,8 @@ import ( "github.com/openstack-k8s-operators/openstack-ansibleee-operator/controllers" networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" + + ansibleeev1beta1 "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1beta1" //+kubebuilder:scaffold:imports ) @@ -53,6 +55,7 @@ func init() { utilruntime.Must(redhatcomv1alpha1.AddToScheme(scheme)) utilruntime.Must(networkv1.AddToScheme(scheme)) + utilruntime.Must(ansibleeev1beta1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } diff --git a/tests/functional/ansibleee_controller_test.go b/tests/functional/ansibleee_controller_test.go index e222a4cd..c2798d58 100644 --- a/tests/functional/ansibleee_controller_test.go +++ b/tests/functional/ansibleee_controller_test.go @@ -23,7 +23,7 @@ import ( . "github.com/onsi/gomega" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" . "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers" - "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1alpha1" + "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1beta1" ) var _ = Describe("Ansibleee controller", func() { @@ -36,7 +36,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -57,7 +57,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectCondition( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionTrue, ) th.ExpectCondition( @@ -76,7 +76,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -98,7 +98,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.ErrorReason, "AnsibleExecutionJob error occured Internal error occurred: Job Failed. Check job logs", @@ -119,7 +119,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -136,7 +136,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectCondition( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionTrue, ) ansibleee := GetAnsibleee(ansibleeeName) @@ -159,7 +159,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -173,7 +173,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectCondition( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionTrue, ) ansibleee = GetAnsibleee(ansibleeeName) @@ -193,7 +193,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionUnknown, condition.InitReason, "AnsibleExecutionJob not started", @@ -210,7 +210,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -229,7 +229,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -250,7 +250,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectCondition( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionTrue, ) th.ExpectCondition( @@ -269,7 +269,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.RequestedReason, "AnsibleExecutionJob is running", @@ -291,7 +291,7 @@ var _ = Describe("Ansibleee controller", func() { th.ExpectConditionWithDetails( ansibleeeName, ConditionGetterFunc(AnsibleeeConditionGetter), - v1alpha1.AnsibleExecutionJobReadyCondition, + v1beta1.AnsibleExecutionJobReadyCondition, corev1.ConditionFalse, condition.ErrorReason, "AnsibleExecutionJob error occured Internal error occurred: Job Failed. Check job logs", diff --git a/tests/functional/base_test.go b/tests/functional/base_test.go index 916b1fa9..f8e3d306 100644 --- a/tests/functional/base_test.go +++ b/tests/functional/base_test.go @@ -20,7 +20,7 @@ import ( . "github.com/onsi/gomega" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" - "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1alpha1" + "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1beta1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -36,8 +36,8 @@ const ( msg: "Hello, world this is ansibleee-play.yaml"` ) -func GetAnsibleee(name types.NamespacedName) *v1alpha1.OpenStackAnsibleEE { - instance := &v1alpha1.OpenStackAnsibleEE{} +func GetAnsibleee(name types.NamespacedName) *v1beta1.OpenStackAnsibleEE { + instance := &v1beta1.OpenStackAnsibleEE{} Eventually(func(g Gomega) { g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed()) }, timeout, interval).Should(Succeed()) @@ -51,7 +51,7 @@ func AnsibleeeConditionGetter(name types.NamespacedName) condition.Conditions { func CreateAnsibleee(name types.NamespacedName) client.Object { raw := map[string]interface{}{ - "apiVersion": "ansibleee.openstack.org/v1alpha1", + "apiVersion": "ansibleee.openstack.org/v1beta1", "kind": "OpenStackAnsibleEE", "metadata": map[string]interface{}{ "name": name.Name, @@ -70,7 +70,7 @@ func CreateAnsibleeeWithParams( name types.NamespacedName, playbook string, image string, play string, debug bool, cmdline string) client.Object { raw := map[string]interface{}{ - "apiVersion": "ansibleee.openstack.org/v1alpha1", + "apiVersion": "ansibleee.openstack.org/v1beta1", "kind": "OpenStackAnsibleEE", "metadata": map[string]interface{}{ "name": name.Name, diff --git a/tests/functional/suite_test.go b/tests/functional/suite_test.go index 311db00a..0c00ffc6 100644 --- a/tests/functional/suite_test.go +++ b/tests/functional/suite_test.go @@ -38,7 +38,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - redhatcomv1alpha1 "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1alpha1" + ansibleeev1 "github.com/openstack-k8s-operators/openstack-ansibleee-operator/api/v1beta1" "github.com/openstack-k8s-operators/openstack-ansibleee-operator/controllers" //+kubebuilder:scaffold:imports ) @@ -86,7 +86,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - err = redhatcomv1alpha1.AddToScheme(scheme.Scheme) + err = ansibleeev1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme diff --git a/tests/kuttl/tests/run_simple_playbook/01-assert.yaml b/tests/kuttl/tests/run_simple_playbook/01-assert.yaml index 7b050b0b..4d2af54c 100644 --- a/tests/kuttl/tests/run_simple_playbook/01-assert.yaml +++ b/tests/kuttl/tests/run_simple_playbook/01-assert.yaml @@ -6,7 +6,7 @@ # - 1 Ansibleee-play job # - Correct output from ansible play # -apiVersion: ansibleee.openstack.org/v1alpha1 +apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE metadata: name: ansibleee-play @@ -45,42 +45,42 @@ status: apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: | - pod=$(oc get pods -n $NAMESPACE -l app=openstackansibleee,job-name=ansibleee-play -o name) - description=$(oc describe -n $NAMESPACE "$pod") - logs=$(echo "$description" | grep 'Hello, world this is ansibleee-play.yaml') - echo Pod name: $pod - echo Description: $description - if [ -n "$logs" ]; then - exit 0 - else - exit 1 - fi +- script: | + pod=$(oc get pods -n $NAMESPACE -l app=openstackansibleee,job-name=ansibleee-play -o name) + description=$(oc describe -n $NAMESPACE "$pod") + logs=$(echo "$description" | grep 'Hello, world this is ansibleee-play.yaml') + echo Pod name: $pod + echo Description: $description + if [ -n "$logs" ]; then + exit 0 + else + exit 1 + fi --- # when using image digests the containerImage URLs are SHA's so we verify them with a script apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: | - tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' - imageTuples=$(oc get -n openstack-operators deployment openstack-ansible-operator-controller-manager -o go-template="$tupleTemplate") - # format of imageTuple is: RELATED_IMAGE_ANSIBLEEE_# separated by newlines - for ITEM in $(echo $imageTuples); do - # it is an image - if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then - NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_ANSIBLEEE_\([^_]*\)_.*|\1|') - IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') - template='{{.spec.image}}' - case $NAME in - API) - SERVICE_IMAGE=$(oc get -n $NAMESPACE openstackansibleee ansibleee-play -o go-template="$template") - ;; - esac - if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then - echo "$NAME image does not equal $VALUE" - exit 1 - fi +- script: | + tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' + imageTuples=$(oc get -n openstack-operators deployment openstack-ansible-operator-controller-manager -o go-template="$tupleTemplate") + # format of imageTuple is: RELATED_IMAGE_ANSIBLEEE_# separated by newlines + for ITEM in $(echo $imageTuples); do + # it is an image + if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then + NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_ANSIBLEEE_\([^_]*\)_.*|\1|') + IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') + template='{{.spec.image}}' + case $NAME in + API) + SERVICE_IMAGE=$(oc get -n $NAMESPACE openstackansibleee ansibleee-play -o go-template="$template") + ;; + esac + if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then + echo "$NAME image does not equal $VALUE" + exit 1 fi - done + fi + done - exit 0 + exit 0 diff --git a/tests/kuttl/tests/run_simple_playbook/01-run-hello-world.yaml b/tests/kuttl/tests/run_simple_playbook/01-run-hello-world.yaml index e206f3e4..75626c86 100644 --- a/tests/kuttl/tests/run_simple_playbook/01-run-hello-world.yaml +++ b/tests/kuttl/tests/run_simple_playbook/01-run-hello-world.yaml @@ -1,4 +1,4 @@ -apiVersion: ansibleee.openstack.org/v1alpha1 +apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE metadata: name: ansibleee-play diff --git a/tests/kuttl/tests/run_simple_playbook/02-cleanup.yaml b/tests/kuttl/tests/run_simple_playbook/02-cleanup.yaml index 8ac9ffca..9f4c7de7 100644 --- a/tests/kuttl/tests/run_simple_playbook/02-cleanup.yaml +++ b/tests/kuttl/tests/run_simple_playbook/02-cleanup.yaml @@ -1,6 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep delete: -- apiVersion: ansibleee.openstack.org/v1alpha1 +- apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE name: ansibleee-play diff --git a/tests/kuttl/tests/run_simple_playbook_debug/01-assert.yaml b/tests/kuttl/tests/run_simple_playbook_debug/01-assert.yaml index 6fa27a0f..1e11b3aa 100644 --- a/tests/kuttl/tests/run_simple_playbook_debug/01-assert.yaml +++ b/tests/kuttl/tests/run_simple_playbook_debug/01-assert.yaml @@ -6,7 +6,7 @@ # - 1 Ansibleee-play job # - Correct output from ansible play # -apiVersion: ansibleee.openstack.org/v1alpha1 +apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE metadata: name: ansibleee-play-debug @@ -43,42 +43,42 @@ metadata: apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: | - pod=$(oc get pods -n $NAMESPACE -l app=openstackansibleee,job-name=ansibleee-play-debug -o name) - description=$(oc describe -n $NAMESPACE "$pod") - playbook_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') - echo Pod name: $pod - echo Description: $description - if [ -n "$playbook_present" ]; then - exit 0 - else - exit 1 - fi +- script: | + pod=$(oc get pods -n $NAMESPACE -l app=openstackansibleee,job-name=ansibleee-play-debug -o name) + description=$(oc describe -n $NAMESPACE "$pod") + playbook_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') + echo Pod name: $pod + echo Description: $description + if [ -n "$playbook_present" ]; then + exit 0 + else + exit 1 + fi --- # when using image digests the containerImage URLs are SHA's so we verify them with a script apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: | - tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' - imageTuples=$(oc get -n openstack-operators deployment openstack-ansible-operator-controller-manager -o go-template="$tupleTemplate") - # format of imageTuple is: RELATED_IMAGE_ANSIBLEEE_# separated by newlines - for ITEM in $(echo $imageTuples); do - # it is an image - if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then - NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_ANSIBLEEE_\([^_]*\)_.*|\1|') - IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') - template='{{.spec.image}}' - case $NAME in - API) - SERVICE_IMAGE=$(oc get -n $NAMESPACE openstackansibleee ansibleee-play-debug -o go-template="$template") - ;; - esac - if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then - echo "$NAME image does not equal $VALUE" - exit 1 - fi +- script: | + tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' + imageTuples=$(oc get -n openstack-operators deployment openstack-ansible-operator-controller-manager -o go-template="$tupleTemplate") + # format of imageTuple is: RELATED_IMAGE_ANSIBLEEE_# separated by newlines + for ITEM in $(echo $imageTuples); do + # it is an image + if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then + NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_ANSIBLEEE_\([^_]*\)_.*|\1|') + IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') + template='{{.spec.image}}' + case $NAME in + API) + SERVICE_IMAGE=$(oc get -n $NAMESPACE openstackansibleee ansibleee-play-debug -o go-template="$template") + ;; + esac + if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then + echo "$NAME image does not equal $VALUE" + exit 1 fi - done + fi + done - exit 0 + exit 0 diff --git a/tests/kuttl/tests/run_simple_playbook_debug/01-run-debug.yaml b/tests/kuttl/tests/run_simple_playbook_debug/01-run-debug.yaml index 8708c139..571cf2fc 100644 --- a/tests/kuttl/tests/run_simple_playbook_debug/01-run-debug.yaml +++ b/tests/kuttl/tests/run_simple_playbook_debug/01-run-debug.yaml @@ -1,4 +1,4 @@ -apiVersion: ansibleee.openstack.org/v1alpha1 +apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE metadata: name: ansibleee-play-debug diff --git a/tests/kuttl/tests/run_simple_playbook_debug/02-cleanup.yaml b/tests/kuttl/tests/run_simple_playbook_debug/02-cleanup.yaml index 4ee4e76a..14b9610a 100644 --- a/tests/kuttl/tests/run_simple_playbook_debug/02-cleanup.yaml +++ b/tests/kuttl/tests/run_simple_playbook_debug/02-cleanup.yaml @@ -1,6 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep delete: -- apiVersion: ansibleee.openstack.org/v1alpha1 +- apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE name: ansibleee-play-debug diff --git a/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-assert.yaml b/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-assert.yaml index 050fd159..e2a710f0 100644 --- a/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-assert.yaml +++ b/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-assert.yaml @@ -6,7 +6,7 @@ # - 1 Ansibleee-play job # - Correct output from ansible play # -apiVersion: ansibleee.openstack.org/v1alpha1 +apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE metadata: name: ansibleee-play-debug @@ -43,48 +43,48 @@ metadata: apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: | - pod=$(oc get pods -n $NAMESPACE -l app=openstackansibleee,job-name=ansibleee-play-debug -o name) - description=$(oc describe -n $NAMESPACE "$pod") - playbook_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') - cmdline_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') - echo Pod name: $pod - echo Description: $description - if [ -n "$playbook_present" ]; then - exit 0 - else - exit 1 - fi - if [ -z "$cmdline_present" ]; then - exit 1 - else - exit 0 - fi +- script: | + pod=$(oc get pods -n $NAMESPACE -l app=openstackansibleee,job-name=ansibleee-play-debug -o name) + description=$(oc describe -n $NAMESPACE "$pod") + playbook_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') + cmdline_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') + echo Pod name: $pod + echo Description: $description + if [ -n "$playbook_present" ]; then + exit 0 + else + exit 1 + fi + if [ -z "$cmdline_present" ]; then + exit 1 + else + exit 0 + fi --- # when using image digests the containerImage URLs are SHA's so we verify them with a script apiVersion: kuttl.dev/v1beta1 kind: TestAssert commands: - - script: | - tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' - imageTuples=$(oc get -n openstack-operators deployment openstack-ansible-operator-controller-manager -o go-template="$tupleTemplate") - # format of imageTuple is: RELATED_IMAGE_ANSIBLEEE_# separated by newlines - for ITEM in $(echo $imageTuples); do - # it is an image - if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then - NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_ANSIBLEEE_\([^_]*\)_.*|\1|') - IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') - template='{{.spec.image}}' - case $NAME in - API) - SERVICE_IMAGE=$(oc get -n $NAMESPACE openstackansibleee ansibleee-play-debug -o go-template="$template") - ;; - esac - if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then - echo "$NAME image does not equal $VALUE" - exit 1 - fi +- script: | + tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' + imageTuples=$(oc get -n openstack-operators deployment openstack-ansible-operator-controller-manager -o go-template="$tupleTemplate") + # format of imageTuple is: RELATED_IMAGE_ANSIBLEEE_# separated by newlines + for ITEM in $(echo $imageTuples); do + # it is an image + if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then + NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_ANSIBLEEE_\([^_]*\)_.*|\1|') + IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') + template='{{.spec.image}}' + case $NAME in + API) + SERVICE_IMAGE=$(oc get -n $NAMESPACE openstackansibleee ansibleee-play-debug -o go-template="$template") + ;; + esac + if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then + echo "$NAME image does not equal $VALUE" + exit 1 fi - done + fi + done - exit 0 + exit 0 diff --git a/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-run-debug.yaml b/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-run-debug.yaml index 2e3ea090..0f67d883 100644 --- a/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-run-debug.yaml +++ b/tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-run-debug.yaml @@ -1,4 +1,4 @@ -apiVersion: ansibleee.openstack.org/v1alpha1 +apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE metadata: name: ansibleee-play-debug diff --git a/tests/kuttl/tests/run_simple_playbook_debug_cmdline/02-cleanup.yaml b/tests/kuttl/tests/run_simple_playbook_debug_cmdline/02-cleanup.yaml index 4ee4e76a..14b9610a 100644 --- a/tests/kuttl/tests/run_simple_playbook_debug_cmdline/02-cleanup.yaml +++ b/tests/kuttl/tests/run_simple_playbook_debug_cmdline/02-cleanup.yaml @@ -1,6 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep delete: -- apiVersion: ansibleee.openstack.org/v1alpha1 +- apiVersion: ansibleee.openstack.org/v1beta1 kind: OpenStackAnsibleEE name: ansibleee-play-debug