Skip to content

Commit

Permalink
Add flags for --ignore-not-found for uninstall, fix #351
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Schnabel authored and sschnabe committed Feb 6, 2024
1 parent 0da8166 commit 838aa42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Parameter | Type | User Property | Required | Description
`<uninstallNoHooks>` | boolean | helm.uninstall.no-hooks | false | Prevent hooks from running during uninstallation.
`<uninstallCascade>` | boolean | helm.uninstall.cascade | false | Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents. Defaults to background. (default "background" from helm)
`<uninstallKeepHistory>` | boolean | helm.uninstall.keep-history | false | Remove all associated resources and mark the release as deleted, but retain the release history.
`<uninstallIgnoreNotFound>` | boolean | helm.uninstall.ignore-not-found | false | Treat "release not found" as a successful uninstall.
`<templateOutputDir>` | file | helm.template.output-dir | false | Writes the executed templates to files in output-dir instead of stdout.
`<templateGenerateName>` | boolean | helm.template.generate-name | false | Generate the name (and omit the NAME parameter).
`<templatePlainHttp>` | boolean | helm.template.plain-http | false | Use insecure HTTP connections for the chart download.
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/io/kokuwa/maven/helm/UninstallMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public class UninstallMojo extends AbstractHelmWithValueOverrideMojo {
@Parameter(property = "helm.uninstall.no-hooks", defaultValue = "false")
private boolean uninstallNoHooks;

/**
* Treat "release not found" as a successful uninstall.
*
* @since 6.14.0
*/
@Parameter(property = "helm.uninstall.ignore-not-found ", defaultValue = "false")
private boolean uninstallIgnoreNotFound;

/**
* Remove all associated resources and mark the release as deleted, but retain the release history.
*
Expand Down Expand Up @@ -86,6 +94,7 @@ public void execute() throws MojoExecutionException {
.flag("cascade", uninstallCascade)
.flag("no-hooks", uninstallNoHooks)
.flag("keep-history", uninstallKeepHistory)
.flag("ignore-not-found", uninstallIgnoreNotFound)
.execute("Failed to deploy helm chart");
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/io/kokuwa/maven/helm/UninstallMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ void noHooks(UninstallMojo mojo) {
assertHelm(mojo, "uninstall simple --no-hooks");
}

@DisplayName("with flag ignore-not-found")
@Test
void ignoreNotFound(UninstallMojo mojo) {
mojo.setSkipUninstall(false);
mojo.setUninstallIgnoreNotFound(true);
assertHelm(mojo, "uninstall simple --ignore-not-found");
}

@DisplayName("with flags cascade background")
@Test
void cascade(UninstallMojo mojo) {
Expand Down

0 comments on commit 838aa42

Please sign in to comment.