From 1eac8863c862480e07561051830eec7da9616ed8 Mon Sep 17 00:00:00 2001 From: Stephan Schnabel Date: Tue, 10 Sep 2024 15:55:47 +0200 Subject: [PATCH] Add flags for `--name-template`, fix #376 (#381) --- README.md | 1 + src/main/java/io/kokuwa/maven/helm/TemplateMojo.java | 9 +++++++++ src/main/java/io/kokuwa/maven/helm/github/Github.java | 2 +- src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java | 8 ++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 34ca1cd7..db117062 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,7 @@ Parameter | Type | User Property | Required | Description `` | boolean | helm.uninstall.keep-history | false | Remove all associated resources and mark the release as deleted, but retain the release history. `` | boolean | helm.uninstall.ignore-not-found | false | Treat "release not found" as a successful uninstall. `` | file | helm.template.output-dir | false | Writes the executed templates to files in output-dir instead of stdout. +`` | string | helm.template.name-template | false | Specify template used to name the release. `` | boolean | helm.template.generate-name | false | Generate the name (and omit the NAME parameter). `` | boolean | helm.template.plain-http | false | Use insecure HTTP connections for the chart download. `` | boolean | helm.push.plain-http | false | Use insecure HTTP connections for the chart download. diff --git a/src/main/java/io/kokuwa/maven/helm/TemplateMojo.java b/src/main/java/io/kokuwa/maven/helm/TemplateMojo.java index c805005a..427a7437 100644 --- a/src/main/java/io/kokuwa/maven/helm/TemplateMojo.java +++ b/src/main/java/io/kokuwa/maven/helm/TemplateMojo.java @@ -33,6 +33,14 @@ public class TemplateMojo extends AbstractHelmWithValueOverrideMojo { @Parameter(property = "action", defaultValue = "template") private String action; + /** + * Specify template used to name the release. + * + * @since 6.15 + */ + @Parameter(property = "helm.template.name-template") + private String templateNameTemplate; + /** * Writes the executed templates to files in output-dir instead of stdout. * @@ -89,6 +97,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { .arguments(action, chartDirectory) .arguments(getArguments()) .flag("output-dir", templateOutputDir) + .flag("name-template", templateNameTemplate) .flag("generate-name", templateGenerateName) .flag("plain-http", isPlainHttp(templatePlainHttp)) .execute("There are test failures"); diff --git a/src/main/java/io/kokuwa/maven/helm/github/Github.java b/src/main/java/io/kokuwa/maven/helm/github/Github.java index d5a092a4..3409795d 100644 --- a/src/main/java/io/kokuwa/maven/helm/github/Github.java +++ b/src/main/java/io/kokuwa/maven/helm/github/Github.java @@ -15,7 +15,7 @@ import lombok.RequiredArgsConstructor; /** - * Utility for Github requests with cachging. + * Utility for Github requests with caching. * * @author Stephan Schnabel * @since 6.1.0 diff --git a/src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java b/src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java index 19945ba1..6a7eca5a 100644 --- a/src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java +++ b/src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java @@ -63,6 +63,14 @@ void additionalArguments(TemplateMojo mojo) { assertHelm(mojo, "template src/test/resources/simple --foo --bar"); } + @DisplayName("with --name-template") + @Test + void nameTemplate(TemplateMojo mojo) { + mojo.setSkipTemplate(false); + mojo.setTemplateNameTemplate("my-name"); + assertHelm(mojo, "template src/test/resources/simple --name-template my-name"); + } + @DisplayName("with --output-dir") @Test void outputDirectory(TemplateMojo mojo) {