Skip to content

Commit

Permalink
added requested changes to finalize upload verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Cho-William committed Dec 7, 2023
1 parent db6cb0d commit ff12308
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/main/java/io/kokuwa/maven/helm/UploadMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
public class UploadMojo extends AbstractHelmMojo {

private static final ObjectMapper MAPPER = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
private static final ObjectMapper YAML_MAPPER = new YAMLMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
private static final String CATALOG_ARTIFACT_NAME = "helm-catalog";
private static final String CATALOG_ARTIFACT_TYPE = "json";

Expand Down Expand Up @@ -127,7 +129,7 @@ public void execute() throws MojoExecutionException {
}

if (uploadVerificationTimeout != null && uploadVerificationTimeout <= 0) {
throw new IllegalArgumentException("Timeout must be a positive value.");
throw new MojoExecutionException("Timeout must be a positive value.");
}

getLog().info("Uploading to " + getHelmUploadUrl() + "\n");
Expand Down Expand Up @@ -311,11 +313,9 @@ private void uploadSingle(Path chart) throws MojoExecutionException, IOException
}

private boolean verifyUpload(Path chartPath) throws MojoExecutionException {
ObjectMapper mapper = new YAMLMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String chartName;
try {
chartName = mapper.readValue(chartPath.toFile(), HelmChart.class).getName();
chartName = YAML_MAPPER.readValue(chartPath.toFile(), HelmChart.class).getName();
} catch (IOException e) {
throw new MojoExecutionException("Unable to read chart from " + chartPath, e);
}
Expand All @@ -332,7 +332,7 @@ private boolean verifyUpload(Path chartPath) throws MojoExecutionException {
"--version", getChartVersion(), "--repo", getHelmUploadUrl())
.execute("show chart failed");
verificationSuccess = true;
} catch (Exception e) {
} catch (Exception MojoExecutionException) {
getLog().info("Upload verification failed, retrying...");
try {
Thread.sleep(1000);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/kokuwa/maven/helm/UploadMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void timeoutTimeNotPositive(UploadMojo mojo) throws Exception {
mojo.setUploadVerificationTimeout(-1);
mojo.setChartVersion("0.1.0");
copyPackagedHelmChartToOutputdirectory(mojo);
assertThrows(IllegalArgumentException.class, mojo::execute, "Nonpositive timeout must fail.");
assertThrows(MojoExecutionException.class, mojo::execute, "Nonpositive timeout must fail.");
}

private void assertUpload(UploadMojo mojo, RequestMethod method, String path, String authorization) {
Expand Down

0 comments on commit ff12308

Please sign in to comment.