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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- main

env:
IMAGE_NAME: quay.io/hybridcloudpatterns/patternizer
IMAGE_NAME: quay.io/validatedpatterns/patternizer
GO_VERSION: '1.24'

jobs:
Expand Down
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Patternizer

[![Quay Repository](https://img.shields.io/badge/Quay.io-patternizer-blue?logo=quay)](https://quay.io/repository/hybridcloudpatterns/patternizer)
[![Quay Repository](https://img.shields.io/badge/Quay.io-patternizer-blue?logo=quay)](https://quay.io/repository/validatedpatterns/patternizer)
[![CI Pipeline](https://github.com/validatedpatterns/patternizer/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/validatedpatterns/patternizer/actions/workflows/ci.yaml)

**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.
Expand All @@ -15,6 +15,7 @@
- [Container Usage (Recommended)](#container-usage-recommended)
- [**Initialize without secrets:**](#initialize-without-secrets)
- [**Initialize with secrets support:**](#initialize-with-secrets-support)
- [**Upgrade an existing pattern repository:**](#upgrade-an-existing-pattern-repository)
- [Understanding Secrets Management](#understanding-secrets-management)
- [Generated Files](#generated-files)
- [Development \& Contributing](#development--contributing)
Expand All @@ -33,6 +34,7 @@
- 🔍 **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

## Quick Start

Expand All @@ -47,7 +49,7 @@ Navigate to your repository's root directory and run the initialization command:

```bash
# In the root of your pattern-repo
podman run -v "$PWD:/repo:z" quay.io/hybridcloudpatterns/patternizer init
podman run -v "$PWD:/repo:z" quay.io/validatedpatterns/patternizer init
```

This single command will generate all the necessary files to turn your repository into a Validated Pattern.
Expand All @@ -65,7 +67,7 @@ This single command will generate all the necessary files to turn your repositor
2. **Initialize the pattern using Patternizer:**

```bash
podman run -v "$PWD:/repo:z" quay.io/hybridcloudpatterns/patternizer init
podman run -v "$PWD:/repo:z" quay.io/validatedpatterns/patternizer init
```

3. **Review, commit, and push the generated files:**
Expand All @@ -92,15 +94,39 @@ Using the prebuilt container is the easiest way to run Patternizer, as it requir
#### **Initialize without secrets:**

```bash
podman run -v "$PWD:/repo:z" quay.io/hybridcloudpatterns/patternizer init
podman run -v "$PWD:/repo:z" quay.io/validatedpatterns/patternizer init
```

#### **Initialize with secrets support:**

```bash
podman run -v "$PWD:/repo:z" quay.io/hybridcloudpatterns/patternizer init --with-secrets
podman run -v "$PWD:/repo:z" quay.io/validatedpatterns/patternizer init --with-secrets
```

#### **Upgrade an existing pattern repository:**

Use this to migrate or refresh an existing pattern repo to the latest common structure and scripts.

```bash
# Refresh common assets, keep your Makefile unless it lacks the include
podman run -v "$PWD:/repo:z" quay.io/validatedpatterns/patternizer upgrade

# Replace your Makefile with the default from Patternizer
podman run -v "$PWD:/repo:z" quay.io/validatedpatterns/patternizer upgrade --replace-makefile
```

What upgrade does:

- Removes the `common/` directory if it exists
- Removes `./pattern.sh` if it exists (symlink or file)
- Copies `resources/Makefile-common` and `resources/pattern.sh` into the repo root
- Makefile handling:
- If `--replace-makefile` is set: copies the default `Makefile` into the repo root (overwriting any existing one)
- If not set:
- If no `Makefile` exists: copies the default `Makefile`
- If a `Makefile` exists and already contains `include Makefile-common` anywhere: leaves it unchanged
- Otherwise: prepends `include Makefile-common` to the first line so your existing targets are preserved

### Understanding Secrets Management

You can start simple and add secrets management later.
Expand All @@ -118,8 +144,8 @@ 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 includes `Makefile-pattern`.
* `Makefile-pattern`: The core Makefile with all pattern-related targets.
* `Makefile`: A simple Makefile that includes `Makefile-common`.
* `Makefile-common`: The core Makefile with all pattern-related targets.

Using the `--with-secrets` flag additionally creates:

Expand Down Expand Up @@ -176,8 +202,12 @@ Patternizer has a comprehensive test suite to ensure stability and correctness.
2. **Init with Secrets:** Ensures secrets-related applications and files are correctly added.
3. **Configuration Preservation:** Verifies that existing custom values are preserved when the tool is re-run.
4. **Sequential Execution:** Tests running `init` and then `init --with-secrets` to ensure a clean upgrade.
5. **Selective File Overwriting:** Confirms that running `init` on a repository with pre-existing custom files correctly **merges YAML configurations**, preserves user-modified files (like `Makefile` and `values-secret.yaml.template`), and only overwrites essential, generated scripts (`pattern.sh`, `Makefile-pattern`).
5. **Selective File Overwriting:** Confirms that running `init` on a repository with pre-existing custom files correctly **merges YAML configurations**, preserves user-modified files (like `Makefile` and `values-secret.yaml.template`), and only overwrites essential, generated scripts (`pattern.sh`, `Makefile-common`).
6. **Mixed State Handling:** Validates that the tool correctly initializes a partially-configured repository, **creating files that are missing** while leaving existing ones untouched.
7. **Upgrade (no replace):** Removes legacy `common/` and `pattern.sh` symlink, copies `Makefile-common`/`pattern.sh`, and injects `include Makefile-common` at the top of `Makefile` when missing.
8. **Upgrade (include present):** Leaves the existing `Makefile` unchanged when it already contains `include Makefile-common` anywhere.
9. **Upgrade with `--replace-makefile`:** Replaces `Makefile` with the default and refreshes common assets.
10. **Upgrade (no Makefile present):** Creates the default `Makefile` and refreshes common assets when a `Makefile` does not exist.

### Architecture

Expand Down
4 changes: 2 additions & 2 deletions resources/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated by patternizer
# This Makefile includes the common pattern targets from Makefile-pattern
# This Makefile includes the common pattern targets from Makefile-common
# You can add custom targets above or below the include line

include Makefile-pattern
include Makefile-common
42 changes: 42 additions & 0 deletions resources/Makefile-common
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
MAKEFLAGS += --no-print-directory
ANSIBLE_STDOUT_CALLBACK ?= null # null silences all ansible output. Override this with default, minimal, oneline, etc. when debugging.
ANSIBLE_RUN := ANSIBLE_STDOUT_CALLBACK=$(ANSIBLE_STDOUT_CALLBACK) ansible-playbook $(EXTRA_PLAYBOOK_OPTS)
DOCS_URL := https://validatedpatterns.io/blog/2025-08-25-new-common-makefile-structure/

.PHONY: help
help: ## Print this help message
@echo "For a complete guide to these targets and the available overrides, please visit $(DOCS_URL)"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^(\s|[a-zA-Z_0-9-])+:.*?##/ { printf " \033[36m%-35s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Pattern Install Tasks
.PHONY: show
show: ## Shows the template that would be applied by the `make install` target
@$(ANSIBLE_RUN) rhvp.cluster_utils.show

.PHONY: operator-deploy
operator-deploy operator-upgrade: ## Installs/updates the pattern on a cluster (DOES NOT load secrets)
@$(ANSIBLE_RUN) rhvp.cluster_utils.operator_deploy

.PHONY: install
install: pattern-install ## Installs the pattern onto a cluster (Loads secrets as well if configured)

.PHONY: pattern-install
pattern-install:
@$(ANSIBLE_RUN) rhvp.cluster_utils.install

.PHONY: load-secrets
load-secrets: ## Loads secrets onto the cluster (unless explicitly disabled in values-global.yaml)
@$(ANSIBLE_RUN) rhvp.cluster_utils.load_secrets

##@ Validation Tasks
.PHONY: validate-prereq
validate-prereq: ## verify pre-requisites
@$(ANSIBLE_RUN) rhvp.cluster_utils.validate_prereq

.PHONY: validate-origin
validate-origin: ## verify the git origin is available
@$(ANSIBLE_RUN) rhvp.cluster_utils.validate_origin

.PHONY: validate-cluster
validate-cluster: ## Do some cluster validations before installing
@$(ANSIBLE_RUN) rhvp.cluster_utils.validate_cluster
184 changes: 0 additions & 184 deletions resources/Makefile-pattern

This file was deleted.

Loading