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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Patternizer

![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square)
![Version: 2.1.0](https://img.shields.io/badge/Version-2.1.0-informational?style=flat-square)
[![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/build-push.yaml/badge.svg?branch=main)](https://github.com/validatedpatterns/patternizer/actions/workflows/build-push.yaml)

Expand All @@ -16,6 +16,7 @@
- [**Initialize without secrets:**](#initialize-without-secrets)
- [**Initialize with secrets support:**](#initialize-with-secrets-support)
- [**Upgrade an existing pattern repository:**](#upgrade-an-existing-pattern-repository)
- [**Shell alias (optional):**](#shell-alias-optional)
- [Understanding Secrets Management](#understanding-secrets-management)
- [Generated Files](#generated-files)
- [AI Coding Skills](#ai-coding-skills)
Expand Down Expand Up @@ -106,6 +107,21 @@ podman run --pull=newer -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/pat
podman run --pull=newer -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer upgrade --replace-makefile
```

#### **Shell alias (optional):**

You can shorten the patternizer command by adding a shell function to your shell's startup file (e.g. `~/.bashrc` or `~/.zshrc`):

```bash
pattern() {
podman run --pull=newer \
-v "$PWD:$PWD:z" \
-w "$PWD" \
quay.io/validatedpatterns/patternizer "$@"
}
```

Then run commands as `pattern init`, `pattern upgrade`, etc.

What upgrade does:

- Removes the `common/` directory if it exists
Expand Down
16 changes: 16 additions & 0 deletions src/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,22 @@ var _ = Describe("patternizer init", func() {
})
})

for _, alias := range []string{"create", "bootstrap"} {
alias := alias
Context("using the "+alias+" alias on an empty directory", Ordered, func() {
var tempDir string

BeforeAll(func() {
tempDir = createTestDir()
_ = runCLI(tempDir, alias)
})

It("should produce the same result as init", func() {
verifyScaffoldFilesCopied(tempDir)
})
})
}

Context("on a directory with singleArgoCD explicitly set to false", Ordered, func() {
var tempDir string

Expand Down
10 changes: 6 additions & 4 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ values-global.yaml, values-<clustergroup>.yaml, and optional secrets configurati
}

var initCmd = &cobra.Command{
Use: "init",
Short: "Initialize pattern files",
Use: "init",
Aliases: []string{"create", "bootstrap"},
Short: "Initialize pattern files",
Long: `Initialize pattern files creates or updates the necessary YAML configuration files
for a validated pattern, including values-global.yaml and values-<clustergroup>.yaml.

Expand All @@ -41,8 +42,9 @@ configures the pattern.sh script for secrets usage.`,
rootCmd.AddCommand(initCmd)

var upgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "Upgrade an existing pattern repository",
Use: "upgrade",
Aliases: []string{"update"},
Short: "Upgrade an existing pattern repository",
Long: `Upgrade an existing pattern repository by refreshing common assets.

This will remove the legacy common/ directory and pattern.sh symlink if present,
Expand Down
18 changes: 18 additions & 0 deletions src/cmd/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ var _ = Describe("patternizer upgrade", func() {
})
})

var _ = Describe("patternizer update (upgrade alias)", func() {
Context("on a repo using common", Ordered, func() {
var tempDir string

BeforeAll(func() {
tempDir = createTestDir()
cloneMCGWithCommon(tempDir)
_ = runCLI(tempDir, "update")
})

It("should produce the same result as upgrade", func() {
verifyPattenShCopied(tempDir)
verifyMakefileCommonCopied(tempDir)
verifyAnsibleCfgCopied(tempDir)
})
})
})

var _ = Describe("patternizer upgrade --replace-makefile", func() {
Context("on a repo using common", Ordered, func() {
var tempDir string
Expand Down
Loading