Skip to content

Commit 65f00a3

Browse files
chore: Generated commit to update templated files since the last template run up to stackabletech/operator-templating@86d5117 (#820)
Reference-to: stackabletech/operator-templating@86d5117 (Various fixes to Helm charts as well as support for ArtifactHub)
1 parent ab8a356 commit 65f00a3

7 files changed

Lines changed: 102 additions & 24 deletions

File tree

.github/workflows/build.yaml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@ jobs:
6565
outputs:
6666
detected: ${{ steps.check.outputs.detected }}
6767

68+
helm-lint:
69+
name: Lint Helm Chart
70+
needs:
71+
- detect-changes
72+
if: needs.detect-changes.outputs.detected == 'true'
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout Repository
76+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
77+
with:
78+
persist-credentials: false
79+
80+
# Validates the chart templates and, where a values.schema.json exists, the
81+
# default values against it.
82+
#
83+
# The chart cannot render without a registry overlay, because image.repository
84+
# is only set there.
85+
- name: Lint Helm Chart
86+
env:
87+
CHART_DIRECTORY: deploy/helm/hdfs-operator
88+
run: |
89+
for registry in oci.stackable.tech quay.io; do
90+
helm lint "$CHART_DIRECTORY" --values "$CHART_DIRECTORY/values/${registry}.yaml"
91+
done
92+
6893
cargo-udeps:
6994
name: Run cargo-udeps
7095
if: needs.detect-changes.outputs.detected == 'true'
@@ -151,12 +176,18 @@ jobs:
151176
152177
CURRENT_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stackable-hdfs-operator") | .version')
153178
179+
# Include a PR suffix if this workflow is triggered by a PR
154180
if [ "$GITHUB_EVENT_NAME" == 'pull_request' ]; then
155-
# Include a PR suffix if this workflow is triggered by a PR
156-
if [ "$PR_BASE_REF" == 'main' ]; then
157-
NEW_VERSION="0.0.0-pr$PR_NUMBER"
158-
else
181+
# If the PR is raised against a release branch, use the current operator version and
182+
# append a suffix to it. If the PR is raised against ANY other base branch, use the
183+
# established 0.0.0-prXXX tag.
184+
if [[ "$PR_BASE_REF" =~ ^release-[0-9]{2}\.[0-9]{1,2}$ ]]; then
159185
NEW_VERSION="$CURRENT_VERSION-pr$PR_NUMBER"
186+
else
187+
# NOTE (@Techassi): One could argue that we should warn the developer when the current
188+
# version is not 0.0.0-dev (and the PR potentially doesn't target main) that we will
189+
# still rewrite the version to 0.0.0-prXXX.
190+
NEW_VERSION="0.0.0-pr$PR_NUMBER"
160191
fi
161192
else
162193
# Just use the current version if this workflow is run on push, schedule, etc...
@@ -338,6 +369,7 @@ jobs:
338369
needs:
339370
- detect-changes
340371
- cargo-udeps
372+
- helm-lint
341373
- build-container-image
342374
- publish-index-manifest
343375
- publish-helm-chart

.github/workflows/integration-test-profile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
PROFILE_INPUT: ${{ inputs.test-profile }}
3333
shell: bash
3434
run: |
35-
if [ "$EVENT_NAME" = "schedule" ]; then
35+
if [ "$EVENT_NAME" == "schedule" ]; then
3636
echo "PROFILE=schedule" | tee -a "$GITHUB_OUTPUT"
3737
else
3838
echo "PROFILE=${PROFILE_INPUT}" | tee -a "$GITHUB_OUTPUT"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# oras push oci.stackable.tech/sdp-charts/hdfs-operator:artifacthub.io \
88
# --config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
9-
# artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
9+
# artifacthub-repo.yaml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
1010
#
1111
# Reference: https://github.com/artifacthub/hub/blob/master/docs/metadata/artifacthub-repo.yml and https://artifacthub.io/docs/topics/repositories/#verified-publisher
1212

@@ -16,10 +16,10 @@
1616
# Every operator that gets this file has an ID. An operator without an Artifact Hub
1717
# repository excludes the file entirely via `ignored_files` in
1818
# config/repositories.yaml, the way druid does while it is being removed from SDP.
19-
repositoryID: 2d19d362-65c5-47ab-b04a-217b5bd32f2c
19+
repositoryID: "2d19d362-65c5-47ab-b04a-217b5bd32f2c"
2020

2121
# Versions Artifact Hub should not index.
2222
# This excludes all dev/rc/pr charts.
2323
ignore:
24-
- name: hdfs-operator
25-
version: '-(dev|rc|pr)'
24+
- name: "hdfs-operator"
25+
version: "-(dev|rc|pr)"

deploy/helm/hdfs-operator/templates/_helpers.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ Create the name of the service account to use
6565
*/}}
6666
{{- define "operator.serviceAccountName" -}}
6767
{{- if .Values.serviceAccount.create }}
68-
{{- default (include "operator.fullname" .) .Values.serviceAccount.name }}
68+
{{- default (printf "%s-serviceaccount" (include "operator.fullname" .)) .Values.serviceAccount.name }}
6969
{{- else }}
70-
{{- default "default" .Values.serviceAccount.name }}
70+
{{- required "serviceAccount.name is required when serviceAccount.create is false, because the chart then does not create a ServiceAccount for the operator to run as." .Values.serviceAccount.name }}
7171
{{- end }}
7272
{{- end }}
7373

deploy/helm/hdfs-operator/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
imagePullSecrets:
3030
{{- toYaml . | nindent 8 }}
3131
{{- end }}
32-
serviceAccountName: {{ include "operator.fullname" . }}-serviceaccount
32+
serviceAccountName: {{ include "operator.serviceAccountName" . }}
3333
securityContext:
3434
{{- toYaml .Values.podSecurityContext | nindent 8 }}
3535
containers:

deploy/helm/hdfs-operator/templates/serviceaccount.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@
33
apiVersion: v1
44
kind: ServiceAccount
55
metadata:
6-
name: {{ include "operator.fullname" . }}-serviceaccount
6+
name: {{ include "operator.serviceAccountName" . }}
77
labels:
88
{{- include "operator.labels" . | nindent 4 }}
99
{{- with .Values.serviceAccount.annotations }}
1010
annotations:
1111
{{- toYaml . | nindent 4 }}
1212
{{- end }}
13+
{{- end }}
1314
---
1415
apiVersion: rbac.authorization.k8s.io/v1
15-
# This cluster role binding allows anyone in the "manager" group to read secrets in any namespace.
16+
# Grants the operator ServiceAccount the ClusterRole from roles.yaml, which is what lets the
17+
# operator watch and manage its custom resources across the cluster.
1618
kind: ClusterRoleBinding
1719
metadata:
1820
name: {{ include "operator.fullname" . }}-clusterrolebinding
1921
labels:
2022
{{- include "operator.labels" . | nindent 4 }}
2123
subjects:
2224
- kind: ServiceAccount
23-
name: {{ include "operator.fullname" . }}-serviceaccount
25+
name: {{ include "operator.serviceAccountName" . }}
2426
namespace: {{ .Release.Namespace }}
2527
roleRef:
2628
kind: ClusterRole
2729
name: {{ include "operator.fullname" . }}-clusterrole
2830
apiGroup: rbac.authorization.k8s.io
29-
{{- end }}

scripts/run-tests

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,38 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
144144
default=os.path.join("tests", "_work"),
145145
)
146146

147+
parser.add_argument(
148+
"--template-dir",
149+
help="Directory containing the test templates (default tests/templates/kuttl)",
150+
type=str,
151+
required=False,
152+
default=os.path.join("tests", "templates", "kuttl"),
153+
)
154+
155+
parser.add_argument(
156+
"--test-definition",
157+
help="Path to the test definition file (default tests/test-definition.yaml)",
158+
type=str,
159+
required=False,
160+
default=os.path.join("tests", "test-definition.yaml"),
161+
)
162+
163+
parser.add_argument(
164+
"--kuttl-test",
165+
help="Path to the kuttl test definition file (default tests/kuttl-test.yaml.jinja2)",
166+
type=str,
167+
required=False,
168+
default=os.path.join("tests", "kuttl-test.yaml.jinja2"),
169+
)
170+
171+
parser.add_argument(
172+
"--release-file",
173+
help="Path to the test release file (default tests/release.yaml)",
174+
type=str,
175+
required=False,
176+
default=os.path.join("tests", "release.yaml"),
177+
)
178+
147179
parser.add_argument(
148180
"--listener-class-preset",
149181
help="Choose the ListenerClass preset",
@@ -201,7 +233,7 @@ def have_requirements() -> None:
201233

202234
@contextlib.contextmanager
203235
def release_file(
204-
operators: list[tuple[str, str]], skip_ops: list[str]
236+
release_file: str, operators: list[tuple[str, str]], skip_ops: list[str]
205237
) -> collections.abc.Generator[str, None, None]:
206238
"""Generate a (possibly modified) copy of the release.yaml file.
207239
@@ -217,7 +249,6 @@ def release_file(
217249
"""
218250

219251
def _patch():
220-
release_file = os.path.join("tests", "release.yaml")
221252
# A marker to validate that all ops were patched
222253
patched_release = []
223254
with open(release_file, "r") as f:
@@ -334,16 +365,23 @@ def maybe_install_release(
334365
raise TestRunnerException()
335366

336367

337-
def gen_tests(test_suite: str, namespace: str, work_dir: str) -> None:
368+
def gen_tests(
369+
test_definition: str,
370+
kuttl_test: str,
371+
template_dir: str,
372+
test_suite: str,
373+
namespace: str,
374+
work_dir: str,
375+
) -> None:
338376
try:
339377
beku_cmd = [
340378
"beku",
341379
"--test_definition",
342-
os.path.join("tests", "test-definition.yaml"),
380+
test_definition,
343381
"--kuttl_test",
344-
os.path.join("tests", "kuttl-test.yaml.jinja2"),
382+
kuttl_test,
345383
"--template_dir",
346-
os.path.join("tests", "templates", "kuttl"),
384+
template_dir,
347385
"--output_dir",
348386
work_dir,
349387
]
@@ -448,8 +486,15 @@ def main(argv) -> int:
448486
opts = parse_args(argv[1:])
449487
logging.basicConfig(encoding="utf-8", level=opts.log_level)
450488
have_requirements()
451-
gen_tests(opts.test_suite, opts.namespace, opts.work_dir)
452-
with release_file(opts.operator, opts.skip_operator) as f:
489+
gen_tests(
490+
opts.test_definition,
491+
opts.kuttl_test,
492+
opts.template_dir,
493+
opts.test_suite,
494+
opts.namespace,
495+
opts.work_dir,
496+
)
497+
with release_file(opts.release_file, opts.operator, opts.skip_operator) as f:
453498
maybe_install_release(opts.skip_release, f, opts.listener_class_preset)
454499
if opts.skip_tests:
455500
logging.info("Skip running tests.")

0 commit comments

Comments
 (0)