Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/helm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Helm chart

on:
push:
branches:
- main
paths:
- "charts/**"
- "config/crd/bases/**"
- "config/rbac/**"
- "Makefile"
- ".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: 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

- 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 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:

Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ help: ## Display this help.
manifests: controller-gen ## Generate the CustomResourceDefinition.
"$(CONTROLLER_GEN)" crd paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: helm-chart

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rockstar 🥳

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.
"$(CONTROLLER_GEN)" object paths="./..."
Expand Down Expand Up @@ -95,8 +110,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)
Expand Down
9 changes: 9 additions & 0 deletions charts/runtime-conditions-crd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions charts/runtime-conditions-crd/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rbac:
# Install the convenience admin/editor/viewer ClusterRoles for the
# RuntimeConditionsProfile CRD. Not tied to any controller.
create: true
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why these went down in version number. Not a problem if it's necessary, just not something you usually see.

name: runtimeconditionsprofiles.runtimeconditions.io
spec:
group: runtimeconditions.io
Expand Down