Skip to content

Commit d2b1f21

Browse files
committed
Add flags for --plain-http, fix #336
1 parent 3635cc0 commit d2b1f21

File tree

10 files changed

+141
-0
lines changed

10 files changed

+141
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,22 @@ Parameter | Type | User Property | Required | Description
316316
`<installForce>` | boolean | helm.install.force | false | Force resource updates through a replacement strategy.
317317
`<installAtomic>` | boolean | helm.install.atomic | false | Set this to `true` to delete the installation on failure.
318318
`<installTimeout>` | boolean | helm.upgrade.imeout | false | Time in seconds to wait for any individual Kubernetes operation during install process. The default is 300 seconds (from helm) if `installAtomic` is set to `true`.
319+
`<installPlainHttp>` | boolean | helm.install.plain-http | false | Use insecure HTTP connections for the chart download.
319320
`<upgradeForce>` | boolean | helm.upgrade.force | false | Force resource updates through a replacement strategy.
320321
`<upgradeAtomic>` | boolean | helm.upgrade.atomic | false | Set this to `true` to rollback changes made in case of failed upgrade.
321322
`<upgradeTimeout>` | boolean | helm.upgrade.imeout | false | Time in seconds to wait for any individual Kubernetes operation during upgrade process. The default is 300 seconds (from helm) if `upgradeTimeout` is set to `true`.
322323
`<upgradeDryRun>` | boolean | helm.upgrade.dryRun | false | Run upgrade goal only in dry run mode
324+
`<upgradePlainHttp>` | boolean | helm.upgrade.plain-http | false | Use insecure HTTP connections for the chart download.
323325
`<uninstallWait>` | boolean | helm.uninstall.wait | false | If set, will wait until all the resources are deleted before returning. It will wait for as long as `uninstallTimeout`.
324326
`<uninstallTimeout>` | boolean | helm.uninstall.timeout | false | Time to wait for any individual Kubernetes operation (like Jobs for hooks) (default 5m0s).
325327
`<uninstallNoHooks>` | boolean | helm.uninstall.no-hooks | false | Prevent hooks from running during uninstallation.
326328
`<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)
327329
`<uninstallKeepHistory>` | boolean | helm.uninstall.keep-history | false | Remove all associated resources and mark the release as deleted, but retain the release history.
328330
`<templateOutputDir>` | file | helm.template.output-dir | false | Writes the executed templates to files in output-dir instead of stdout.
329331
`<templateGenerateName>` | boolean | helm.template.generate-name | false | Generate the name (and omit the NAME parameter).
332+
`<templatePlainHttp>` | boolean | helm.template.plain-http | false | Use insecure HTTP connections for the chart download.
333+
`<pushPlainHttp>` | boolean | helm.push.plain-http | false | Use insecure HTTP connections for the chart download.
334+
`<plainHttp>` | boolean | helm.plain-http | false | Global Flag: Use insecure HTTP connections for the chart download.
330335
`<caFile>` | boolean | helm.push.caFile | false | Verify certificates of HTTPS-enabled servers using this CA bundle.
331336
`<insecure>` | boolean | helm.push.insecure | false | Skip tls certificate checks for the chart upload. Also known as `helm push --insecure-skip-tls-verify`
332337
`<fallbackBinaryDownload>` | boolean | helm.fallbackBinaryDownload | false | Controls whether a download should occur when local helm binary is not found. This property has no effect unless `<useLocalHelmBinary>` is set to `true`.

src/main/java/io/kokuwa/maven/helm/AbstractHelmMojo.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ public abstract class AbstractHelmMojo extends AbstractMojo {
204204
@Parameter(property = "helm.security", defaultValue = "~/.m2/settings-security.xml")
205205
private String helmSecurity;
206206

207+
/**
208+
* Global Flag: Use insecure HTTP connections for the chart download.
209+
*
210+
* @since 6.12.0
211+
*/
212+
@Parameter(property = "helm.plain-http", defaultValue = "false")
213+
private boolean plainHttp;
214+
207215
/**
208216
* Set this to <code>true</code> to skip all goals.
209217
*
@@ -443,6 +451,10 @@ public String getHelmVersion() throws MojoExecutionException {
443451
return helmVersion;
444452
}
445453

454+
public boolean isPlainHttp(Boolean mojoPlainHttp) {
455+
return mojoPlainHttp != null ? mojoPlainHttp : plainHttp;
456+
}
457+
446458
public Path getOutputDirectory() {
447459
return outputDirectory.toPath();
448460
}

src/main/java/io/kokuwa/maven/helm/InstallMojo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public class InstallMojo extends AbstractHelmWithValueOverrideMojo {
5555
@Parameter(property = "helm.install.force")
5656
private boolean installForce;
5757

58+
/**
59+
* Use insecure HTTP connections for the chart download.
60+
*
61+
* @since 6.12.0
62+
*/
63+
@Parameter(property = "helm.install.plain-http")
64+
private Boolean installPlainHttp;
65+
5866
/**
5967
* Set this to <code>true</code> to skip invoking install goal.
6068
*
@@ -79,6 +87,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7987
.arguments(action, chartDirectory.getFileName().toString(), chartDirectory)
8088
.flag("atomic", installAtomic)
8189
.flag("force", installForce)
90+
.flag("plain-http", isPlainHttp(installPlainHttp))
8291
.flag("timeout", installTimeout != null ? installTimeout + "s" : null)
8392
.execute("Failed to deploy helm chart");
8493
}

src/main/java/io/kokuwa/maven/helm/PushMojo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ public class PushMojo extends AbstractHelmMojo {
4040
@Parameter(property = "helm.push.insecure", defaultValue = "false")
4141
private boolean insecure;
4242

43+
/**
44+
* Use insecure HTTP connections for the chart download.
45+
*
46+
* @since 6.12.0
47+
*/
48+
@Parameter(property = "helm.push.plain-http")
49+
private Boolean pushPlainHttp;
50+
4351
/**
4452
* Skip login, usefull if already logged via `helm:registry-login`.
4553
*
@@ -104,6 +112,7 @@ public void execute() throws MojoExecutionException {
104112
.arguments("push", chartArchive, "oci://" + repository.getUrl())
105113
.flag("ca-file", caFile)
106114
.flag("insecure-skip-tls-verify", insecure)
115+
.flag("plain-http", isPlainHttp(pushPlainHttp))
107116
.execute("Upload failed");
108117
}
109118
}

src/main/java/io/kokuwa/maven/helm/TemplateMojo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ public class TemplateMojo extends AbstractHelmWithValueOverrideMojo {
5959
@Parameter(property = "helm.additional.arguments")
6060
private String additionalArguments;
6161

62+
/**
63+
* Use insecure HTTP connections for the chart download.
64+
*
65+
* @since 6.12.0
66+
*/
67+
@Parameter(property = "helm.template.plain-http")
68+
private Boolean templatePlainHttp;
69+
6270
/**
6371
* Set this to <code>true</code> to skip invoking template goal.
6472
*
@@ -82,6 +90,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8290
.arguments(getArguments())
8391
.flag("output-dir", templateOutputDir)
8492
.flag("generate-name", templateGenerateName)
93+
.flag("plain-http", isPlainHttp(templatePlainHttp))
8594
.execute("There are test failures");
8695
}
8796
}

src/main/java/io/kokuwa/maven/helm/UpgradeMojo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public class UpgradeMojo extends AbstractHelmWithValueOverrideMojo {
6767
@Parameter(property = "helm.upgrade.force")
6868
private boolean upgradeForce;
6969

70+
/**
71+
* Use insecure HTTP connections for the chart download.
72+
*
73+
* @since 6.12.0
74+
*/
75+
@Parameter(property = "helm.upgrade.plain-http")
76+
private Boolean upgradePlainHttp;
7077
/**
7178
* Name of the release for upgrade goal.
7279
*
@@ -96,6 +103,7 @@ public void execute() throws MojoExecutionException {
96103
.flag("dry-run", upgradeDryRun)
97104
.flag("atomic", upgradeAtomic)
98105
.flag("force", upgradeForce)
106+
.flag("plain-http", isPlainHttp(upgradePlainHttp))
99107
.flag("timeout", upgradeTimeout != null ? upgradeTimeout + "s" : null)
100108
.execute("Error occurred while upgrading the chart");
101109
}

src/test/java/io/kokuwa/maven/helm/InstallMojoTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,28 @@ void atomicAndTimeout(InstallMojo mojo) {
5050
assertHelm(mojo, "install simple src/test/resources/simple --atomic --timeout 30s");
5151
}
5252

53+
@DisplayName("with flag plain-http")
54+
@Test
55+
void plainHttp(InstallMojo mojo) {
56+
mojo.setSkipInstall(false);
57+
58+
mojo.setPlainHttp(false);
59+
mojo.setInstallPlainHttp(null);
60+
assertHelm(mojo, "install simple src/test/resources/simple");
61+
62+
mojo.setPlainHttp(true);
63+
mojo.setInstallPlainHttp(null);
64+
assertHelm(mojo, "install simple src/test/resources/simple --plain-http");
65+
66+
mojo.setPlainHttp(false);
67+
mojo.setInstallPlainHttp(true);
68+
assertHelm(mojo, "install simple src/test/resources/simple --plain-http");
69+
70+
mojo.setPlainHttp(false);
71+
mojo.setInstallPlainHttp(false);
72+
assertHelm(mojo, "install simple src/test/resources/simple");
73+
}
74+
5375
@DisplayName("with values overrides")
5476
@Test
5577
void valuesFile(InstallMojo mojo) {

src/test/java/io/kokuwa/maven/helm/PushMojoTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ void caFile(PushMojo mojo) {
4343
assertHelm(mojo, "push " + packaged + " oci://reg.example.org --ca-file registry-ca.pem");
4444
}
4545

46+
@DisplayName("with flag plain-http")
47+
@Test
48+
void plainHttp(PushMojo mojo) {
49+
Path packaged = copyPackagedHelmChartToOutputdirectory(mojo);
50+
mojo.setUploadRepoStable(new HelmRepository().setUrl("reg.example.org"));
51+
52+
mojo.setPlainHttp(false);
53+
mojo.setPushPlainHttp(null);
54+
assertHelm(mojo, "push " + packaged + " oci://reg.example.org");
55+
56+
mojo.setPlainHttp(true);
57+
mojo.setPushPlainHttp(null);
58+
assertHelm(mojo, "push " + packaged + " oci://reg.example.org --plain-http");
59+
60+
mojo.setPlainHttp(false);
61+
mojo.setPushPlainHttp(true);
62+
assertHelm(mojo, "push " + packaged + " oci://reg.example.org --plain-http");
63+
64+
mojo.setPlainHttp(false);
65+
mojo.setPushPlainHttp(false);
66+
assertHelm(mojo, "push " + packaged + " oci://reg.example.org");
67+
}
68+
4669
@DisplayName("push without authentication")
4770
@Test
4871
void withoutAuthentication(PushMojo mojo) {

src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ void skip(TemplateMojo mojo) {
2525
assertHelm(mojo.setSkipTemplate(true).setSkip(true));
2626
}
2727

28+
@DisplayName("with flag plain-http")
29+
@Test
30+
void plainHttp(TemplateMojo mojo) {
31+
mojo.setSkipTemplate(false);
32+
33+
mojo.setPlainHttp(false);
34+
mojo.setTemplatePlainHttp(null);
35+
assertHelm(mojo, "template src/test/resources/simple");
36+
37+
mojo.setPlainHttp(true);
38+
mojo.setTemplatePlainHttp(null);
39+
assertHelm(mojo, "template src/test/resources/simple --plain-http");
40+
41+
mojo.setPlainHttp(false);
42+
mojo.setTemplatePlainHttp(true);
43+
assertHelm(mojo, "template src/test/resources/simple --plain-http");
44+
45+
mojo.setPlainHttp(false);
46+
mojo.setTemplatePlainHttp(false);
47+
assertHelm(mojo, "template src/test/resources/simple");
48+
}
49+
2850
@DisplayName("with values overrides")
2951
@Test
3052
void valuesFile(TemplateMojo mojo) {

src/test/java/io/kokuwa/maven/helm/UpgradeMojoTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ void install(UpgradeMojo mojo) {
7272
assertHelm(mojo, "upgrade foo src/test/resources/simple");
7373
}
7474

75+
@DisplayName("with flag plain-http")
76+
@Test
77+
void plainHttp(UpgradeMojo mojo) {
78+
mojo.setSkipUpgrade(false);
79+
80+
mojo.setPlainHttp(false);
81+
mojo.setUpgradePlainHttp(null);
82+
assertHelm(mojo, "upgrade src/test/resources/simple --install");
83+
84+
mojo.setPlainHttp(true);
85+
mojo.setUpgradePlainHttp(null);
86+
assertHelm(mojo, "upgrade src/test/resources/simple --install --plain-http");
87+
88+
mojo.setPlainHttp(false);
89+
mojo.setUpgradePlainHttp(true);
90+
assertHelm(mojo, "upgrade src/test/resources/simple --install --plain-http");
91+
92+
mojo.setPlainHttp(false);
93+
mojo.setUpgradePlainHttp(false);
94+
assertHelm(mojo, "upgrade src/test/resources/simple --install");
95+
}
96+
7597
@DisplayName("with values overrides")
7698
@Test
7799
void valuesFile(UpgradeMojo mojo) {

0 commit comments

Comments
 (0)