diff --git a/ozgcloud-elastic-operator/run_helm_test.sh b/ozgcloud-elastic-operator/run_helm_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..8097a39a04ff100d5c9350e205d942100dd37894 --- /dev/null +++ b/ozgcloud-elastic-operator/run_helm_test.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +helm template ./src/main/helm/ -f src/test/helm/linter_values.yaml +helm lint -f src/test/helm/linter_values.yaml ./src/main/helm/ +cd src/main/helm && helm unittest --helm3 -f '../../test/helm/*/*.yaml' -f '../../test/helm/*.yaml' . diff --git a/ozgcloud-elastic-operator/src/main/helm/Chart.yaml b/ozgcloud-elastic-operator/src/main/helm/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fed209d033d0927f25a921315c5206449f3b5a2f --- /dev/null +++ b/ozgcloud-elastic-operator/src/main/helm/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: ozgcloud-elastic-operator +description: OZG Cloud Elastic Operator +type: application +version: 0.0.0-MANAGED-BY-JENKINS +appVersion: "0.0.0-MANAGED-BY-JENKINS" +icon: https://simpleicons.org/icons/helm.svg \ No newline at end of file diff --git a/ozgcloud-elastic-operator/src/main/helm/templates/crd/operator.ozgcloud.de_OzgCloudElasticUser.yaml b/ozgcloud-elastic-operator/src/main/helm/templates/crd/operator.ozgcloud.de_OzgCloudElasticUser.yaml new file mode 100644 index 0000000000000000000000000000000000000000..530a95b977b0ee36787c1a1dbad1717f5fd7d108 --- /dev/null +++ b/ozgcloud-elastic-operator/src/main/helm/templates/crd/operator.ozgcloud.de_OzgCloudElasticUser.yaml @@ -0,0 +1,45 @@ +# Muss die Datei so benannt werden? +--- #TOASK Werden die gebraucht?! +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: ozgcloudelasticuser.operator.ozgcloud.de +spec: + group: operator.ozgcloud.de + names: + kind: OzgCloudElasticUser + listKind: OzgCloudElasticUserList + plural: ozgelasticusers + singular: ozgelasticuser + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + type: object + description: OzgCloudElasticUser is the Schema for the keycloaks API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + type: string + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + metadata: + type: object + spec: + description: Spec defines the desired state of Elastic + type: object + x-kubernetes-preserve-unknown-fields: true + status: + description: Status defines the observed state of Elastic + type: object + x-kubernetes-preserve-unknown-fields: true + served: true + storage: true + subresources: + status: {} diff --git a/ozgcloud-elastic-operator/src/main/helm/templates/rbac/elastic_edit_role.yaml b/ozgcloud-elastic-operator/src/main/helm/templates/rbac/elastic_edit_role.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe5364cf7594ea3c75e6f0b14dc218d010c2499d --- /dev/null +++ b/ozgcloud-elastic-operator/src/main/helm/templates/rbac/elastic_edit_role.yaml @@ -0,0 +1,30 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: elastic-edit-role + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: elastic-edit-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: ozgcloud-operator + app.kubernetes.io/part-of: ozgcloud-operator + app.kubernetes.io/managed-by: kustomize +rules: +- apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches/status + verbs: + - get \ No newline at end of file diff --git a/ozgcloud-elastic-operator/src/main/helm/templates/rbac/elastic_view_role.yaml b/ozgcloud-elastic-operator/src/main/helm/templates/rbac/elastic_view_role.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f84a78ab9603df08501c091fe8de5e6f51942855 --- /dev/null +++ b/ozgcloud-elastic-operator/src/main/helm/templates/rbac/elastic_view_role.yaml @@ -0,0 +1,26 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: elastic-view-role + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: elastic-view-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: ozgcloud-operator + app.kubernetes.io/part-of: ozgcloud-operator + app.kubernetes.io/managed-by: kustomize +rules: +- apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches + verbs: + - get + - list + - watch +- apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches/status + verbs: + - get \ No newline at end of file diff --git a/ozgcloud-elastic-operator/src/test/helm/crd/operator.ozgcloud.de_OzgCloudElasticUser_test.yaml b/ozgcloud-elastic-operator/src/test/helm/crd/operator.ozgcloud.de_OzgCloudElasticUser_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ecef6087e671ba67740ae8c3d2325e911f7a8eb1 --- /dev/null +++ b/ozgcloud-elastic-operator/src/test/helm/crd/operator.ozgcloud.de_OzgCloudElasticUser_test.yaml @@ -0,0 +1,51 @@ +suite: operator.ozgcloud.de_OzgCloudElasticUser test +templates: + - templates/crd/operator.ozgcloud.de_OzgCloudElasticUser.yaml +tests: + - it: should have apiVersion + asserts: + - equal: + path: apiVersion + value: apiextensions.k8s.io/v1 + - it: should have isKind of + asserts: + - isKind: + of: CustomResourceDefinition + + - it: should have metadata name + asserts: + - equal: + path: metadata.name + value: ozgcloudelasticuser.operator.ozgcloud.de + + - it: should have spec group + asserts: + - equal: + path: spec.group + value: operator.ozgcloud.de + - it: should have spec names kind + asserts: + - equal: + path: spec.names.kind + value: OzgCloudElasticUser + - it: should have spec names listKind + asserts: + - equal: + path: spec.names.listKind + value: OzgCloudElasticUserList + - it: should have spec names plural + asserts: + - equal: + path: spec.names.plural + value: ozgelasticusers + - it: should have spec names singular + asserts: + - equal: + path: spec.names.singular + value: ozgelasticuser + + - it: should have spec scope + asserts: + - equal: + path: spec.scope + value: Namespaced \ No newline at end of file diff --git a/ozgcloud-elastic-operator/src/test/helm/crd/operator.ozgcloud.de_OzgCloudElasticUser_versions_v1_test.yaml b/ozgcloud-elastic-operator/src/test/helm/crd/operator.ozgcloud.de_OzgCloudElasticUser_versions_v1_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d52d4601eccce9f2580915cd7a58e980737b78cc --- /dev/null +++ b/ozgcloud-elastic-operator/src/test/helm/crd/operator.ozgcloud.de_OzgCloudElasticUser_versions_v1_test.yaml @@ -0,0 +1,99 @@ +suite: operator.ozgcloud.de_OzgCloudElasticUser versions v1 test +templates: + - templates/crd/operator.ozgcloud.de_OzgCloudElasticUser.yaml +tests: + - it: should have versions name + asserts: + - equal: + path: spec.versions[0].name + value: v1 + - it: should have versions schema description + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.description + value: OzgCloudElasticUser is the Schema for the keycloaks API + - it: should have versions schema type + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.type + value: object + + - it: should have versions schema apiVersion property type + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.apiVersion.type + value: string + - it: should have versions schema apiVersion property description + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.apiVersion.description + value: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + + - it: should have versions schema kind property type + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.kind.type + value: string + - it: should have versions schema kind property description + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.kind.description + value: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + + - it: should have versions schema metadata + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.metadata.type + value: object + + - it: should have versions schema spec description + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.description + value: Spec defines the desired state of Elastic + - it: should have versions schema spec type + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.type + value: object + - it: should have versions schema spec preserve unknown fields + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.x-kubernetes-preserve-unknown-fields + value: true + + - it: should have versions schema status description + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.status.description + value: Status defines the observed state of Elastic + - it: should have versions schema status type + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.status.type + value: object + - it: should have versions schema status preserve unknown fields + asserts: + - equal: + path: spec.versions[0].schema.openAPIV3Schema.properties.status.x-kubernetes-preserve-unknown-fields + value: true + + - it: should have versions served + asserts: + - equal: + path: spec.versions[0].served + value: true + - it: should have versions storage + asserts: + - equal: + path: spec.versions[0].storage + value: true + - it: should have versions subresources statis + asserts: + - equal: + path: spec.versions[0].subresources.status + value: {} \ No newline at end of file diff --git a/ozgcloud-elastic-operator/src/test/helm/linter_values.yaml b/ozgcloud-elastic-operator/src/test/helm/linter_values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ozgcloud-elastic-operator/src/test/helm/rbac/elastic_edit_role_test.yaml b/ozgcloud-elastic-operator/src/test/helm/rbac/elastic_edit_role_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d4c28e594e30786404ce7a2e8734d15f4f699ec7 --- /dev/null +++ b/ozgcloud-elastic-operator/src/test/helm/rbac/elastic_edit_role_test.yaml @@ -0,0 +1,79 @@ +suite: elastic_edit_role test +templates: + - templates/rbac/elastic_edit_role.yaml +tests: + - it: should have apiVersion + asserts: + - equal: + path: apiVersion + value: rbac.authorization.k8s.io/v1 + - it: should have isKind of + asserts: + - isKind: + of: ClusterRole + + - it: should have metadata name + asserts: + - equal: + path: metadata.name + value: elastic-edit-role + - it: should have metadata labels name + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/name] + value: clusterrole + - it: should have metadata labels instance + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/instance] + value: elastic-edit-role + - it: should have metadata labels component + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/component] + value: rbac + - it: should have metadata labels created-by + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/created-by] + value: ozgcloud-operator + - it: should have metadata labels part-of + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/part-of] + value: ozgcloud-operator + - it: should have metadata labels managed-by + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/managed-by] + value: kustomize + + - it: should have rules for ozgcloudelasticsearches resource + asserts: + - contains: + path: rules + content: + apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + + - it: should have rules for ozgcloudelasticsearches/status resource + asserts: + - contains: + path: rules + content: + apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches/status + verbs: + - get \ No newline at end of file diff --git a/ozgcloud-elastic-operator/src/test/helm/rbac/elastic_view_role_test.yaml b/ozgcloud-elastic-operator/src/test/helm/rbac/elastic_view_role_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3be96c45687d853d01a83bec97913657aebe9def --- /dev/null +++ b/ozgcloud-elastic-operator/src/test/helm/rbac/elastic_view_role_test.yaml @@ -0,0 +1,75 @@ +suite: elastic_view_role test +templates: + - templates/rbac/elastic_view_role.yaml +tests: + - it: should have apiVersion + asserts: + - equal: + path: apiVersion + value: rbac.authorization.k8s.io/v1 + - it: should have isKind of + asserts: + - isKind: + of: ClusterRole + + - it: should have metadata name + asserts: + - equal: + path: metadata.name + value: elastic-view-role + - it: should have metadata labels name + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/name] + value: clusterrole + - it: should have metadata labels instance + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/instance] + value: elastic-view-role + - it: should have metadata labels component + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/component] + value: rbac + - it: should have metadata labels created-by + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/created-by] + value: ozgcloud-operator + - it: should have metadata labels part-of + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/part-of] + value: ozgcloud-operator + - it: should have metadata labels managed-by + asserts: + - equal: + path: metadata.labels.[app.kubernetes.io/managed-by] + value: kustomize + + - it: should have rules for ozgcloudelasticsearches resource + asserts: + - contains: + path: rules + content: + apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches + verbs: + - get + - list + - watch + + - it: should have rules for ozgcloudelasticsearches/status resource + asserts: + - contains: + path: rules + content: + apiGroups: + - api.ozgcloud-stack.de + resources: + - ozgcloudelasticsearches/status + verbs: + - get \ No newline at end of file