From d5b73966effa17c53db02a5417e8f0c5ee8bcd6a Mon Sep 17 00:00:00 2001 From: Stacky McStackface Date: Tue, 8 Sep 2026 12:32:46 +0000 Subject: [PATCH] chore: Generated commit to update templated files since the last template run up to stackabletech/operator-templating@ca104d68c598a6c38535f154fc74126342825fc4 Reference-to: stackabletech/operator-templating@ca104d6 (Helm Test Script) --- .dockerignore | 3 + .envrc.sample | 3 + .gitattributes | 3 + .github/ISSUE_TEMPLATE/01-normal-issue.md | 2 + .github/ISSUE_TEMPLATE/02-bug_report.yml | 2 + .github/ISSUE_TEMPLATE/config.yml | 2 + .../pre-release-getting-started-script.md | 5 + .../pre-release-rust-deps.md | 5 + .github/actionlint.yaml | 2 + .github/pull_request_template.md | 5 + .../workflows/integration-test-custom.yaml | 2 + .../workflows/integration-test-profile.yaml | 2 + .github/workflows/pr_prek.yaml | 2 + .gitignore | 3 + .hadolint.yaml | 2 + .markdownlint.yaml | 2 + .pre-commit-config.yaml | 15 +++ .pylintrc | 3 + .vscode/DO_NOT_EDIT.md | 9 ++ .yamllint.yaml | 2 + Tiltfile | 3 + deny.toml | 5 +- nix/sources.nix | 3 + rust-toolchain.toml | 4 +- rustfmt.toml | 3 + scripts/auto-retry-tests.py | 4 + scripts/check_namespaced_defines.py | 95 +++++++++++++++++++ scripts/docs_templating.sh | 4 + scripts/ensure_one_trailing_newline.py | 3 + scripts/render_readme.sh | 4 + scripts/run-tests | 3 + scripts/run_tests.sh | 3 + shell.nix | 3 + tests/README-templating.md | 5 + tests/kuttl-test.yaml.jinja2 | 2 + tests/templates/.gitkeep | 2 + 36 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 .vscode/DO_NOT_EDIT.md create mode 100644 scripts/check_namespaced_defines.py diff --git a/.dockerignore b/.dockerignore index 7fd788f8..dbb72741 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + debug/ target/ **/*.rs.bk diff --git a/.envrc.sample b/.envrc.sample index 247153c0..6a2a188c 100644 --- a/.envrc.sample +++ b/.envrc.sample @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + # vim: syntax=conf # # If you use direnv, you can autoload the nix shell: diff --git a/.gitattributes b/.gitattributes index 53c7506b..7528684c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + nix/** linguist-generated Cargo.nix linguist-generated crate-hashes.json linguist-generated diff --git a/.github/ISSUE_TEMPLATE/01-normal-issue.md b/.github/ISSUE_TEMPLATE/01-normal-issue.md index 61e46c8c..41b53d6c 100644 --- a/.github/ISSUE_TEMPLATE/01-normal-issue.md +++ b/.github/ISSUE_TEMPLATE/01-normal-issue.md @@ -1,4 +1,6 @@ --- +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE name: Normal issue about: This is just a normal empty issue with a simple checklist title: '' diff --git a/.github/ISSUE_TEMPLATE/02-bug_report.yml b/.github/ISSUE_TEMPLATE/02-bug_report.yml index 8c4fdad6..175ab2ce 100644 --- a/.github/ISSUE_TEMPLATE/02-bug_report.yml +++ b/.github/ISSUE_TEMPLATE/02-bug_report.yml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- name: "🐛 Bug Report" description: "If something isn't working as expected 🤔." diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 128973ac..9c803f7e 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- blank_issues_enabled: true contact_links: diff --git a/.github/PULL_REQUEST_TEMPLATE/pre-release-getting-started-script.md b/.github/PULL_REQUEST_TEMPLATE/pre-release-getting-started-script.md index bc008c91..d1453d29 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pre-release-getting-started-script.md +++ b/.github/PULL_REQUEST_TEMPLATE/pre-release-getting-started-script.md @@ -1,3 +1,8 @@ + + ## Check and Update Getting Started Script + ## Bump Rust Dependencies for Stackable Release YY.M.X + ## Description *Please add a description here. This will become the commit message of the merge request later.* diff --git a/.github/workflows/integration-test-custom.yaml b/.github/workflows/integration-test-custom.yaml index 8d6e8483..d933b5e9 100644 --- a/.github/workflows/integration-test-custom.yaml +++ b/.github/workflows/integration-test-custom.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- name: Integration Test (Custom) diff --git a/.github/workflows/integration-test-profile.yaml b/.github/workflows/integration-test-profile.yaml index a4c55ca9..81b38740 100644 --- a/.github/workflows/integration-test-profile.yaml +++ b/.github/workflows/integration-test-profile.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- name: Integration Test (Profile + Schedule) diff --git a/.github/workflows/pr_prek.yaml b/.github/workflows/pr_prek.yaml index d4e075a2..bb103633 100644 --- a/.github/workflows/pr_prek.yaml +++ b/.github/workflows/pr_prek.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- name: prek diff --git a/.gitignore b/.gitignore index 696bc411..411cc85d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + tests/_work/ debug/ target/ diff --git a/.hadolint.yaml b/.hadolint.yaml index 0e9084e7..e27b31bc 100644 --- a/.hadolint.yaml +++ b/.hadolint.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- ignored: # Warning: Use the -y switch to avoid manual input dnf install -y diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 75212ec5..9befea53 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- # All defaults or options can be checked here: # https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6f833118..24c60ce9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- exclude: ^(Cargo\.nix|crate-hashes\.json|nix/.*)$ @@ -66,6 +68,19 @@ repos: - repo: local hooks: + - id: script-tests + name: script-tests + language: system + entry: python3 -m unittest discover --start-directory scripts --pattern '*.py' + pass_filenames: false + files: ^scripts/.*\.py$ + + - id: check-namespaced-defines + name: check-namespaced-defines + language: system + entry: python3 scripts/check_namespaced_defines.py + files: ^deploy/helm/[^/]+/templates/ + - id: regenerate-charts name: regenerate-charts language: system diff --git a/.pylintrc b/.pylintrc index 5df27e82..ff87cc9c 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + [MESSAGES CONTROL] # These rules are for missing docstrings which doesn't matter much for most of our simple scripts diff --git a/.vscode/DO_NOT_EDIT.md b/.vscode/DO_NOT_EDIT.md new file mode 100644 index 00000000..642bbc7f --- /dev/null +++ b/.vscode/DO_NOT_EDIT.md @@ -0,0 +1,9 @@ +# DO NOT EDIT + +The files in this directory are automatically generated from the templates in stackabletech/operator-templating + +DO NOT MANUALLY EDIT THESE FILES + +> [!NOTE] +> This file only exists because VS Code currently doesn't support JSONC files. +> See diff --git a/.yamllint.yaml b/.yamllint.yaml index 020cb5f0..f8970d15 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- extends: default diff --git a/Tiltfile b/Tiltfile index 1859de01..1769d19a 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + # Load the metadata first, so that we immediately get access to the operator name meta = read_json('nix/meta.json') operator_name = meta['operator']['name'] diff --git a/deny.toml b/deny.toml index f446cc19..089f738b 100644 --- a/deny.toml +++ b/deny.toml @@ -1,6 +1,9 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + # This file is the source of truth for all our repos! # This includes repos not templated by operator-templating, please copy/paste the file for this repos. - +# # TIP: Use "cargo deny check" to check if everything is fine [graph] diff --git a/nix/sources.nix b/nix/sources.nix index fe3dadf7..07aa2576 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE +# # This file has been generated by Niv. let diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ac2fc556..40643ed3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,6 @@ -# DO NOT EDIT, this file is generated by operator-templating +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + [toolchain] channel = "1.97.1" profile = "default" diff --git a/rustfmt.toml b/rustfmt.toml index 03d21a4f..5d4f5de9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + # This file includes unstable features, so you need to run "cargo +nightly fmt" to format your code. # It's also ok to use the stable toolchain by simple running "cargo fmt", but using the nightly formatter is preferred. diff --git a/scripts/auto-retry-tests.py b/scripts/auto-retry-tests.py index 153b7fc1..2ee829d6 100755 --- a/scripts/auto-retry-tests.py +++ b/scripts/auto-retry-tests.py @@ -1,4 +1,8 @@ #!/usr/bin/env python3 + +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + """ Automated test suite runner with intelligent retry logic for flaky integration tests. diff --git a/scripts/check_namespaced_defines.py b/scripts/check_namespaced_defines.py new file mode 100644 index 00000000..00dc0369 --- /dev/null +++ b/scripts/check_namespaced_defines.py @@ -0,0 +1,95 @@ +""" +Fails when a Helm defined template, or a call to one, is not prefixed with the +name of the chart it lives in. + +To run tests for this script: + python3 -m unittest check_namespaced_defines.py +""" + +import re +import unittest +from pathlib import Path + +NAME_PATTERN = r'\b(?:define|include|template)\s+"([^"]+)"' +CHART_PATTERN = r"(?:^|/)deploy/helm/(?P[^/]+)/templates/" + + +def chart_of(path): + """The chart whose templates directory holds path, or None if it is outside one.""" + found = re.search(CHART_PATTERN, Path(path).as_posix()) + return found.group("chart") if found else None + + +def unprefixed(file_contents, chart_name): + """The defined template names in file_contents, and the calls to them, lacking the chart prefix.""" + names = re.findall(NAME_PATTERN, file_contents) + return sorted({name for name in names if not name.startswith(f"{chart_name}.")}) + + +# Run these with: python3 -m unittest check_namespaced_defines.py +class TestCoreMethods(unittest.TestCase): + def test_chart_of(self): + self.assertEqual( + chart_of("deploy/helm/trino-operator/templates/x.yaml"), "trino-operator" + ) + # An absolute path has to give the same answer, or a manual run invents a chart name. + self.assertEqual( + chart_of("/tmp/wt/deploy/helm/secret-operator/templates/a/b.yaml"), + "secret-operator", + ) + self.assertIsNone(chart_of("deploy/helm/trino-operator/values.yaml")) + self.assertIsNone(chart_of("README.md")) + + def test_prefixed_is_accepted(self): + text = '{{- define "trino-operator.labels" -}}\n{{ include "trino-operator.chart" . }}\n' + self.assertEqual(unprefixed(text, "trino-operator"), []) + + def test_unprefixed_define_is_reported(self): + self.assertEqual( + unprefixed('{{- define "helper.thing" -}}', "trino-operator"), + ["helper.thing"], + ) + + def test_unprefixed_call_is_reported(self): + # A renamed definition whose call sites did not move with it stops the chart rendering. + text = ( + '{{ include "operator.fullname" . }}\n{{ template "operator.labels" . }}\n' + ) + self.assertEqual( + unprefixed(text, "trino-operator"), ["operator.fullname", "operator.labels"] + ) + + def test_keyword_must_stand_alone(self): + # Without a word boundary any identifier ending in the keyword matches. + self.assertEqual( + unprefixed('{{ .Values.xinclude "bar.baz" }}', "foo-operator"), [] + ) + + +if __name__ == "__main__": + import sys + + if not sys.argv[1:]: + print(f"usage: {sys.argv[0]} deploy/helm//templates/*", file=sys.stderr) + sys.exit(2) + + failed = False + for path in sys.argv[1:]: + chart_name = chart_of(path) + if chart_name is None: + print( + f"{sys.argv[0]}: {path} is not inside deploy/helm//templates/", + file=sys.stderr, + ) + sys.exit(2) + file_contents = Path(path).read_text(encoding="utf-8") + unprefixed_names = unprefixed(file_contents, chart_name) + if unprefixed_names: + failed = True + print( + f"{path}: defined templates and the calls to them must be prefixed with '{chart_name}.'" + ) + for name in unprefixed_names: + print(f" {name}") + + sys.exit(1 if failed else 0) diff --git a/scripts/docs_templating.sh b/scripts/docs_templating.sh index 4ea10a23..da6f38ae 100755 --- a/scripts/docs_templating.sh +++ b/scripts/docs_templating.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash + +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + set -euo pipefail # Reads a file with variables to insert into templates, and templates all .*.j2 files diff --git a/scripts/ensure_one_trailing_newline.py b/scripts/ensure_one_trailing_newline.py index a6f73c06..6f57b91f 100644 --- a/scripts/ensure_one_trailing_newline.py +++ b/scripts/ensure_one_trailing_newline.py @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + """ Given the location of a file, trims all trailing blank lines and places a single one. Used as post-processing step for README rendering. diff --git a/scripts/render_readme.sh b/scripts/render_readme.sh index 78489c24..048dff33 100755 --- a/scripts/render_readme.sh +++ b/scripts/render_readme.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash + +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + set -euo pipefail # Check if jinja2 is there diff --git a/scripts/run-tests b/scripts/run-tests index 4e6496b5..ea149d79 100755 --- a/scripts/run-tests +++ b/scripts/run-tests @@ -1,6 +1,9 @@ #!/usr/bin/env python # vim: filetype=python syntax=python tabstop=4 expandtab +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + import argparse import collections.abc import contextlib diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index a31a1382..c41c4c7d 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -1,3 +1,6 @@ #!/usr/bin/env bash +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + ./scripts/run-tests "$@" diff --git a/shell.nix b/shell.nix index b6ee3afb..890b25c1 100644 --- a/shell.nix +++ b/shell.nix @@ -1,3 +1,6 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE + let self = import ./. {}; inherit (self) sources pkgs meta; diff --git a/tests/README-templating.md b/tests/README-templating.md index 8da9fe91..7f05d504 100644 --- a/tests/README-templating.md +++ b/tests/README-templating.md @@ -1,3 +1,8 @@ + + # Test Scenario Templating ## Introduction diff --git a/tests/kuttl-test.yaml.jinja2 b/tests/kuttl-test.yaml.jinja2 index 8a5620c4..4366670a 100644 --- a/tests/kuttl-test.yaml.jinja2 +++ b/tests/kuttl-test.yaml.jinja2 @@ -1,3 +1,5 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE --- apiVersion: kuttl.dev/v1beta1 kind: TestSuite diff --git a/tests/templates/.gitkeep b/tests/templates/.gitkeep index e69de29b..d20cec98 100644 --- a/tests/templates/.gitkeep +++ b/tests/templates/.gitkeep @@ -0,0 +1,2 @@ +# This file is automatically generated from the templates in stackabletech/operator-templating +# DO NOT MANUALLY EDIT THIS FILE