diff --git a/.editorconfig b/.editorconfig
index a55132b..5a306ee 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -37,3 +37,6 @@ tab_width = 4
indent_style = space
indent_size = 2
+[*.md]
+indent_style = space
+indent_size = 2
diff --git a/CHANGELOG.adoc b/CHANGELOG.md
similarity index 82%
rename from CHANGELOG.adoc
rename to CHANGELOG.md
index 120e92b..a907289 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.md
@@ -1,98 +1,103 @@
-= Changelog
+# Changelog
-== Version 2.11.1
+## Unreleased
+
+* Converted README and CHANGELOG to Markdown
+* Add option to provide additional values files
+
+## Version 2.11.1
* Fix helm binary path when adding incubator repository
-== Version 2.11.0
+## Version 2.11.0
* Support authentication to the helm repository using credentials from server definitions in maven `settings.xml` via `chartRepoServerId`.
* Add an option to pass `--force-update` when adding helm repositories managed by this plugin.
* Cleanup dependencies, readme, and deprecated Kotlin functions
-== Version 2.10.0
+## Version 2.10.0
* Add a new goal, `resolve`, for downloading the helm binary as a separate step. This will still be done automatically
by the other goals, but it can be used when running maven builds in parallel, so the helm binary doesn't need to be
downloaded twice and to prevent concurrency issues.
-== Version 2.9.0
+## Version 2.9.0
* Support configuring the default URL of the helm repository for helm 2.x via `stableRepoUrl`
-== Version 2.8.1
+## Version 2.8.1
* Fix detection of aarch64/arm64 architecture
-== Version 2.8.0
+## Version 2.8.0
* Support configuring the URL to the incubator repository via `incubatorRepoUrl` and allow to disable the incubator repository via `addIncubatorRepo`
-== Version 2.7.1
+## Version 2.7.1
* Fix inverted status check which _fails_ for any 2xx HTTP status
-== Version 2.7.0
+## Version 2.7.0
* Accept any 2xx HTTP status code when deploying Helm charts
* Use new incubator repository hosted at https://charts.helm.sh/incubator
-== Version 2.6.0
+## Version 2.6.0
* If the package can't resolve a property an exception is no longer thrown. This behaviour is now logged with a
warning, and the packaging mojo continues.
-== Version 2.5.1
+## Version 2.5.1
* Ignore `Set-Cookie` header of responses in the `deploy` goal
* Update dependency versions
-== Version 2.5.0
+## Version 2.5.0
* Make `chartRepoUrl` optional
* Add logging for property resolution
* Limit property substitution in `package` mojo to the file extensions "json", "tpl", "yml" and "yaml"
* Allow multiple property substitutions on a single line
-== Version 2.4.1
+## Version 2.4.1
* Fix a bug where `chartVersion` always had to be configured explicitly. After this fix, `chartVersion` correctly falls
back to `project.model.version` again.
-== Version 2.4.0
+## Version 2.4.0
* Support other chart registries like JFrog Artifactory by introducing new optional configuration parameters:
-** `chartPublishUrl`
-** `chartPublishMethod`
-** `chartDeleteUrl`
+ * `chartPublishUrl`
+ * `chartPublishMethod`
+ * `chartDeleteUrl`
* Support chart registries that need authentication for pulling images.
* Fix a problem with quoted file path arguments on Linux by only quoting paths that contain a space.
-== Version 2.3.0
+## Version 2.3.0
* Support overriding the chart version using the configuration parameter `chartVersion`. If `chartVersion` is not
configured, the value for `project.model.version` will be used instead.
* Add support for Helm 3.
-== Version 2.2.0
+## Version 2.2.0
* Update dependency on `jackson-databind` to version 2.9.10 because of
- https://nvd.nist.gov/vuln/detail/CVE-2019-14540[CVE-2019-14540] and
- https://nvd.nist.gov/vuln/detail/CVE-2019-16335[CVE-2019-16335].
+ [CVE-2019-14540](https://nvd.nist.gov/vuln/detail/CVE-2019-14540) and
+ [CVE-2019-16335](https://nvd.nist.gov/vuln/detail/CVE-2019-16335).
* Replace gitflow plugin `jgitflow-maven-plugin` with
- https://github.com/aleksandr-m/gitflow-maven-plugin[gitflow-maven-plugin].
+ [gitflow-maven-plugin](https://github.com/aleksandr-m/gitflow-maven-plugin).
-== Version 2.1.1
+## Version 2.1.1
* Update dependency on `jackson-databind` to version 2.9.9 because of
- https://nvd.nist.gov/vuln/detail/CVE-2019-12086[CVE-2019-12086].
+ [CVE-2019-12086](https://nvd.nist.gov/vuln/detail/CVE-2019-12086).
-== Version 2.1.0
+## Version 2.1.0
* Add new goal lint, which runs linting using helm lint.
* Make sure `target/test-classes` is created if it's missing.
-== Version 2.0.0
+## Version 2.0.0
* Support multiple platforms.
* Download official helm binary release if release is missing in remote artifact repository.
diff --git a/README.adoc b/README.adoc
deleted file mode 100644
index 2980a6b..0000000
--- a/README.adoc
+++ /dev/null
@@ -1,221 +0,0 @@
-= Helm Maven Plugin
-
-:uri-build-status: https://github.com/deviceinsight/helm-maven-plugin/actions/workflows/maven.yml
-:img-build-status: https://github.com/deviceinsight/helm-maven-plugin/actions/workflows/maven.yml/badge.svg
-
-image:{img-build-status}[Build Status Badge,link={uri-build-status}]
-
-A Maven plugin that makes Maven properties available in your Helm Charts. It can be used to automatically package your
-Helm Chart, render it and upload it to a Helm repository like https://chartmuseum.com/[ChartMuseum].
-
-== Usage
-
-Add the following to your `pom.xml`
-
-[source,xml]
-....
-
-
- ...
-
- com.deviceinsight.helm
- helm-maven-plugin
- 2.11.0
-
- my-chart
- https://charts.helm.sh/stable
- 3.5.2
- true
- src/test/helm/my-chart/values.yaml
-
-
-
-
- package
- lint
- template
- deploy
-
-
-
-
-
-
-....
-
-In the same Maven module, put your helm charts into `src/main/helm/`. In the `Chart.yaml`, you can use the
-`${artifactId}`, `${project.version}`, and `${project.name}` Maven placeholders. You can also use Maven properties.
-
-An example for a `Chart.yaml` is:
-
-[source,yaml]
-....
-apiVersion: v1
-description: A Helm chart installing Rubicon
-name: ${artifactId}
-version: ${project.version}
-home: https://gitlab.device-insight.com/deviceinsight/rubicon
-maintainers:
- - name: Device Insight
- url: https://www.device-insight.com
-....
-
-You probably also will adjust the `templates/deployment.yaml` so
-that the correct docker image is used. An example snippet:
-
-[source,yaml]
-....
-[...]
- containers:
- - name: {{ .Chart.Name }}
- image: "{{ .Values.image.repository }}/rubicon:${project.version}"
-[...]
-....
-
-== Configuration
-
-|===
-|Property |Default |Description
-
-|chartName |The Maven `artifactId` |The name of the chart
-|chartVersion |`${project.model.version}` |The version of the chart
-|chartRepoUrl |`null` |The URL of the Chart repository where dependencies are required from and where charts should be published to
-|incubatorRepoUrl |`https://charts.helm.sh/incubator` |The URL to the incubator Chart repository
-|addIncubatorRepo |`true` |Whether the repository defined in `incubatorRepoUrl` should be added when running the package goal
-|forceAddRepos |`false` |Whether to overwrite the repository configuration when adding a new repository with the same name. This flag is only relevant when using Helm 3 and emulates Helm 2 behavior
-|chartPublishUrl |`${chartRepoUrl}/api/charts` |The URL that will be used for publishing the chart. The default value will work if `chartRepoUrl` refers to a ChartMuseum.
-|chartPublishMethod |"POST" |The HTTP method that will be used for publishing requests
-|chartDeleteUrl |`${chartRepoUrl}/api/charts/${chartName}/${chartVersion}` |The URL that will be used for deleting a previous version of the chart. This is used for updating SNAPSHOT versions. The default value will work if `chartRepoUrl` refers to a ChartMuseum.
-|chartRepoUsername |None |The username for basic authentication against the chart repo
-|chartRepoPassword |None |The password for basic authentication against the chart repo
-|chartRepoServerId |None |The ID of the server definition from the settings.xml server list to obtain the chart repo username/password from. If both chartRepoUsername/chartRepoPassword and chartRepoServerId are specified then the values specified in chartRepoUsername/chartRepoPassword take precedence.
-|chartFolder |`"src/main/helm/"` |The location of the chart files (e.g. Chart.yaml).
-|skipSnapshots |`true` |If true, SNAPSHOT versions will be built, but not deployed.
-|helmGroupId |`"com.deviceinsight.helm"` |The helm binary `groupId`
-|helmArtifactId |`"helm"` |The helm binary `artifactId`
-|helmVersion |None |The helm binary `version`. (Make sure to use a recent helm binary version that doesn't use the old Helm Chart repositories from `+https://kubernetes-charts.storage.googleapis.com+`, >= 3.4.0 _or_ >= 2.17.0 if you are still using Helm 2)
-|helmDownloadUrl |`"https://get.helm.sh/"` |The URL where the helm binary is downloaded from.
-|helm.skip |`false` |If true, execution will be skipped entirely
-|stableRepoUrl | `"https://charts.helm.sh/stable"` | For helm 2.x: Can be used to overwrite the default URL for stable repository during `helm init`
-|strictLint |`false` |If true, linting fails on warnings (see: <>)
-|valuesFile | None | values file that should be used for goals <>, <>
-|outputFile | target/test-classes/helm.yaml | output file for <>
-|deployAtEnd |`false` | If true, the helm chart is deployed at the end of a multi-module Maven build. This option does not make sense for single-module Maven projects.
-
-|===
-
-== Goals
-
-[#goal-package]
-=== Package
-
-Goal packages a chart directory into a chart archive using the https://github.com/helm/helm/blob/master/docs/helm/helm_package.md[helm package] command.
-
-[#goal-deploy]
-=== Deploy
-
-Goal publishes the packaged chart in the configured chart repository.
-
-[#goal-lint]
-=== Lint
-
-Goal examines a chart for possible issues using the https://github.com/helm/helm/blob/master/docs/helm/helm_lint.md[helm lint] command.
-
-* A values file can be provided via parameter `valueFile`
-* Strict linting can be configured via parameter `strictLint`
-
-
-[#goal-template]
-=== Template
-
-goal locally renders templates using the https://github.com/helm/helm/blob/master/docs/helm/helm_template.md[helm template] command.
-
-* A values file can be provided via parameter `valueFile`
-* An output file can be provided via parameter `outputFile`
-
-== Example
-
-To use the `deployAtEnd` functionality it's mandatory to put the Helm Maven Plugin configuration in the parent pom.
-
-[source,xml]
-....
-
-
- ...
-
- com.deviceinsight.helm
- helm-maven-plugin
- 2.11.0
-
- my-chart
- https://charts.helm.sh/stable
- 3.5.2
- true
- src/test/helm/my-chart/values.yaml
- true
-
-
-
-
- package
- lint
- template
- deploy
-
-
-
-
-
-
-....
-
-== Troubleshooting
-
-. {blank}
-Problem:: The following error message is a common source of trouble, lately:
-+
-----
-[ERROR] Output: Error: error initializing: Looks like "https://kubernetes-charts.storage.googleapis.com" is not a valid chart repository or cannot be reached: Failed to fetch https://kubernetes-charts.storage.googleapis.com/index.yaml : 403 Forbidden
-
-...
-
-[ERROR] Failed to execute goal com.deviceinsight.helm:helm-maven-plugin:2.11.0:package (default) on project my-project: Error creating helm chart: When executing '/home/user/.m2/repository/com/deviceinsight/helm/helm/2.16.2/helm-2.16.2-linux-amd64.binary init --client-only' got result code '1' -> [Help 1]
-----
-Solution:: This is likely due to an old version of helm itself. Make sure to configure `` to a version >= 3.4.0 or, if you are still using Helm 2, a version >= 2.17.0 (https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice[background information]).
-. {blank}
-+
-Problem:: The following error message appears if you use an old version of helm-maven-plugin:
-+
-----
-[ERROR] Output: Error: error initializing: Looks like "https://kubernetes-charts-incubator.storage.googleapis.com" is not a valid chart repository or cannot be reached: Failed to fetch https://kubernetes-charts-incubator.storage.googleapis.com/index.yaml : 403 Forbidden
-----
-Solution:: This can be solved by upgrading helm-maven-plugin itself to version 2.7.0 or later (https://github.com/deviceinsight/helm-maven-plugin/issues/67[#67]).
-
-== Releasing
-
-Creating a new release involves the following steps:
-
-. `./mvnw gitflow:release-start gitflow:release-finish`
-. `git push origin master`
-. `git push --tags`
-. `git push origin develop`
-
-In order to deploy the release to Maven Central, you need to create an account at https://issues.sonatype.org and
-configure your account in `~/.m2/settings.xml`:
-
-[source,xml]
-....
-
-
-
- ossrh
- your-jira-id
- your-jira-pwd
-
-
-
-....
-
-The account also needs access to the project on Maven Central. This can be requested by another project member.
-
-Then check out the release you want to deploy (`git checkout x.y.z`) and run `./mvnw deploy -Prelease`.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b0f441b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,207 @@
+# Helm Maven Plugin
+
+[](https://github.com/deviceinsight/helm-maven-plugin/actions/workflows/maven.yml)
+
+A Maven plugin that makes Maven properties available in your Helm Charts. It can be used to automatically package your
+Helm Chart, render it and upload it to a Helm repository like [ChartMuseum](https://chartmuseum.com/).
+
+## Usage
+
+Add the following to your `pom.xml`
+
+```xml
+
+
+ ...
+
+ com.deviceinsight.helm
+ helm-maven-plugin
+ 2.11.1
+
+ my-chart
+ https://charts.helm.sh/stable
+ 3.11.1
+ true
+ src/test/helm/my-chart/values.yaml
+
+
+
+
+ package
+ lint
+ template
+ deploy
+
+
+
+
+
+
+```
+
+In the same Maven module, put your helm charts into `src/main/helm/`. In the `Chart.yaml`, you can use the
+`${artifactId}`, `${project.version}`, and `${project.name}` Maven placeholders. You can also use Maven properties.
+
+An example for a `Chart.yaml` is:
+
+```yaml
+apiVersion: v1
+description: A Helm chart installing Rubicon
+name: ${artifactId}
+version: ${project.version}
+home: https://gitlab.device-insight.com/deviceinsight/rubicon
+maintainers:
+ - name: Device Insight
+ url: https://www.device-insight.com
+```
+
+You probably also will adjust the `templates/deployment.yaml` so
+that the correct docker image is used. An example snippet:
+
+```yaml
+[...]
+ containers:
+ - name: {{ .Chart.Name }}
+ image: "{{ .Values.image.repository }}/rubicon:${project.version}"
+[...]
+```
+
+## Configuration
+
+| Property | Default | Description |
+|---|---|---|
+| chartName | The Maven `artifactId` | The name of the chart |
+| chartVersion | `${project.model.version}` | The version of the chart |
+| chartRepoUrl | `null` | The URL of the Chart repository where dependencies are required from and where charts should be published to |
+| incubatorRepoUrl | `https://charts.helm.sh/incubator` | The URL to the incubator Chart repository |
+| addIncubatorRepo | `true` | Whether the repository defined in `incubatorRepoUrl` should be added when running the package goal |
+| forceAddRepos | `false` | Whether to overwrite the repository configuration when adding a new repository with the same name. This flag is only relevant when using Helm 3 and emulates Helm 2 behavior |
+| chartPublishUrl | `${chartRepoUrl}/api/charts` | The URL that will be used for publishing the chart. The default value will work if `chartRepoUrl` refers to a ChartMuseum. |
+| chartPublishMethod | "POST" | The HTTP method that will be used for publishing requests |
+| chartDeleteUrl | `${chartRepoUrl}/api/charts/${chartName}/${chartVersion}` | The URL that will be used for deleting a previous version of the chart. This is used for updating SNAPSHOT versions. The default value will work if `chartRepoUrl` refers to a ChartMuseum. |
+| chartRepoUsername | None | The username for basic authentication against the chart repo |
+| chartRepoPassword | None | The password for basic authentication against the chart repo |
+| chartRepoServerId | None | The ID of the server definition from the settings.xml server list to obtain the chart repo username/password from. If both chartRepoUsername/chartRepoPassword and chartRepoServerId are specified then the values specified in chartRepoUsername/chartRepoPassword take precedence. |
+| chartFolder | `"src/main/helm/"` | The location of the chart files (e.g. Chart.yaml). |
+| skipSnapshots | `true` | If true, SNAPSHOT versions will be built, but not deployed. |
+| helmGroupId | `"com.deviceinsight.helm"` | The helm binary `groupId` |
+| helmArtifactId | `"helm"` | The helm binary `artifactId` |
+| helmVersion | None | The helm binary `version`. (Make sure to use a recent helm binary version that doesn't use the old Helm Chart repositories from `+https://kubernetes-charts.storage.googleapis.com+`, >= 3.4.0 _or_ >= 2.17.0 if you are still using Helm 2) |
+| helmDownloadUrl | `"https://get.helm.sh/"` | The URL where the helm binary is downloaded from. |
+| helm.skip | `false` | If true, execution will be skipped entirely |
+| stableRepoUrl | `"https://charts.helm.sh/stable"` | For helm 2.x: Can be used to overwrite the default URL for stable repository during `helm init` |
+| strictLint | `false` | If true, linting fails on warnings (see: [Lint](#lint)) |
+| valuesFile | None | values file that should be used for goals [Lint](#lint), [Template](#template) |
+| extraValuesFiles | None | a list of additional values files that can be generated dynamically and will be merged with the values.yaml during [Package](#package). |
+| outputFile | target/test-classes/helm.yaml | output file for [template goal](#template) |
+| deployAtEnd | `false` | If true, the helm chart is deployed at the end of a multi-module Maven build. This option does not make sense for single-module Maven projects. |
+
+## Goals
+
+### Package
+
+Goal packages a chart directory into a chart archive using the [helm package](https://github.com/helm/helm/blob/master/docs/helm/helm_package.md) command.
+
+### Deploy
+
+Goal publishes the packaged chart in the configured chart repository.
+
+### Lint
+
+Goal examines a chart for possible issues using the [helm lint](https://github.com/helm/helm/blob/master/docs/helm/helm_lint.md) command.
+
+* A values file can be provided via parameter `valueFile`
+* Strict linting can be configured via parameter `strictLint`
+
+### Template
+
+goal locally renders templates using the [helm template](https://github.com/helm/helm/blob/master/docs/helm/helm_template.md) command.
+
+* A values file can be provided via parameter `valueFile`
+* An output file can be provided via parameter `outputFile`
+
+## Example
+
+To use the `deployAtEnd` functionality it's mandatory to put the Helm Maven Plugin configuration in the parent pom.
+
+```xml
+
+
+ ...
+
+ com.deviceinsight.helm
+ helm-maven-plugin
+ 2.11.1
+
+ my-chart
+ https://charts.helm.sh/stable
+ 3.5.2
+ true
+ src/test/helm/my-chart/values.yaml
+ true
+
+
+
+
+ package
+ lint
+ template
+ deploy
+
+
+
+
+
+
+```
+
+## Troubleshooting
+
+1. _**Problem**_
+ The following error message is a common source of trouble, lately:
+ ```
+ [ERROR] Output: Error: error initializing: Looks like "https://kubernetes-charts.storage.googleapis.com" is not a valid chart repository or cannot be reached: Failed to fetch https://kubernetes-charts.storage.googleapis.com/index.yaml : 403 Forbidden
+
+ ...
+
+ [ERROR] Failed to execute goal com.deviceinsight.helm:helm-maven-plugin:2.11.1:package (default) on project my-project: Error creating helm chart: When executing '/home/user/.m2/repository/com/deviceinsight/helm/helm/2.16.2/helm-2.16.2-linux-amd64.binary init --client-only' got result code '1' -> [Help 1]
+ ```
+ _**Solution**_
+ This is likely due to an old version of helm itself. Make sure to configure `` to a version >= 3.4.0 or, if you are still using Helm 2, a version >= 2.17.0 ([background information](https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice)).
+
+
+2. _**Problem**_
+ The following error message appears if you use an old version of helm-maven-plugin:
+ ```
+ [ERROR] Output: Error: error initializing: Looks like "https://kubernetes-charts-incubator.storage.googleapis.com" is not a valid chart repository or cannot be reached: Failed to fetch https://kubernetes-charts-incubator.storage.googleapis.com/index.yaml : 403 Forbidden
+ ```
+ _**Solution**_
+ This can be solved by upgrading helm-maven-plugin itself to version 2.7.0 or later ([#67](https://github.com/deviceinsight/helm-maven-plugin/issues/67)).
+
+## Releasing
+
+Creating a new release involves the following steps:
+
+1. `./mvnw gitflow:release-start gitflow:release-finish`
+2. `git push origin master`
+3. `git push --tags`
+4. `git push origin develop`
+
+In order to deploy the release to Maven Central, you need to create an account at https://issues.sonatype.org and
+configure your account in `~/.m2/settings.xml`:
+
+```xml
+
+
+
+ ossrh
+ your-jira-id
+ your-jira-pwd
+
+
+
+```
+
+The account also needs access to the project on Maven Central. This can be requested by another project member.
+
+Then check out the release you want to deploy (`git checkout x.y.z`) and run `./mvnw deploy -Prelease`.
diff --git a/pom.xml b/pom.xml
index 1b2fe90..24e08b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.deviceinsight.helm
helm-maven-plugin
- 2.11.1
+ 2.12.0
maven-plugin
Helm Maven Plugin
@@ -21,6 +21,7 @@
3.6.2
2.2.1
+ 2.14.2
4.5.14
1.4
@@ -28,7 +29,7 @@
3.24.2
1.7.20
- 3.10.1
+ 3.11.0
3.2.1
1.19.0
1.6.13
@@ -44,6 +45,13 @@
pom
import
+
+ com.fasterxml.jackson
+ jackson-bom
+ ${jackson-bom.version}
+ import
+ pom
+
@@ -95,6 +103,15 @@
${plexus-sec-dispatcher.version}
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-yaml
+
+
org.junit.jupiter
junit-jupiter
diff --git a/src/main/kotlin/com/deviceinsight/helm/PackageMojo.kt b/src/main/kotlin/com/deviceinsight/helm/PackageMojo.kt
index 87811dc..8d63167 100644
--- a/src/main/kotlin/com/deviceinsight/helm/PackageMojo.kt
+++ b/src/main/kotlin/com/deviceinsight/helm/PackageMojo.kt
@@ -17,6 +17,10 @@
package com.deviceinsight.helm
import com.deviceinsight.helm.util.ServerAuthentication
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
+import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import org.apache.maven.plugin.MojoExecutionException
import org.apache.maven.plugins.annotations.Component
import org.apache.maven.plugins.annotations.LifecyclePhase
@@ -25,6 +29,8 @@ import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.settings.Settings
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher
import java.io.File
+import java.io.IOException
+
/**
* Packages helm charts
@@ -70,6 +76,9 @@ class PackageMojo : ResolveHelmMojo(), ServerAuthentication {
@Parameter(defaultValue = "\${settings}", readonly = true)
override lateinit var settings: Settings
+ @Parameter(property = "extraValuesFiles")
+ private val extraValuesFiles: List = emptyList()
+
@Throws(MojoExecutionException::class)
override fun execute() {
@@ -98,6 +107,7 @@ class PackageMojo : ResolveHelmMojo(), ServerAuthentication {
log.info("Created target helm directory")
processHelmConfigFiles(targetHelmDir)
+ mergeValuesFiles(targetHelmDir, extraValuesFiles)
val helmAddFlags = if (isHelm2 || !forceAddRepos) emptyList() else listOf("--force-update")
@@ -183,6 +193,38 @@ class PackageMojo : ResolveHelmMojo(), ServerAuthentication {
}
}
+ private fun mergeValuesFiles(targetHelmDir: File, extraValuesFiles: List) {
+
+ if (extraValuesFiles.isEmpty()) {
+ return
+ }
+
+ val missingFiles = extraValuesFiles.filter { !File(it).exists() }
+ if (missingFiles.isNotEmpty()) {
+ throw IllegalStateException("extraValueFiles not found: $missingFiles")
+ }
+
+ val allValuesFiles = extraValuesFiles.toMutableList()
+ val valuesFile = targetHelmDir.resolve("values.yaml")
+
+ if (valuesFile.exists()) {
+ allValuesFiles.add(0, valuesFile.absolutePath)
+ }
+
+ val yamlMapper = ObjectMapper(YAMLFactory().enable(YAMLGenerator.Feature.MINIMIZE_QUOTES))
+ val values: ObjectNode = yamlMapper.createObjectNode()
+ val yamlReader = yamlMapper.setDefaultMergeable(true).readerForUpdating(values)
+
+ try {
+ for (file in allValuesFiles) {
+ yamlReader.readValue(File(file), ObjectNode::class.java)
+ }
+ yamlMapper.writeValue(valuesFile, values)
+ } catch (e: IOException) {
+ throw RuntimeException(e)
+ }
+ }
+
private fun findPropertyValue(property: String, fileName: String): CharSequence? {
val result = when (property) {
"project.version" -> project.version