@@ -28,7 +28,7 @@ docker-build:
2828 docker build --force-rm --build-arg VERSION=${VERSION} -t " ${OCI_REGISTRY_HOSTNAME} /${OCI_REGISTRY_PROJECT_IMAGES} /${OPERATOR_NAME} :${VERSION} -${ARCH} " -f docker/Dockerfile .
2929
3030# # Chart related targets
31- compile-chart : version crds
31+ compile-chart : version crds crd-annotation
3232
3333version :
3434 cat " deploy/helm/${OPERATOR_NAME} /Chart.yaml" | yq " .version = \" ${VERSION} \" | .appVersion = \" ${VERSION} \" " > " deploy/helm/${OPERATOR_NAME} /Chart.yaml.new"
4040 mkdir -p extra
4141 cargo run --bin stackable-" ${OPERATOR_NAME} " -- crd > extra/crds.yaml
4242
43+ # This adds CRD metadata for artifacthub.io (AH) to Chart.yaml.
44+ # We don't ship CRDs in our Helm charts (anymore), so we need these annotations to provide details.
45+ # We only list the storage version as we're unsure if AH supports more than one (docs unclear).
46+ #
47+ # It appends a single annotation whose value is a list, one entry per CRD.
48+ # Example: For the secret-operator that comes out as:
49+ #
50+ # artifacthub.io/crds: |-
51+ # - kind: SecretClass
52+ # version: v1alpha2
53+ # name: secretclasses.secrets.stackable.tech
54+ # displayName: SecretClass
55+ # description: A SecretClass is a cluster-global Kubernetes resource that defines ...
56+ # - kind: TrustStore
57+ # version: v1alpha1
58+ # name: truststores.secrets.stackable.tech
59+ # displayName: TrustStore
60+ # description: A TrustStore requests information about how to validate secrets ...
61+ #
62+ # The two yq expressions are split out below so it's easier to review and see what's going on.
63+
64+ # READ step: turn every CRD document in extra/crds.yaml into one AH card entry.
65+ # `[.] | map(...)` collects the documents into a list and maps each one to the format (see above) required by AH.
66+ # The result of this is a list of these entries.
67+ CRD_ANNOTATION_READ := [.] | map(.spec.versions |= map(select(.storage == true))) | map({"kind": .spec.names.kind, "version": .spec.versions[0].name, "name": .metadata.name, "displayName": .spec.names.kind, "description": (.spec.versions[0].schema.openAPIV3Schema.description // "")})
68+
69+ # WRITE step: Write that list to Chart.yaml as an annotation value.
70+ # Literal block scalar so it stays readable in Chart.yaml.
71+ CRD_ANNOTATION_WRITE := .annotations["artifacthub.io/crds"] = strenv(CRDS) | .annotations["artifacthub.io/crds"] style="literal"
72+
73+ crd-annotation : crds
74+ @CRDS=" $$ (yq ea -o=yaml '$( CRD_ANNOTATION_READ) ' extra/crds.yaml)" \
75+ yq -i ' $(CRD_ANNOTATION_WRITE)' " deploy/helm/${OPERATOR_NAME} /Chart.yaml"
76+
4377chart-lint : compile-chart
4478 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
4579
0 commit comments