Skip to content

Commit e2366d3

Browse files
authored
add aliases to init and upgrade commands (#33)
1 parent 99902c0 commit e2366d3

4 files changed

Lines changed: 57 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Patternizer
22

3-
![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square)
3+
![Version: 2.1.0](https://img.shields.io/badge/Version-2.1.0-informational?style=flat-square)
44
[![Quay Repository](https://img.shields.io/badge/Quay.io-patternizer-blue?logo=quay)](https://quay.io/repository/validatedpatterns/patternizer)
55
[![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)
66

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

110+
#### **Shell alias (optional):**
111+
112+
You can shorten the patternizer command by adding a shell function to your shell's startup file (e.g. `~/.bashrc` or `~/.zshrc`):
113+
114+
```bash
115+
pattern() {
116+
podman run --pull=newer \
117+
-v "$PWD:$PWD:z" \
118+
-w "$PWD" \
119+
quay.io/validatedpatterns/patternizer "$@"
120+
}
121+
```
122+
123+
Then run commands as `pattern init`, `pattern upgrade`, etc.
124+
109125
What upgrade does:
110126
111127
- Removes the `common/` directory if it exists

‎src/cmd/init_test.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,22 @@ var _ = Describe("patternizer init", func() {
272272
})
273273
})
274274

275+
for _, alias := range []string{"create", "bootstrap"} {
276+
alias := alias
277+
Context("using the "+alias+" alias on an empty directory", Ordered, func() {
278+
var tempDir string
279+
280+
BeforeAll(func() {
281+
tempDir = createTestDir()
282+
_ = runCLI(tempDir, alias)
283+
})
284+
285+
It("should produce the same result as init", func() {
286+
verifyScaffoldFilesCopied(tempDir)
287+
})
288+
})
289+
}
290+
275291
Context("on a directory with singleArgoCD explicitly set to false", Ordered, func() {
276292
var tempDir string
277293

‎src/cmd/root.go‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ values-global.yaml, values-<clustergroup>.yaml, and optional secrets configurati
2121
}
2222

2323
var initCmd = &cobra.Command{
24-
Use: "init",
25-
Short: "Initialize pattern files",
24+
Use: "init",
25+
Aliases: []string{"create", "bootstrap"},
26+
Short: "Initialize pattern files",
2627
Long: `Initialize pattern files creates or updates the necessary YAML configuration files
2728
for a validated pattern, including values-global.yaml and values-<clustergroup>.yaml.
2829
@@ -41,8 +42,9 @@ configures the pattern.sh script for secrets usage.`,
4142
rootCmd.AddCommand(initCmd)
4243

4344
var upgradeCmd = &cobra.Command{
44-
Use: "upgrade",
45-
Short: "Upgrade an existing pattern repository",
45+
Use: "upgrade",
46+
Aliases: []string{"update"},
47+
Short: "Upgrade an existing pattern repository",
4648
Long: `Upgrade an existing pattern repository by refreshing common assets.
4749
4850
This will remove the legacy common/ directory and pattern.sh symlink if present,

‎src/cmd/upgrade_test.go‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ var _ = Describe("patternizer upgrade", func() {
9797
})
9898
})
9999

100+
var _ = Describe("patternizer update (upgrade alias)", func() {
101+
Context("on a repo using common", Ordered, func() {
102+
var tempDir string
103+
104+
BeforeAll(func() {
105+
tempDir = createTestDir()
106+
cloneMCGWithCommon(tempDir)
107+
_ = runCLI(tempDir, "update")
108+
})
109+
110+
It("should produce the same result as upgrade", func() {
111+
verifyPattenShCopied(tempDir)
112+
verifyMakefileCommonCopied(tempDir)
113+
verifyAnsibleCfgCopied(tempDir)
114+
})
115+
})
116+
})
117+
100118
var _ = Describe("patternizer upgrade --replace-makefile", func() {
101119
Context("on a repo using common", Ordered, func() {
102120
var tempDir string

0 commit comments

Comments
 (0)