From 454331a2222fa0cb5722266ee7098725ef24f826 Mon Sep 17 00:00:00 2001 From: itvi-1234 Date: Sun, 13 Sep 2026 23:00:56 +0530 Subject: [PATCH 1/2] Add Helm chart and GH Action to publish it as an OCI artifact to GHCR Signed-off-by: itvi-1234 --- .github/workflows/helm-publish.yml | 39 +++++ AGENTS.md | 1 + Makefile | 6 +- charts/runtime-conditions-crd/Chart.yaml | 9 ++ ...nditions.io_runtimeconditionsprofiles.yaml | 137 ++++++++++++++++++ .../templates/rbac.yaml | 60 ++++++++ charts/runtime-conditions-crd/values.yaml | 4 + ...nditions.io_runtimeconditionsprofiles.yaml | 2 +- 8 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/helm-publish.yml create mode 100644 charts/runtime-conditions-crd/Chart.yaml create mode 100644 charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml create mode 100644 charts/runtime-conditions-crd/templates/rbac.yaml create mode 100644 charts/runtime-conditions-crd/values.yaml diff --git a/.github/workflows/helm-publish.yml b/.github/workflows/helm-publish.yml new file mode 100644 index 0000000..561928b --- /dev/null +++ b/.github/workflows/helm-publish.yml @@ -0,0 +1,39 @@ +name: Publish Helm chart + +on: + push: + branches: + - main + paths: + - "charts/**" + - ".github/workflows/helm-publish.yml" + workflow_dispatch: {} + +permissions: {} + +jobs: + publish: + permissions: + contents: read + packages: write + name: Package and push to GHCR + runs-on: ubuntu-latest + steps: + - name: Clone the code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Setup Helm + uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0 + + - name: Log in to GHCR + run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u "${{ github.actor }}" --password-stdin + + - name: Package chart + run: helm package charts/runtime-conditions-crd -d dist + + - name: Push chart as an OCI artifact + run: | + chart_file="$(ls dist/runtime-conditions-crd-*.tgz)" + helm push "$chart_file" oci://ghcr.io/runtimeconditions/charts diff --git a/AGENTS.md b/AGENTS.md index 2d6d4e1..0a801a2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,6 +13,7 @@ manager binary in this repo. | `config/crd/bases/*.yaml` | Generated CRD manifest. DO NOT EDIT by hand - run `make manifests`. | | `config/samples/*.yaml` | Example CR. Edit these if the schema changes. | | `config/rbac/runtimeconditionsprofile_{admin,editor,viewer}_role.yaml` | Convenience ClusterRoles for people/service accounts using the CRD. Not tied to any controller. | +| `charts/runtime-conditions-crd/` | Helm chart wrapping the CRD (+ the same RBAC convenience roles, toggled by `rbac.create`). Published as an OCI artifact to GHCR on push to main. `crds/*.yaml` here is a copy kept in sync by `make manifests` - don't hand-edit it. | After editing `api/v1alpha1/*_types.go`, always run: diff --git a/Makefile b/Makefile index 2090998..6f2029d 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,8 @@ help: ## Display this help. .PHONY: manifests manifests: controller-gen ## Generate the CustomResourceDefinition. "$(CONTROLLER_GEN)" crd paths="./..." output:crd:artifacts:config=config/crd/bases + @cp config/crd/bases/runtimeconditions.io_runtimeconditionsprofiles.yaml \ + charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. @@ -95,8 +97,8 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint ## Tool Versions KUSTOMIZE_VERSION ?= v5.8.1 -CONTROLLER_TOOLS_VERSION ?= v0.21.0 -GOLANGCI_LINT_VERSION ?= v2.13.2 +CONTROLLER_TOOLS_VERSION ?= v0.20.1 +GOLANGCI_LINT_VERSION ?= v2.12.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. $(KUSTOMIZE): $(LOCALBIN) diff --git a/charts/runtime-conditions-crd/Chart.yaml b/charts/runtime-conditions-crd/Chart.yaml new file mode 100644 index 0000000..3d250b3 --- /dev/null +++ b/charts/runtime-conditions-crd/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: runtime-conditions-crd +description: The RuntimeConditionsProfile CustomResourceDefinition (runtimeconditions.io/v1alpha1) +type: application +version: 0.1.0 +appVersion: v1alpha1 +home: https://runtimeconditions.io +sources: + - https://github.com/runtimeconditions/runtime-conditions-crd diff --git a/charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml b/charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml new file mode 100644 index 0000000..112f96b --- /dev/null +++ b/charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml @@ -0,0 +1,137 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: runtimeconditionsprofiles.runtimeconditions.io +spec: + group: runtimeconditions.io + names: + kind: RuntimeConditionsProfile + listKind: RuntimeConditionsProfileList + plural: runtimeconditionsprofiles + shortNames: + - rcp + - rcprofile + - rcprofiles + singular: runtimeconditionsprofile + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + RuntimeConditionsProfile is the Schema for the runtimeconditionsprofiles API. + + Its shape mirrors the Runtime Conditions Profile document directly: + workload/extensions/conditions are top-level fields, not nested under a + spec, the same way ConfigMap's data is top-level. + 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 + conditions: + description: |- + conditions is the workload's external runtime dependencies. Can be + empty. + items: + description: |- + Condition is one external runtime dependency a workload requires. + + name/optional/kind/interface.type are the fields the core spec reserves, + so they're typed and validated here. Everything extension-defined + (additional interface fields, and any extra condition-level fields an + extension's conditionFields declare) is left schemaless. + properties: + interface: + description: |- + ConditionInterface is the workload-facing interface requirement for a + Condition. `type` is the only field the core spec reserves; everything + else here is extension-defined (operations, engine, etc.), so we don't + type it - we keep it and let a validating webhook check it against + whatever extension the profile declared. + properties: + type: + minLength: 1 + type: string + required: + - type + type: object + x-kubernetes-preserve-unknown-fields: true + kind: + description: |- + kind is the extension-defined integration classification, e.g. + "api", "datastore", "cache". Whether a given value is actually + backed by a resolved extension is checked by a webhook, not here. + minLength: 1 + type: string + name: + description: name is a unique label for this condition within the + profile. + minLength: 1 + type: string + optional: + default: false + type: boolean + required: + - interface + - kind + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + x-kubernetes-validations: + - message: condition names must be unique within the profile + rule: self.filter(c, has(c.name)).all(c, self.filter(d, has(d.name) + && d.name == c.name).size() == 1) + extensions: + description: |- + extensions is the list of extension identifiers (absolute URIs) this + profile depends on. Can be empty, can't have duplicates. + items: + format: uri + type: string + type: array + x-kubernetes-validations: + - message: each extension must have a URI scheme + rule: self.all(e, e.matches('^[A-Za-z][A-Za-z0-9+.-]*:')) + - message: extensions must not contain duplicate identifiers + rule: self.all(x, self.exists_one(y, y == x)) + 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 + workload: + description: Workload identifies the single application a profile describes. + properties: + uri: + description: uri is a stable identifier for the workload, e.g. a repo + URL. + minLength: 1 + type: string + version: + description: version is the workload version this profile was generated + for. + minLength: 1 + type: string + required: + - uri + type: object + required: + - conditions + - extensions + - metadata + - workload + type: object + served: true + storage: true diff --git a/charts/runtime-conditions-crd/templates/rbac.yaml b/charts/runtime-conditions-crd/templates/rbac.yaml new file mode 100644 index 0000000..711fd98 --- /dev/null +++ b/charts/runtime-conditions-crd/templates/rbac.yaml @@ -0,0 +1,60 @@ +{{- if .Values.rbac.create }} +# Convenience ClusterRoles for people/service accounts using the CRD. Not +# tied to any controller in this repo - hand these out as needed. + +# Full control over RuntimeConditionsProfile resources. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: runtime-conditions-crd + app.kubernetes.io/managed-by: {{ .Release.Service }} + name: runtimeconditionsprofile-admin-role +rules: +- apiGroups: + - runtimeconditions.io + resources: + - runtimeconditionsprofiles + verbs: + - '*' +--- +# Create/update/delete RuntimeConditionsProfile resources. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: runtime-conditions-crd + app.kubernetes.io/managed-by: {{ .Release.Service }} + name: runtimeconditionsprofile-editor-role +rules: +- apiGroups: + - runtimeconditions.io + resources: + - runtimeconditionsprofiles + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +--- +# Read-only access to RuntimeConditionsProfile resources. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: runtime-conditions-crd + app.kubernetes.io/managed-by: {{ .Release.Service }} + name: runtimeconditionsprofile-viewer-role +rules: +- apiGroups: + - runtimeconditions.io + resources: + - runtimeconditionsprofiles + verbs: + - get + - list + - watch +{{- end }} diff --git a/charts/runtime-conditions-crd/values.yaml b/charts/runtime-conditions-crd/values.yaml new file mode 100644 index 0000000..718e6d5 --- /dev/null +++ b/charts/runtime-conditions-crd/values.yaml @@ -0,0 +1,4 @@ +rbac: + # Install the convenience admin/editor/viewer ClusterRoles for the + # RuntimeConditionsProfile CRD. Not tied to any controller. + create: true diff --git a/config/crd/bases/runtimeconditions.io_runtimeconditionsprofiles.yaml b/config/crd/bases/runtimeconditions.io_runtimeconditionsprofiles.yaml index 0f60423..112f96b 100644 --- a/config/crd/bases/runtimeconditions.io_runtimeconditionsprofiles.yaml +++ b/config/crd/bases/runtimeconditions.io_runtimeconditionsprofiles.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.21.0 + controller-gen.kubebuilder.io/version: v0.20.1 name: runtimeconditionsprofiles.runtimeconditions.io spec: group: runtimeconditions.io From 89571988a935890509041d375cdf4c5cf6067ee8 Mon Sep 17 00:00:00 2001 From: itvi-1234 Date: Mon, 14 Sep 2026 18:37:09 +0530 Subject: [PATCH 2/2] Generate Helm chart CRD and RBAC from source instead of committing copies Signed-off-by: itvi-1234 --- .github/workflows/helm-publish.yml | 6 + .gitignore | 5 + AGENTS.md | 2 +- Makefile | 13 ++ ...nditions.io_runtimeconditionsprofiles.yaml | 137 ------------------ .../templates/rbac.yaml | 60 -------- 6 files changed, 25 insertions(+), 198 deletions(-) delete mode 100644 charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml delete mode 100644 charts/runtime-conditions-crd/templates/rbac.yaml diff --git a/.github/workflows/helm-publish.yml b/.github/workflows/helm-publish.yml index 561928b..734b1bd 100644 --- a/.github/workflows/helm-publish.yml +++ b/.github/workflows/helm-publish.yml @@ -6,6 +6,9 @@ on: - main paths: - "charts/**" + - "config/crd/bases/**" + - "config/rbac/**" + - "Makefile" - ".github/workflows/helm-publish.yml" workflow_dispatch: {} @@ -27,6 +30,9 @@ jobs: - name: Setup Helm uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0 + - name: Prepare chart (copy CRD, derive RBAC template) + run: make helm-chart + - name: Log in to GHCR run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u "${{ github.actor }}" --password-stdin diff --git a/.gitignore b/.gitignore index 9f0f3a1..fa5acb5 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,8 @@ go.work # Kubeconfig might contain secrets *.kubeconfig + +# Copied/derived into the Helm chart by `make helm-chart` - config/crd/bases +# and config/rbac are the source of truth, not these. +/charts/runtime-conditions-crd/crds/*.yaml +/charts/runtime-conditions-crd/templates/rbac.yaml diff --git a/AGENTS.md b/AGENTS.md index 0a801a2..792df04 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,7 +13,7 @@ manager binary in this repo. | `config/crd/bases/*.yaml` | Generated CRD manifest. DO NOT EDIT by hand - run `make manifests`. | | `config/samples/*.yaml` | Example CR. Edit these if the schema changes. | | `config/rbac/runtimeconditionsprofile_{admin,editor,viewer}_role.yaml` | Convenience ClusterRoles for people/service accounts using the CRD. Not tied to any controller. | -| `charts/runtime-conditions-crd/` | Helm chart wrapping the CRD (+ the same RBAC convenience roles, toggled by `rbac.create`). Published as an OCI artifact to GHCR on push to main. `crds/*.yaml` here is a copy kept in sync by `make manifests` - don't hand-edit it. | +| `charts/runtime-conditions-crd/` | Helm chart wrapping the CRD (+ the same RBAC convenience roles, toggled by `rbac.create`). Published as an OCI artifact to GHCR on push to main. `crds/*.yaml` and `templates/rbac.yaml` are derived from `config/crd/bases/` and `config/rbac/` by `make helm-chart` - not committed, don't hand-edit them. Run `make helm-chart` before `helm lint`/`helm package` locally. | After editing `api/v1alpha1/*_types.go`, always run: diff --git a/Makefile b/Makefile index 6f2029d..c6ef91e 100644 --- a/Makefile +++ b/Makefile @@ -35,8 +35,21 @@ help: ## Display this help. .PHONY: manifests manifests: controller-gen ## Generate the CustomResourceDefinition. "$(CONTROLLER_GEN)" crd paths="./..." output:crd:artifacts:config=config/crd/bases + +.PHONY: helm-chart +helm-chart: ## Copy the CRD and derive the RBAC template into charts/runtime-conditions-crd. Not committed - run before helm package/lint. + @mkdir -p charts/runtime-conditions-crd/crds charts/runtime-conditions-crd/templates @cp config/crd/bases/runtimeconditions.io_runtimeconditionsprofiles.yaml \ charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml + @{ \ + echo '{{- if .Values.rbac.create }}'; \ + sed 's/managed-by: kustomize/managed-by: {{ .Release.Service }}/' config/rbac/runtimeconditionsprofile_admin_role.yaml; \ + echo '---'; \ + sed 's/managed-by: kustomize/managed-by: {{ .Release.Service }}/' config/rbac/runtimeconditionsprofile_editor_role.yaml; \ + echo '---'; \ + sed 's/managed-by: kustomize/managed-by: {{ .Release.Service }}/' config/rbac/runtimeconditionsprofile_viewer_role.yaml; \ + echo '{{- end }}'; \ + } > charts/runtime-conditions-crd/templates/rbac.yaml .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. diff --git a/charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml b/charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml deleted file mode 100644 index 112f96b..0000000 --- a/charts/runtime-conditions-crd/crds/runtimeconditions.io_runtimeconditionsprofiles.yaml +++ /dev/null @@ -1,137 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.20.1 - name: runtimeconditionsprofiles.runtimeconditions.io -spec: - group: runtimeconditions.io - names: - kind: RuntimeConditionsProfile - listKind: RuntimeConditionsProfileList - plural: runtimeconditionsprofiles - shortNames: - - rcp - - rcprofile - - rcprofiles - singular: runtimeconditionsprofile - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: |- - RuntimeConditionsProfile is the Schema for the runtimeconditionsprofiles API. - - Its shape mirrors the Runtime Conditions Profile document directly: - workload/extensions/conditions are top-level fields, not nested under a - spec, the same way ConfigMap's data is top-level. - 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 - conditions: - description: |- - conditions is the workload's external runtime dependencies. Can be - empty. - items: - description: |- - Condition is one external runtime dependency a workload requires. - - name/optional/kind/interface.type are the fields the core spec reserves, - so they're typed and validated here. Everything extension-defined - (additional interface fields, and any extra condition-level fields an - extension's conditionFields declare) is left schemaless. - properties: - interface: - description: |- - ConditionInterface is the workload-facing interface requirement for a - Condition. `type` is the only field the core spec reserves; everything - else here is extension-defined (operations, engine, etc.), so we don't - type it - we keep it and let a validating webhook check it against - whatever extension the profile declared. - properties: - type: - minLength: 1 - type: string - required: - - type - type: object - x-kubernetes-preserve-unknown-fields: true - kind: - description: |- - kind is the extension-defined integration classification, e.g. - "api", "datastore", "cache". Whether a given value is actually - backed by a resolved extension is checked by a webhook, not here. - minLength: 1 - type: string - name: - description: name is a unique label for this condition within the - profile. - minLength: 1 - type: string - optional: - default: false - type: boolean - required: - - interface - - kind - type: object - x-kubernetes-preserve-unknown-fields: true - type: array - x-kubernetes-validations: - - message: condition names must be unique within the profile - rule: self.filter(c, has(c.name)).all(c, self.filter(d, has(d.name) - && d.name == c.name).size() == 1) - extensions: - description: |- - extensions is the list of extension identifiers (absolute URIs) this - profile depends on. Can be empty, can't have duplicates. - items: - format: uri - type: string - type: array - x-kubernetes-validations: - - message: each extension must have a URI scheme - rule: self.all(e, e.matches('^[A-Za-z][A-Za-z0-9+.-]*:')) - - message: extensions must not contain duplicate identifiers - rule: self.all(x, self.exists_one(y, y == x)) - 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 - workload: - description: Workload identifies the single application a profile describes. - properties: - uri: - description: uri is a stable identifier for the workload, e.g. a repo - URL. - minLength: 1 - type: string - version: - description: version is the workload version this profile was generated - for. - minLength: 1 - type: string - required: - - uri - type: object - required: - - conditions - - extensions - - metadata - - workload - type: object - served: true - storage: true diff --git a/charts/runtime-conditions-crd/templates/rbac.yaml b/charts/runtime-conditions-crd/templates/rbac.yaml deleted file mode 100644 index 711fd98..0000000 --- a/charts/runtime-conditions-crd/templates/rbac.yaml +++ /dev/null @@ -1,60 +0,0 @@ -{{- if .Values.rbac.create }} -# Convenience ClusterRoles for people/service accounts using the CRD. Not -# tied to any controller in this repo - hand these out as needed. - -# Full control over RuntimeConditionsProfile resources. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: runtime-conditions-crd - app.kubernetes.io/managed-by: {{ .Release.Service }} - name: runtimeconditionsprofile-admin-role -rules: -- apiGroups: - - runtimeconditions.io - resources: - - runtimeconditionsprofiles - verbs: - - '*' ---- -# Create/update/delete RuntimeConditionsProfile resources. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: runtime-conditions-crd - app.kubernetes.io/managed-by: {{ .Release.Service }} - name: runtimeconditionsprofile-editor-role -rules: -- apiGroups: - - runtimeconditions.io - resources: - - runtimeconditionsprofiles - verbs: - - create - - delete - - get - - list - - patch - - update - - watch ---- -# Read-only access to RuntimeConditionsProfile resources. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: runtime-conditions-crd - app.kubernetes.io/managed-by: {{ .Release.Service }} - name: runtimeconditionsprofile-viewer-role -rules: -- apiGroups: - - runtimeconditions.io - resources: - - runtimeconditionsprofiles - verbs: - - get - - list - - watch -{{- end }}