summaryrefslogtreecommitdiffstats
path: root/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java
diff options
context:
space:
mode:
Diffstat (limited to 'mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java')
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java
index ed861b0..ab0b964 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java
@@ -40,14 +40,19 @@ import java.util.Objects;
@Slf4j
public class ChartMuseumDistributor implements ChartDistributor {
- @Value("${chartmuseum.baseurl}")
- private String chartMuseumUrl;
+ private final String chartMuseumUrl;
- @Value("${chartmuseum.auth.basic.username}")
- private String username;
+ private final String username;
- @Value("${chartmuseum.auth.basic.password}")
- private String password;
+ private final String password;
+
+ public ChartMuseumDistributor( @Value("${chartmuseum.baseurl}") String chartMuseumUrl,
+ @Value("${chartmuseum.auth.basic.username}") String username,
+ @Value("${chartmuseum.auth.basic.password}")String password) {
+ this.chartMuseumUrl = chartMuseumUrl;
+ this.username = username;
+ this.password = password;
+ }
/**
* distributes chart to Chart Museum
@@ -60,6 +65,9 @@ public class ChartMuseumDistributor implements ChartDistributor {
try {
Response response = client.newCall(request).execute();
log.info(Objects.requireNonNull(response.body()).string());
+ if(!response.isSuccessful()){
+ throw new RuntimeException("Distribution Failed.");
+ }
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
@@ -70,7 +78,7 @@ public class ChartMuseumDistributor implements ChartDistributor {
MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(chartFile, mediaType);
return new Request.Builder()
- .url(chartMuseumUrl)
+ .url(chartMuseumUrl + "/api/charts")
.method("POST", body)
.addHeader("Content-Type", "application/octet-stream")
.addHeader("Authorization", credential)