From 62c73e0bb0267373d04c9835c2e642921fd9dcd8 Mon Sep 17 00:00:00 2001 From: Toni Reina Date: Thu, 26 Sep 2024 13:43:19 +0200 Subject: [PATCH] Move crds to templates folder (#19) * Move crds to templates folder * Add parameter to control if qdrantversions CRD is included - Update makefile to add a conditional block to the qdrantversions template - Add parameter to the chart values - Remove duplicated qdrantversions.yaml file * Make bot management and regional CRDs configurable * Add CI to ensure make gen was run --------- Co-authored-by: Bastian Hofmann --- .github/workflows/pr-workflow.yaml | 9 ++ Makefile | 16 ++- .../crds/qdrant.io_qdrantversions.yaml | 104 ------------------ .../qdrant.io_qdrantversions.yaml | 2 + .../qdrant.io_qdrantcloudregions.yaml | 2 + .../qdrant.io_qdrantclusterrestores.yaml | 2 + .../qdrant.io_qdrantclusters.yaml | 2 + ...nt.io_qdrantclusterscheduledsnapshots.yaml | 2 + .../qdrant.io_qdrantclustersnapshots.yaml | 2 + charts/qdrant-operator-crds/values.yaml | 4 + 10 files changed, 39 insertions(+), 106 deletions(-) delete mode 100644 charts/qdrant-operator-crds/crds/qdrant.io_qdrantversions.yaml rename charts/qdrant-operator-crds/{crds-for-cluster-api => templates/management-crds}/qdrant.io_qdrantversions.yaml (98%) rename charts/qdrant-operator-crds/{crds => templates/region-crds}/qdrant.io_qdrantcloudregions.yaml (99%) rename charts/qdrant-operator-crds/{crds => templates/region-crds}/qdrant.io_qdrantclusterrestores.yaml (98%) rename charts/qdrant-operator-crds/{crds => templates/region-crds}/qdrant.io_qdrantclusters.yaml (99%) rename charts/qdrant-operator-crds/{crds => templates/region-crds}/qdrant.io_qdrantclusterscheduledsnapshots.yaml (98%) rename charts/qdrant-operator-crds/{crds => templates/region-crds}/qdrant.io_qdrantclustersnapshots.yaml (99%) diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/pr-workflow.yaml index c958ad5..fd2e555 100644 --- a/.github/workflows/pr-workflow.yaml +++ b/.github/workflows/pr-workflow.yaml @@ -31,3 +31,12 @@ jobs: with: version: v1.59.1 # Specify the golangci-lint version, so we are stable args: --timeout 10m # Increase the timeout to 10 minutes + + - name: Run make gen + run: | + make gen + + - name: Ensure that make gen did not result in changes + uses: CatChen/check-git-status-action@v1 + with: + fail-if-not-clean: true diff --git a/Makefile b/Makefile index 35aa407..1672d04 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,20 @@ gen: manifests generate format vet ## Generate code containing DeepCopy, DeepCop .PHONY: manifests manifests: controller-gen ## Generate CustomResourceDefinition objects. - $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=charts/qdrant-operator-crds/crds - cp charts/qdrant-operator-crds/crds/qdrant.io_qdrantversions.yaml charts/qdrant-operator-crds/crds-for-cluster-api/qdrant.io_qdrantversions.yaml + rm charts/qdrant-operator-crds/templates/management-crds/*.yaml + rm charts/qdrant-operator-crds/templates/region-crds/*.yaml + $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=charts/qdrant-operator-crds/templates + mv charts/qdrant-operator-crds/templates/qdrant.io_qdrantversions.yaml charts/qdrant-operator-crds/templates/management-crds/ + mv charts/qdrant-operator-crds/templates/qdrant*.yaml charts/qdrant-operator-crds/templates/region-crds/ + for file in charts/qdrant-operator-crds/templates/management-crds/*.yaml; do \ + echo "{{ if .Values.includeManagementCRDs }}" | cat - $$file > temp && mv temp $$file; \ + echo "{{ end }}" >> $$file; \ + done + for file in charts/qdrant-operator-crds/templates/region-crds/*.yaml; do \ + echo "{{ if .Values.includeRegionCRDs }}" | cat - $$file > temp && mv temp $$file; \ + echo "{{ end }}" >> $$file; \ + done + helm lint charts/qdrant-operator-crds .PHONY: generate generate: controller-gen crd-ref-docs ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantversions.yaml b/charts/qdrant-operator-crds/crds/qdrant.io_qdrantversions.yaml deleted file mode 100644 index 0762ab8..0000000 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantversions.yaml +++ /dev/null @@ -1,104 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: qdrantversions.qdrant.io -spec: - group: qdrant.io - names: - kind: QdrantVersion - listKind: QdrantVersionList - plural: qdrantversions - shortNames: - - qv - - qvs - singular: qdrantversions - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .spec.version - name: Version - type: string - - jsonPath: .spec.isDefault - name: IsDefault - type: boolean - - jsonPath: .spec.unavailable - name: Unavailable - type: boolean - - jsonPath: .metadata.isEndOfLife - name: IsEndOfLife - type: boolean - name: v1 - schema: - openAPIV3Schema: - description: QdrantVersion is the Schema for the qdrantversions 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: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: QdrantVersionSpec defines the desired state of QdrantVersion - properties: - accountIds: - description: If set, this version can only be used by accounts with - given IDs. - items: - type: string - type: array - accountPrivileges: - description: If set, this version can only be used by accounts that - have been given the listed privileges. - items: - type: string - type: array - image: - description: |- - Full docker image to use for this version. - If empty, a default image will be derived from Version (and qdrant/qdrant is assumed). - type: string - isDefault: - default: false - description: |- - If set, this version is default for new clusters on Cloud. - There should be only 1 Qdrant version in the platform set as default. - type: boolean - isEndOfLife: - default: false - description: If set, this version is no longer actively supported. - type: boolean - releaseNotesURL: - description: Release Notes URL for the specified version - type: string - remarks: - description: General remarks for human reading - type: string - unavailable: - default: false - description: If set, this version cannot be used for new clusters. - type: boolean - version: - description: |- - Version number (should be semver compliant). - E.g. "v1.10.1" - type: string - type: object - type: object - served: true - storage: true - subresources: {} diff --git a/charts/qdrant-operator-crds/crds-for-cluster-api/qdrant.io_qdrantversions.yaml b/charts/qdrant-operator-crds/templates/management-crds/qdrant.io_qdrantversions.yaml similarity index 98% rename from charts/qdrant-operator-crds/crds-for-cluster-api/qdrant.io_qdrantversions.yaml rename to charts/qdrant-operator-crds/templates/management-crds/qdrant.io_qdrantversions.yaml index 0762ab8..f06e8dc 100644 --- a/charts/qdrant-operator-crds/crds-for-cluster-api/qdrant.io_qdrantversions.yaml +++ b/charts/qdrant-operator-crds/templates/management-crds/qdrant.io_qdrantversions.yaml @@ -1,3 +1,4 @@ +{{ if .Values.includeManagementCRDs }} --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -102,3 +103,4 @@ spec: served: true storage: true subresources: {} +{{ end }} diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantcloudregions.yaml b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantcloudregions.yaml similarity index 99% rename from charts/qdrant-operator-crds/crds/qdrant.io_qdrantcloudregions.yaml rename to charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantcloudregions.yaml index 05f292b..ed59e59 100644 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantcloudregions.yaml +++ b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantcloudregions.yaml @@ -1,3 +1,4 @@ +{{ if .Values.includeRegionCRDs }} --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -1727,3 +1728,4 @@ spec: storage: true subresources: status: {} +{{ end }} diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusterrestores.yaml b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusterrestores.yaml similarity index 98% rename from charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusterrestores.yaml rename to charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusterrestores.yaml index 551d027..adddd5f 100644 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusterrestores.yaml +++ b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusterrestores.yaml @@ -1,3 +1,4 @@ +{{ if .Values.includeRegionCRDs }} --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -105,3 +106,4 @@ spec: served: true storage: true subresources: {} +{{ end }} diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusters.yaml similarity index 99% rename from charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml rename to charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusters.yaml index 9f9ce53..685750e 100644 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusters.yaml +++ b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusters.yaml @@ -1,3 +1,4 @@ +{{ if .Values.includeRegionCRDs }} --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -1096,3 +1097,4 @@ spec: served: true storage: true subresources: {} +{{ end }} diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusterscheduledsnapshots.yaml b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusterscheduledsnapshots.yaml similarity index 98% rename from charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusterscheduledsnapshots.yaml rename to charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusterscheduledsnapshots.yaml index 4a53915..bf4d5b0 100644 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclusterscheduledsnapshots.yaml +++ b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclusterscheduledsnapshots.yaml @@ -1,3 +1,4 @@ +{{ if .Values.includeRegionCRDs }} --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -111,3 +112,4 @@ spec: served: true storage: true subresources: {} +{{ end }} diff --git a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclustersnapshots.yaml b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml similarity index 99% rename from charts/qdrant-operator-crds/crds/qdrant.io_qdrantclustersnapshots.yaml rename to charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml index 206cdbb..1efe08a 100644 --- a/charts/qdrant-operator-crds/crds/qdrant.io_qdrantclustersnapshots.yaml +++ b/charts/qdrant-operator-crds/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml @@ -1,3 +1,4 @@ +{{ if .Values.includeRegionCRDs }} --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -125,3 +126,4 @@ spec: served: true storage: true subresources: {} +{{ end }} diff --git a/charts/qdrant-operator-crds/values.yaml b/charts/qdrant-operator-crds/values.yaml index e69de29..fd8c677 100644 --- a/charts/qdrant-operator-crds/values.yaml +++ b/charts/qdrant-operator-crds/values.yaml @@ -0,0 +1,4 @@ +# Include management-crds in the deployment +includeManagementCRDs: false +# Include region-crds in the deployment +includeRegionCRDs: true