Patternizer is a command-line tool that bootstraps a Git repository containing Helm charts into a ready-to-use Validated Pattern. It automatically generates the necessary scaffolding, configuration files, and utility scripts, so you can get your pattern up and running in minutes.
Note: This tool was developed with assistance from Cursor, an AI-powered code editor.
- π CLI-first design with intuitive commands and help system
- π¦ Container-native for consistent execution across all environments
- π Auto-discovery of Helm charts and Git repository metadata
- π Optional secrets integration with Vault and External Secrets
- ποΈ Makefile-driven utility scripts for easy pattern management
- β»οΈ Upgrade command to refresh existing pattern repositories to the latest common structure
This guide assumes you have a Git repository containing one or more Helm charts.
Prerequisites:
- Podman or Docker
- A Git repository you want to convert into a pattern
Navigate to your repository's root directory and run the initialization command:
# In the root of your pattern-repo
podman run -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer initThis single command will generate all the necessary files to turn your repository into a Validated Pattern.
-
Clone or create your pattern repository:
git clone https://github.com/your-org/your-pattern.git cd your-pattern git checkout -b initialize-pattern -
Initialize the pattern using Patternizer:
podman run -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer init
-
Review, commit, and push the generated files:
git status git add . git commit -m 'initialize pattern using patternizer' git push -u origin initialize-pattern
-
Install the pattern:
./pattern.sh make install
Using the prebuilt container is the easiest way to run Patternizer, as it requires no local installation. The -v "$PWD:$PWD:z" -w "$PWD" flag mounts your current directory into the container's /repo workspace.
podman run -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer initpodman run -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer init --with-secretsUse this to migrate or refresh an existing pattern repo to the latest common structure and scripts.
# Refresh common assets, keep your Makefile unless it lacks the include
podman run -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer upgrade
# Replace your Makefile with the default from Patternizer
podman run -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer upgrade --replace-makefileWhat upgrade does:
- Removes the
common/directory if it exists - Removes
./pattern.shif it exists (symlink or file) - Copies
resources/Makefile-commonandresources/pattern.shinto the repo root - Makefile handling:
- If
--replace-makefileis set: copies the defaultMakefileinto the repo root (overwriting any existing one) - If not set:
- If no
Makefileexists: copies the defaultMakefile - If a
Makefileexists and already containsinclude Makefile-commonanywhere: leaves it unchanged - Otherwise: prepends
include Makefile-commonto the first line so your existing targets are preserved
- If no
- If
You can start simple and add secrets management later.
- By default,
patternizer initdisables secret loading. - To add secrets scaffolding, run
patternizer init --with-secretsat any time. This will update your configuration to enable secrets. - Important: This action is not easily reversible. We recommend committing your work to Git before adding secrets support.
For more details on how secrets work in the framework, see the Secrets Management Documentation.
Running patternizer init creates the following:
values-global.yaml: Global pattern configuration.values-<cluster_group>.yaml: Cluster group-specific values.pattern.sh: A utility script for common pattern operations (install,upgrade, etc.).Makefile: A simple Makefile that includesMakefile-common.Makefile-common: The core Makefile with all pattern-related targets.
Using the --with-secrets flag additionally creates:
values-secret.yaml.template: A template for defining your secrets.- It also updates
values-global.yamlto setglobal.secretLoader.disabled: falseand adds Vault and External Secrets Operator to the cluster group values.
This section is for developers who want to contribute to the Patternizer project itself.
- Go (see
go.modfor version) - Podman or Docker
- Git
- Make
# 1. Clone the repository
git clone https://github.com/dminnear-rh/patternizer.git
cd patternizer
# 2. Set up the development environment (installs tools)
make dev-setup
# 3. Make your changes...
# 4. Run the full CI suite locally before committing
make ciThe Makefile is the single source of truth for all development and CI tasks.
make help: Show all available targets.make check: Quick feedback loop (format, vet, build, unit tests).make build: Build thepatternizerbinary.make test: Run all tests (unit and integration).make test-unit: Run unit tests only.make test-integration: Run integration tests only.make lint: Run all code quality checks.make amd64: Build the amd64 container image locally.make arm64: Build the arm64 container image locally.
Patternizer has a comprehensive test suite to ensure stability and correctness.
- Unit Tests: Located alongside the code they test (e.g.,
src/internal/helm/helm_test.go), these tests cover individual functions and packages in isolation. They validate Helm chart detection, Git URL parsing, and YAML processing logic. - Integration Tests: The integration test suite (
test/integration_test.sh) validates the end-to-end CLI workflow against a real Git repository. Key scenarios include:- Basic Init: Validates default file generation without secrets.
- Init with Secrets: Ensures secrets-related applications and files are correctly added.
- Configuration Preservation: Verifies that existing custom values are preserved when the tool is re-run.
- Sequential Execution: Tests running
initand theninit --with-secretsto ensure a clean upgrade. - Selective File Overwriting: Confirms that running
initon a repository with pre-existing custom files correctly merges YAML configurations, preserves user-modified files (likeMakefileandvalues-secret.yaml.template), and only overwrites essential, generated scripts (pattern.sh,Makefile-common). - Mixed State Handling: Validates that the tool correctly initializes a partially-configured repository, creating files that are missing while leaving existing ones untouched.
- Upgrade (no replace): Removes legacy
common/andpattern.shsymlink, copiesMakefile-common/pattern.sh, and injectsinclude Makefile-commonat the top ofMakefilewhen missing. - Upgrade (include present): Leaves the existing
Makefileunchanged when it already containsinclude Makefile-commonanywhere. - Upgrade with
--replace-makefile: ReplacesMakefilewith the default and refreshes common assets. - Upgrade (no Makefile present): Creates the default
Makefileand refreshes common assets when aMakefiledoes not exist.
The CLI is organized into focused packages following Go best practices, with a clean separation of concerns between command-line logic (cmd), core business logic (internal), and file operations (fileutils). This modular design makes the codebase maintainable, testable, and extensible.
The GitHub Actions pipeline (.github/workflows/ci.yaml) runs on every push and pull request. It uses the same Makefile targets that developers use locally, ensuring perfect consistency between local and CI environments.
- Fork the repository.
- Create a feature branch for your changes.
- Make your changes and ensure they pass the local CI check (
make ci). - Submit a pull request.