diff --git a/README.adoc b/README.adoc index dcb7f085..0fb0a575 100644 --- a/README.adoc +++ b/README.adoc @@ -48,11 +48,6 @@ Target repositories are configured in `repositories.yaml` in the following form: |pretty_string | The actual name of the product, including whitespaces and proper capitalization. This is intended to be used in doc or man files or similar things. -|include_crds -| Whether to include files from the `deploy/crd` folder into the os package. - -*Default*: true - |include_productconfig | Whether to include files from the `deploy/config-spec` folder into the os package. diff --git a/playbook/update_repo.yaml b/playbook/update_repo.yaml index 3420f9ea..346d719a 100644 --- a/playbook/update_repo.yaml +++ b/playbook/update_repo.yaml @@ -49,7 +49,7 @@ - name: Ensure directories exist file: - path: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[product]]', operator.product_string) | dirname }}" + path: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[operator]]', operator.name) | dirname }}" state: directory with_items: - "{{ files_j2.files }}" @@ -62,7 +62,7 @@ template: src: "{{ item.path }}" mode: "preserve" - dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[product]]', operator.product_string) | regex_replace('.j2$', '') }}" + dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[operator]]', operator.name) | regex_replace('.j2$', '') }}" variable_start_string: "{[" variable_end_string: "}]" block_start_string: "{[%" @@ -74,7 +74,7 @@ copy: src: "{{ item.path }}" mode: "preserve" - dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[product]]', operator.product_string)}}" + dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[operator]]', operator.name)}}" with_items: "{{ files_normal.files }}" register: file_result diff --git a/repositories.yaml b/repositories.yaml index 776f425f..83bdc958 100644 --- a/repositories.yaml +++ b/repositories.yaml @@ -50,6 +50,12 @@ repositories: url: stackabletech/druid-operator.git product_string: druid pretty_string: Apache Druid + - name: secret-operator + url: stackabletech/secret-operator.git + product_string: secret-operator + pretty_string: Stackable Secret Operator + run_as: custom + include_productconfig: false # Anything specified in the retired_files variable will be deleted. # This is uncommented as I had issues with everything being deleted when this was just present as an empty key. diff --git a/template/Makefile.j2 b/template/Makefile.j2 index 41158c79..118f28c3 100644 --- a/template/Makefile.j2 +++ b/template/Makefile.j2 @@ -10,22 +10,22 @@ TAG := $(shell git rev-parse --short HEAD) -VERSION := $(shell cargo metadata --format-version 1 | jq '.packages[] | select(.name=="stackable-{[ operator.product_string }]-operator") | .version') +VERSION := $(shell cargo metadata --format-version 1 | jq '.packages[] | select(.name=="stackable-{[ operator.name }]") | .version') ## Docker related targets docker-build: - docker build --force-rm -t "docker.stackable.tech/stackable/{[ operator.product_string }]-operator:${VERSION}" -f docker/Dockerfile . + docker build --force-rm -t "docker.stackable.tech/stackable/{[ operator.name }]:${VERSION}" -f docker/Dockerfile . {[% if operator.product_string in ['opa'] %}] docker build --force-rm -t "docker.stackable.tech/stackable/{[ operator.product_string }]-bundle-builder:${VERSION}" -f docker/Dockerfile.builder . {[% endif %}] docker-build-latest: docker-build - docker tag "docker.stackable.tech/stackable/{[ operator.product_string }]-operator:${VERSION}" \ - "docker.stackable.tech/stackable/{[ operator.product_string }]-operator:latest" + docker tag "docker.stackable.tech/stackable/{[ operator.name }]:${VERSION}" \ + "docker.stackable.tech/stackable/{[ operator.name }]:latest" docker-publish: echo "${NEXUS_PASSWORD}" | docker login --username github --password-stdin docker.stackable.tech - docker push --all-tags docker.stackable.tech/stackable/{[ operator.product_string }]-operator + docker push --all-tags docker.stackable.tech/stackable/{[ operator.name }] {[% if operator.product_string in ['opa'] %}] docker push --all-tags docker.stackable.tech/stackable/{[ operator.product_string }]-bundle-builder {[% endif %}] @@ -38,21 +38,21 @@ docker-release: docker-build-latest docker-publish compile-chart: version crds config chart-clean: - rm -rf deploy/helm/{[ operator.product_string }]-operator/configs - rm -rf deploy/helm/{[ operator.product_string }]-operator/crds + rm -rf deploy/helm/{[ operator.name }]/configs + rm -rf deploy/helm/{[ operator.name }]/crds version: - yq eval -i '.version = ${VERSION} | .appVersion = ${VERSION}' deploy/helm/{[ operator.product_string }]-operator/Chart.yaml + yq eval -i '.version = ${VERSION} | .appVersion = ${VERSION}' deploy/helm/{[ operator.name }]/Chart.yaml config: if [ -d "deploy/config-spec/" ]; then\ - mkdir -p deploy/helm/{[ operator.product_string }]-operator/configs;\ - cp -r deploy/config-spec/* deploy/helm/{[ operator.product_string }]-operator/configs;\ + mkdir -p deploy/helm/{[ operator.name }]/configs;\ + cp -r deploy/config-spec/* deploy/helm/{[ operator.name }]/configs;\ fi crds: - mkdir -p deploy/helm/{[ operator.product_string }]-operator/crds - cat deploy/crd/*.yaml | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > deploy/helm/{[ operator.product_string }]-operator/crds/crds.yaml + mkdir -p deploy/helm/{[ operator.name }]/crds + cargo run crd | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > deploy/helm/{[ operator.name }]/crds/crds.yaml chart-lint: compile-chart docker run -it -v $(shell pwd):/build/helm-charts -w /build/helm-charts quay.io/helmpack/chart-testing:v3.5.0 ct lint --config deploy/helm/ct.yaml @@ -65,11 +65,4 @@ clean-manifests: generate-manifests: clean-manifests compile-chart ./scripts/generate-manifests.sh -clean-crds: - rm -rf deploy/crd/* - -generate-crds: - touch rust/operator-binary/build.rs - cargo build - -regenerate-charts: clean-crds chart-clean clean-manifests generate-crds compile-chart generate-manifests +regenerate-charts: chart-clean clean-manifests compile-chart generate-manifests diff --git a/template/deny.toml.j2 b/template/deny.toml.j2 index bbd452fc..16533ab3 100644 --- a/template/deny.toml.j2 +++ b/template/deny.toml.j2 @@ -35,8 +35,8 @@ allow = [ exceptions = [ { name = "stackable-{[ operator.product_string }]-crd", allow = ["OSL-3.0"] }, - { name = "stackable-{[ operator.product_string }]-operator", allow = ["OSL-3.0"] }, - { name = "stackable-{[ operator.product_string }]-operator-binary", allow = ["OSL-3.0"] }, + { name = "stackable-{[ operator.name }]", allow = ["OSL-3.0"] }, + { name = "stackable-{[ operator.name }]-binary", allow = ["OSL-3.0"] }, {[% if operator.extra_crates is not undefined %}]{[% for crate in operator.extra_crates %}]{ name = "{[crate}]", allow = ["OSL-3.0"] }, {[% endfor %}]{[% endif -%}] ] diff --git a/template/deploy/helm/[[product]]-operator/.helmignore b/template/deploy/helm/[[operator]]/.helmignore similarity index 100% rename from template/deploy/helm/[[product]]-operator/.helmignore rename to template/deploy/helm/[[operator]]/.helmignore diff --git a/template/deploy/helm/[[product]]-operator/Chart.yaml.j2 b/template/deploy/helm/[[operator]]/Chart.yaml.j2 similarity index 64% rename from template/deploy/helm/[[product]]-operator/Chart.yaml.j2 rename to template/deploy/helm/[[operator]]/Chart.yaml.j2 index 809b3c58..492e00ff 100644 --- a/template/deploy/helm/[[product]]-operator/Chart.yaml.j2 +++ b/template/deploy/helm/[[operator]]/Chart.yaml.j2 @@ -1,11 +1,11 @@ --- apiVersion: v2 -name: {[ operator.product_string }]-operator +name: {[ operator.name }] version: appVersion: "" description: The Stackable Operator for {[ operator.pretty_string }] -home: https://github.com/stackabletech/{[ operator.product_string }]-operator +home: https://github.com/stackabletech/{[ operator.name }] maintainers: - name: Stackable diff --git a/template/deploy/helm/[[product]]-operator/README.md.j2 b/template/deploy/helm/[[operator]]/README.md.j2 similarity index 72% rename from template/deploy/helm/[[product]]-operator/README.md.j2 rename to template/deploy/helm/[[operator]]/README.md.j2 index cfe90874..65914e43 100644 --- a/template/deploy/helm/[[product]]-operator/README.md.j2 +++ b/template/deploy/helm/[[operator]]/README.md.j2 @@ -13,15 +13,16 @@ This Helm Chart can be used to install Custom Resource Definitions and the Opera # From the root of the operator repository make compile-chart -helm install {[ operator.product_string }]-operator deploy/helm/{[ operator.product_string }]-operator +helm install {[ operator.name }] deploy/helm/{[ operator.name }] ``` ## Usage of the CRDs The usage of this operator and its CRDs is described in the [documentation](https://docs.stackable.tech/{[ operator.product_string }]/index.html) -The operator has example requests included in the [`/examples`](https://github.com/stackabletech/{[ operator.product_string }]/operator/tree/main/examples) directory. +The operator has example requests included in the [`/examples`](https://github.com/stackabletech/{[ operator.name }]/tree/main/examples) directory. ## Links -https://github.com/stackabletech/{[ operator.product_string }]-operator +https://github.com/stackabletech/{[ operator.name }] + diff --git a/template/deploy/helm/[[product]]-operator/templates/_helpers.tpl b/template/deploy/helm/[[operator]]/templates/_helpers.tpl similarity index 100% rename from template/deploy/helm/[[product]]-operator/templates/_helpers.tpl rename to template/deploy/helm/[[operator]]/templates/_helpers.tpl diff --git a/template/deploy/helm/[[product]]-operator/templates/configmap.yaml b/template/deploy/helm/[[operator]]/templates/configmap.yaml similarity index 100% rename from template/deploy/helm/[[product]]-operator/templates/configmap.yaml rename to template/deploy/helm/[[operator]]/templates/configmap.yaml diff --git a/template/deploy/helm/[[product]]-operator/templates/deployment.yaml.j2 b/template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 similarity index 93% rename from template/deploy/helm/[[product]]-operator/templates/deployment.yaml.j2 rename to template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 index 9b560423..19e27bf0 100644 --- a/template/deploy/helm/[[product]]-operator/templates/deployment.yaml.j2 +++ b/template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 @@ -1,3 +1,4 @@ +{[% if operator.run_as is undefined or operator.run_as == "deployment" %}] --- apiVersion: apps/v1 kind: Deployment @@ -66,3 +67,6 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} +{[% else %}] +# Templated Deployment disabled for this operator +{[% endif %}] diff --git a/template/deploy/helm/[[product]]-operator/templates/serviceaccount.yaml.j2 b/template/deploy/helm/[[operator]]/templates/serviceaccount.yaml.j2 similarity index 100% rename from template/deploy/helm/[[product]]-operator/templates/serviceaccount.yaml.j2 rename to template/deploy/helm/[[operator]]/templates/serviceaccount.yaml.j2 diff --git a/template/deploy/helm/[[product]]-operator/values.yaml.j2 b/template/deploy/helm/[[operator]]/values.yaml.j2 similarity index 88% rename from template/deploy/helm/[[product]]-operator/values.yaml.j2 rename to template/deploy/helm/[[operator]]/values.yaml.j2 index a403703d..06665dc1 100644 --- a/template/deploy/helm/[[product]]-operator/values.yaml.j2 +++ b/template/deploy/helm/[[operator]]/values.yaml.j2 @@ -1,7 +1,7 @@ -# Default values for {[ operator.product_string }]-operator. +# Default values for {[ operator.name }]. --- image: - repository: docker.stackable.tech/stackable/{[ operator.product_string }]-operator + repository: docker.stackable.tech/stackable/{[ operator.name }] pullPolicy: IfNotPresent imagePullSecrets: [] diff --git a/template/docker/Dockerfile.j2 b/template/docker/Dockerfile.j2 index f1a2df17..72753266 100644 --- a/template/docker/Dockerfile.j2 +++ b/template/docker/Dockerfile.j2 @@ -13,14 +13,14 @@ RUN microdnf update --disablerepo=* --enablerepo=ubi-8-baseos --enablerepo=ubi-8 && microdnf install --disablerepo=* --enablerepo=ubi-8-baseos shadow-utils -y \ && rm -rf /var/cache/yum -COPY --from=builder /app/stackable-{[ operator.product_string }]-operator / +COPY --from=builder /app/stackable-{[ operator.name }] / {[% if operator.include_productconfig is undefined or operator.include_productconfig == true %}] -COPY deploy/config-spec/properties.yaml /etc/stackable/{[ operator.product_string }]-operator/config-spec/properties.yaml +COPY deploy/config-spec/properties.yaml /etc/stackable/{[ operator.name }]/config-spec/properties.yaml {[% endif %}] RUN groupadd -g 1000 stackable && adduser -u 1000 -g stackable -c 'Stackable Operator' stackable USER 1000:1000 -ENTRYPOINT ["/stackable-{[ operator.product_string }]-operator"] +ENTRYPOINT ["/stackable-{[ operator.name }]"] CMD ["run"] diff --git a/template/scripts/generate-manifests.sh.j2 b/template/scripts/generate-manifests.sh.j2 index 73363b0d..11c0d3ff 100755 --- a/template/scripts/generate-manifests.sh.j2 +++ b/template/scripts/generate-manifests.sh.j2 @@ -7,8 +7,8 @@ tmp=$(mktemp -d ./manifests-XXXXX) helm template --output-dir "$tmp" \ --include-crds \ - --name-template {[ operator.product_string }]-operator \ - deploy/helm/{[ operator.product_string }]-operator + --name-template {[ operator.name }] \ + deploy/helm/{[ operator.name }] while IFS= read -r -d '' file do @@ -17,6 +17,6 @@ do sed -i '/# Source: .*/d' "$file" done < <(find "$tmp" -type f) -cp -r "$tmp"/{[ operator.product_string }]-operator/*/* deploy/manifests/ +cp -r "$tmp"/{[ operator.name }]/*/* deploy/manifests/ rm -rf "$tmp"