diff --git a/deployment/pom.xml b/deployment/pom.xml
index acd8c48..6a03836 100644
--- a/deployment/pom.xml
+++ b/deployment/pom.xml
@@ -27,19 +27,8 @@
quarkus-kubernetes-deployment
- io.dekorate
- helm-annotations
- noapt
-
-
- io.sundr
- *
-
-
- com.sun
- tools
-
-
+ io.github.yaml-path
+ yaml-path
diff --git a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmChartUploader.java b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmChartUploader.java
index 5c6b06d..ee3ca49 100644
--- a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmChartUploader.java
+++ b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmChartUploader.java
@@ -1,5 +1,9 @@
package io.quarkiverse.helm.deployment;
+import static org.apache.commons.lang3.StringUtils.*;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.apache.commons.lang3.StringUtils.isNotEmpty;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -14,19 +18,16 @@
import java.net.URL;
import java.nio.charset.Charset;
-import org.apache.commons.lang3.StringUtils;
import org.jboss.logging.Logger;
-import io.dekorate.utils.Strings;
-
public final class HelmChartUploader {
- private static Logger LOGGER = Logger.getLogger(HelmProcessor.class);
+ private static final Logger LOGGER = Logger.getLogger(HelmProcessor.class);
- private static String APPLICATION_GZIP = "application/gzip";
+ private static final String APPLICATION_GZIP = "application/gzip";
private static final String CONTENT_TYPE = "Content-Type";
- private static String POST = "POST";
- private static String PUT = "PUT";
+ private static final String POST = "POST";
+ private static final String PUT = "PUT";
private HelmChartUploader() {
@@ -61,7 +62,7 @@ static void pushToHelmRepository(File tarball, HelmRepository helmRepository) {
}
private static void validate(HelmRepository repository) {
- if (repository.url().isEmpty() || Strings.isNullOrEmpty(repository.url().get())) {
+ if (repository.url().isEmpty() || isEmpty(repository.url().get())) {
throw new RuntimeException("The push to a Helm repository is enabled (the property `quarkus.helm.repository.push` "
+ "is true), but the repository URL was not provided (the property `quarkus.helm.repository.url`).");
}
@@ -71,8 +72,8 @@ private static void validate(HelmRepository repository) {
+ "is true), but the repository type was not provided (the property `quarkus.helm.repository.type`).");
}
- if ((Strings.isNotNullOrEmpty(repository.getUsername()) && Strings.isNullOrEmpty(repository.getPassword()))
- || (Strings.isNotNullOrEmpty(repository.getPassword()) && Strings.isNullOrEmpty(repository.getUsername()))) {
+ if ((isNotEmpty(repository.getUsername()) && isEmpty(repository.getPassword()))
+ || (isNotEmpty(repository.getPassword()) && isEmpty(repository.getUsername()))) {
throw new RuntimeException("The push to a Helm repository is enabled (the property `quarkus.helm.repository.push` "
+ "is true), but either the username (the property `quarkus.helm.repository.username`) "
+ "or the password (the property `quarkus.helm.repository.password`) was not set.");
@@ -106,7 +107,7 @@ private static HttpURLConnection deductConnectionByRepositoryType(File tarball,
}
private static String formatRepositoryURL(File file, HelmRepository repository) {
- return String.format("%s%s", StringUtils.appendIfMissing(repository.url().get(), "/"), file.getName());
+ return String.format("%s%s", appendIfMissing(repository.url().get(), "/"), file.getName());
}
private static HttpURLConnection createConnection(HelmRepository repository, String url) throws IOException {
@@ -119,7 +120,7 @@ private static HttpURLConnection createConnection(HelmRepository repository, Str
}
private static void verifyAndSetAuthentication(HelmRepository helmRepository) {
- if (Strings.isNotNullOrEmpty(helmRepository.getUsername()) && Strings.isNotNullOrEmpty(helmRepository.getPassword())) {
+ if (isNotEmpty(helmRepository.getUsername()) && isNotEmpty(helmRepository.getPassword())) {
PasswordAuthentication authentication = new PasswordAuthentication(helmRepository.getUsername(),
helmRepository.getPassword().toCharArray());
diff --git a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java
index c9d60be..94940b5 100644
--- a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java
+++ b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java
@@ -1,18 +1,17 @@
package io.quarkiverse.helm.deployment;
-import static io.github.yamlpath.utils.StringUtils.EMPTY;
import static io.quarkiverse.helm.deployment.HelmChartUploader.pushToHelmRepository;
import static io.quarkiverse.helm.deployment.utils.SystemPropertiesUtils.getPropertyFromSystem;
import static io.quarkiverse.helm.deployment.utils.SystemPropertiesUtils.getSystemProperties;
import static io.quarkiverse.helm.deployment.utils.SystemPropertiesUtils.hasSystemProperties;
import static io.quarkus.deployment.Capability.OPENSHIFT;
+import static org.apache.commons.lang3.StringUtils.EMPTY;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -33,16 +32,9 @@
import io.dekorate.ConfigReference;
import io.dekorate.Session;
-import io.dekorate.helm.config.HelmChartConfigBuilder;
-import io.dekorate.helm.config.HelmDependencyBuilder;
-import io.dekorate.helm.config.ValuesSchema;
-import io.dekorate.helm.config.ValuesSchemaBuilder;
-import io.dekorate.helm.config.ValuesSchemaProperty;
-import io.dekorate.helm.config.ValuesSchemaPropertyBuilder;
import io.dekorate.kubernetes.config.ContainerBuilder;
import io.dekorate.kubernetes.decorator.AddInitContainerDecorator;
import io.dekorate.project.Project;
-import io.dekorate.utils.Strings;
import io.quarkiverse.helm.deployment.decorators.LowPriorityAddEnvVarDecorator;
import io.quarkiverse.helm.deployment.utils.HelmConfigUtils;
import io.quarkus.deployment.Capabilities;
@@ -184,10 +176,6 @@ private void doGenerateResources(ApplicationInfoBuildItem app, OutputTargetBuild
final Map> deploymentTargets = toDeploymentTargets(dekorateOutput.getGeneratedFiles(),
generatedResources);
- // Config
- io.dekorate.helm.config.HelmChartConfig dekorateHelmChartConfig = toDekorateHelmChartConfig(app, config);
- List valueReferencesFromUser = toValueReferences(config);
-
// Deduct deployment target to push
String deploymentTargetToPush = deductDeploymentTarget(config, deploymentTargets);
@@ -197,14 +185,14 @@ private void doGenerateResources(ApplicationInfoBuildItem app, OutputTargetBuild
Path chartOutputFolder = outputFolder.resolve(deploymentTarget);
deleteOutputHelmFolderIfExists(chartOutputFolder);
- Map generated = helmWriter.writeHelmFiles(project,
- dekorateHelmChartConfig,
- valueReferencesFromUser,
+ Map generated = helmWriter.writeHelmFiles(
+ config.name().orElse(app.getName()),
+ project,
+ config,
getConfigReferencesFromSession(deploymentTarget, dekorateOutput),
inputFolder,
chartOutputFolder,
- filesInDeploymentTarget.getValue(),
- config.valuesProfileSeparator());
+ filesInDeploymentTarget.getValue());
// Push to Helm repository if enabled
if (config.repository().push() && deploymentTargetToPush.equals(deploymentTarget)) {
@@ -359,125 +347,6 @@ private Map> toDeploymentTargets(List generatedFiles,
return filesByDeploymentTarget;
}
- private io.dekorate.helm.config.HelmChartConfig toDekorateHelmChartConfig(ApplicationInfoBuildItem app,
- HelmChartConfig config) {
- HelmChartConfigBuilder builder = new HelmChartConfigBuilder()
- .withEnabled(config.enabled())
- .withApiVersion(config.apiVersion())
- .withName(config.name().orElse(app.getName()))
- .withCreateTarFile(config.createTarFile() || config.repository().push())
- .withCreateValuesSchemaFile(config.createValuesSchemaFile())
- .withCreateReadmeFile(config.createReadmeFile())
- .withVersion(config.version().orElse(app.getVersion()))
- .withExtension(config.extension())
- .withValuesRootAlias(config.valuesRootAlias())
- .withNotes(config.notes());
- config.description().ifPresent(builder::withDescription);
- config.keywords().ifPresent(builder::addAllToKeywords);
- config.icon().ifPresent(builder::withIcon);
- config.condition().ifPresent(builder::withCondition);
- config.tags().ifPresent(builder::withTags);
- config.appVersion().ifPresent(builder::withAppVersion);
- config.deprecated().ifPresent(builder::withDeprecated);
- config.annotations().entrySet().forEach(e -> builder.addNewAnnotation(e.getKey(), e.getValue()));
- config.kubeVersion().ifPresent(builder::withKubeVersion);
- config.type().ifPresent(builder::withType);
- config.home().ifPresent(builder::withHome);
- config.sources().ifPresent(builder::addAllToSources);
- config.maintainers().entrySet()
- .forEach(e -> builder.addNewMaintainer(
- defaultString(e.getValue().name(), e.getKey()),
- defaultString(e.getValue().email()),
- defaultString(e.getValue().url())));
- config.dependencies().entrySet()
- .forEach(e -> builder.addToDependencies(toDekorateHelmDependencyConfig(e.getKey(), e.getValue())));
- config.tarFileClassifier().ifPresent(builder::withTarFileClassifier);
- config.expressions().values().forEach(e -> builder.addNewExpression(e.path(), e.expression()));
- config.addIfStatement().entrySet()
- .forEach(e -> {
- builder.addNewAddIfStatement(
- defaultString(e.getValue().property(), e.getKey()),
- defaultString(e.getValue().onResourceKind()),
- defaultString(e.getValue().onResourceName()),
- e.getValue().withDefaultValue(),
- e.getValue().description());
- });
-
- builder.withValuesSchema(toValuesSchema(config.valuesSchema()));
-
- return builder.build();
- }
-
- private ValuesSchema toValuesSchema(ValuesSchemaConfig valuesSchema) {
- List properties = new ArrayList<>();
- for (Map.Entry property : valuesSchema.properties().entrySet()) {
- String name = property.getValue().name().orElse(property.getKey());
-
- properties.add(new ValuesSchemaPropertyBuilder()
- .withName(name)
- .withType(property.getValue().type())
- .withDescription(defaultString(property.getValue().description()))
- .withMaximum(property.getValue().maximum().orElse(Integer.MAX_VALUE))
- .withMinimum(property.getValue().minimum().orElse(Integer.MIN_VALUE))
- .withRequired(property.getValue().required())
- .withPattern(defaultString(property.getValue().pattern()))
- .build());
- }
-
- return new ValuesSchemaBuilder()
- .withTitle(valuesSchema.title())
- .withProperties(properties.toArray(new ValuesSchemaProperty[0]))
- .build();
- }
-
- private io.dekorate.helm.config.HelmDependency toDekorateHelmDependencyConfig(String dependencyName,
- HelmDependencyConfig dependency) {
- HelmDependencyBuilder builder = new HelmDependencyBuilder()
- .withName(defaultString(dependency.name(), dependencyName))
- .withAlias(defaultString(dependency.alias(), defaultString(dependency.name(), dependencyName)))
- .withVersion(dependency.version())
- .withRepository(dependency.repository())
- .withCondition(defaultString(dependency.condition()))
- .withTags(defaultArray(dependency.tags()))
- .withEnabled(dependency.enabled().orElse(true));
-
- return builder.build();
- }
-
- private List toValueReferences(HelmChartConfig config) {
- return config.values().entrySet().stream()
- .map(e -> new ConfigReference.Builder(defaultString(e.getValue().property(), e.getKey()),
- defaultArray(e.getValue().paths()))
- .withValue(toValue(e.getValue()))
- .withDescription(defaultString(e.getValue().description(), EMPTY))
- .withExpression(defaultString(e.getValue().expression()))
- .withProfile(defaultString(e.getValue().profile()))
- .withRequired(e.getValue().required())
- .withPattern(defaultString(e.getValue().pattern()))
- .withMaximum(e.getValue().maximum().orElse(Integer.MAX_VALUE))
- .withMinimum(e.getValue().minimum().orElse(Integer.MIN_VALUE))
- .build())
- .collect(Collectors.toList());
- }
-
- private Object toValue(ValueReferenceConfig v) {
- if (v.valueAsInt().isPresent()) {
- return v.valueAsInt().get();
- } else if (v.valueAsBool().isPresent()) {
- return v.valueAsBool().get();
- } else if (!v.valueAsMap().isEmpty()) {
- return v.valueAsMap();
- } else if (v.valueAsList().isPresent()) {
- return v.valueAsList().get();
- }
-
- return v.value().orElse(null);
- }
-
- private String defaultString(Optional value) {
- return defaultString(value, null);
- }
-
private String defaultString(Optional value, String defaultStr) {
if (value.isEmpty() || StringUtils.isEmpty(value.get())) {
return defaultStr;
@@ -486,10 +355,6 @@ private String defaultString(Optional value, String defaultStr) {
return value.get();
}
- private static String[] defaultArray(Optional> optional) {
- return optional.map(l -> l.toArray(new String[0])).orElse(new String[0]);
- }
-
private String mapProperty(String deploymentName, BuildProducer decorators, String property,
Map propertiesFromConfigSource) {
if (!hasSystemProperties(property)) {
@@ -542,7 +407,7 @@ public static String getDeploymentName(Capabilities capabilities, ApplicationInf
}
private boolean isPropertiesConfigSource(String sourceName) {
- return Strings.isNotNullOrEmpty(sourceName) && sourceName.startsWith(PROPERTIES_CONFIG_SOURCE);
+ return StringUtils.isNotEmpty(sourceName) && sourceName.startsWith(PROPERTIES_CONFIG_SOURCE);
}
private boolean isBuildTimeProperty(String name) {
diff --git a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmRepository.java b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmRepository.java
index 7930456..95abf99 100644
--- a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmRepository.java
+++ b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmRepository.java
@@ -2,7 +2,8 @@
import java.util.Optional;
-import io.dekorate.utils.Strings;
+import org.apache.commons.lang3.StringUtils;
+
import io.smallrye.config.WithDefault;
public interface HelmRepository {
@@ -39,10 +40,10 @@ public interface HelmRepository {
Optional password();
default String getUsername() {
- return username().filter(Strings::isNotNullOrEmpty).orElse(null);
+ return username().filter(StringUtils::isNotEmpty).orElse(null);
}
default String getPassword() {
- return password().filter(Strings::isNotNullOrEmpty).orElse(null);
+ return password().filter(StringUtils::isNotEmpty).orElse(null);
}
}
diff --git a/deployment/src/main/java/io/quarkiverse/helm/deployment/QuarkusHelmWriterSessionListener.java b/deployment/src/main/java/io/quarkiverse/helm/deployment/QuarkusHelmWriterSessionListener.java
index 752537d..dd4438d 100644
--- a/deployment/src/main/java/io/quarkiverse/helm/deployment/QuarkusHelmWriterSessionListener.java
+++ b/deployment/src/main/java/io/quarkiverse/helm/deployment/QuarkusHelmWriterSessionListener.java
@@ -1,24 +1,7 @@
-/**
- * Copyright 2018 The original authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- **/
package io.quarkiverse.helm.deployment;
-import static io.dekorate.helm.util.HelmTarArchiver.createTarBall;
-import static io.dekorate.utils.Strings.isNullOrEmpty;
import static io.quarkiverse.helm.deployment.utils.HelmConfigUtils.deductProperty;
+import static io.quarkiverse.helm.deployment.utils.HelmTarArchiver.createTarBall;
import static io.quarkiverse.helm.deployment.utils.MapUtils.toMultiValueUnsortedMap;
import static io.quarkiverse.helm.deployment.utils.MapUtils.toPlainMap;
import static io.quarkiverse.helm.deployment.utils.ValuesSchemaUtils.createSchema;
@@ -33,6 +16,7 @@
import static io.quarkiverse.helm.deployment.utils.YamlExpressionParserUtils.readAndSet;
import static io.quarkiverse.helm.deployment.utils.YamlExpressionParserUtils.set;
import static io.quarkiverse.helm.deployment.utils.YamlExpressionParserUtils.toExpression;
+import static org.apache.commons.lang3.ObjectUtils.isEmpty;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -56,28 +40,24 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+
import com.fasterxml.jackson.core.type.TypeReference;
import io.dekorate.ConfigReference;
import io.dekorate.Logger;
import io.dekorate.LoggerFactory;
-import io.dekorate.helm.config.AddIfStatement;
-import io.dekorate.helm.config.Annotation;
-import io.dekorate.helm.config.HelmChartConfig;
-import io.dekorate.helm.config.HelmExpression;
-import io.dekorate.helm.listener.HelmWriterSessionListener;
-import io.dekorate.helm.model.Chart;
-import io.dekorate.helm.model.HelmDependency;
-import io.dekorate.helm.model.Maintainer;
-import io.dekorate.helm.util.HelmConfigUtils;
-import io.dekorate.helm.util.MapUtils;
import io.dekorate.project.Project;
import io.dekorate.utils.Exec;
import io.dekorate.utils.Maps;
import io.dekorate.utils.Serialization;
-import io.dekorate.utils.Strings;
import io.github.yamlpath.YamlExpressionParser;
import io.github.yamlpath.YamlPath;
+import io.quarkiverse.helm.deployment.model.Chart;
+import io.quarkiverse.helm.deployment.model.HelmDependency;
+import io.quarkiverse.helm.deployment.model.Maintainer;
+import io.quarkiverse.helm.deployment.utils.FileUtils;
+import io.quarkiverse.helm.deployment.utils.MapUtils;
import io.quarkiverse.helm.deployment.utils.ReadmeBuilder;
import io.quarkiverse.helm.deployment.utils.ValuesHolder;
@@ -109,36 +89,34 @@ public class QuarkusHelmWriterSessionListener {
*
* @return the list of the Helm generated files.
*/
- public Map writeHelmFiles(Project project,
- io.dekorate.helm.config.HelmChartConfig helmConfig,
- List valueReferencesFromUser,
+ public Map writeHelmFiles(String name,
+ Project project,
+ HelmChartConfig helmConfig,
List valueReferencesFromDecorators,
Path inputDir,
Path outputDir,
- Collection generatedFiles,
- String valuesProfileSeparator) {
+ Collection generatedFiles) {
Map artifacts = new HashMap<>();
- if (helmConfig.isEnabled()) {
- validateHelmConfig(helmConfig);
+ if (helmConfig.enabled()) {
try {
- LOGGER.info(String.format("Creating Helm Chart \"%s\"", helmConfig.getName()));
+ LOGGER.info(String.format("Creating Helm Chart \"%s\"", name));
ValuesHolder values = populateValuesFromConfig(helmConfig, inputDir);
List