Skip to content

Commit

Permalink
fix: helm module to action conversion: do not require version with na…
Browse files Browse the repository at this point in the history
…me (#4463)

* fix: helm module to action conversion: do not require version with name

* chore: yarn run generate-docs

* chore: add regression test for helm name+version requirement fix
  • Loading branch information
Walther committed May 30, 2023
1 parent b699c45 commit 947b911
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
3 changes: 1 addition & 2 deletions core/src/plugins/kubernetes/helm/config.ts
Expand Up @@ -153,7 +153,6 @@ const helmChartSpecSchema = () =>
url: joi.string().uri().description("An absolute URL to a packaged URL."),
version: helmChartVersionSchema(),
})
.with("name", ["version"])
.without("path", ["name", "repo", "version", "url"])
.without("url", ["name", "repo", "version", "path"])
.xor("name", "path", "url")
Expand All @@ -163,7 +162,7 @@ const helmChartSpecSchema = () =>
If the chart is defined in the same directory as the action, you can skip this, and the chart sources will be detected. If the chart is in the source tree but in a sub-directory, you should set \`chart.path\` to the directory path, relative to the action directory.
If the chart is remote, you must specify \`chart.name\` and \`chart.version\, and optionally \`chart.repo\` (if the chart is not in the default "stable" repo).
If the chart is remote, you can specify \`chart.name\` and \`chart.version\, and optionally \`chart.repo\` (if the chart is not in the default "stable" repo).
You may also specify an absolute URL to a packaged chart via \`chart.url\`.
Expand Down
@@ -0,0 +1,16 @@
kind: Project
apiVersion: garden.io/v0
name: repro
environments:
- name: default
providers:
- name: local-kubernetes

---
kind: Module
description: mailhog service
type: helm
name: mailhog
# version is not specified
repo: https://codecentric.github.io/helm-charts
chart: mailhog
21 changes: 19 additions & 2 deletions core/test/integ/src/plugins/kubernetes/helm/config.ts
Expand Up @@ -10,15 +10,20 @@ import { resolve } from "path"
import { expect } from "chai"
import { cloneDeep, omit } from "lodash"

import { expectError, TestGarden } from "../../../../../helpers"
import { expectError, getDataDir, makeTestGarden, TestGarden, withDefaultGlobalOpts } from "../../../../../helpers"
import { PluginContext } from "../../../../../../src/plugin-context"
import { dedent } from "../../../../../../src/util/string"
import { ModuleConfig } from "../../../../../../src/config/module"
import { apply } from "json-merge-patch"
import { getHelmTestGarden } from "./common"
import { defaultHelmTimeout } from "../../../../../../src/plugins/kubernetes/helm/module-config"
import stripAnsi = require("strip-ansi")
import { DEFAULT_BUILD_TIMEOUT_SEC, DEFAULT_DEPLOY_TIMEOUT_SEC, GardenApiVersion } from "../../../../../../src/constants"
import {
DEFAULT_BUILD_TIMEOUT_SEC,
DEFAULT_DEPLOY_TIMEOUT_SEC,
GardenApiVersion,
} from "../../../../../../src/constants"
import { ValidateCommand } from "../../../../../../src/commands/validate"

describe("configureHelmModule", () => {
let garden: TestGarden
Expand Down Expand Up @@ -220,4 +225,16 @@ describe("configureHelmModule", () => {
`)
)
})

it("should pass validation with a chart name but no version specified", async () => {
const projectRoot = getDataDir("test-projects", "helm-name-version-regression")
const g = await makeTestGarden(projectRoot)
const command = new ValidateCommand()
await command.action({
garden: g,
log: g.log,
args: {},
opts: withDefaultGlobalOpts({}),
})
})
})
4 changes: 2 additions & 2 deletions docs/reference/action-types/Deploy/helm.md
Expand Up @@ -208,7 +208,7 @@ spec:
# detected. If the chart is in the source tree but in a sub-directory, you should set `chart.path` to the directory
# path, relative to the action directory.
#
# If the chart is remote, you must specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the
# If the chart is remote, you can specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the
# chart is not in the default "stable" repo).
#
# You may also specify an absolute URL to a packaged chart via `chart.url`.
Expand Down Expand Up @@ -804,7 +804,7 @@ Specify the Helm chart to use.

If the chart is defined in the same directory as the action, you can skip this, and the chart sources will be detected. If the chart is in the source tree but in a sub-directory, you should set `chart.path` to the directory path, relative to the action directory.

If the chart is remote, you must specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the chart is not in the default "stable" repo).
If the chart is remote, you can specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the chart is not in the default "stable" repo).

You may also specify an absolute URL to a packaged chart via `chart.url`.

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/action-types/Run/helm-pod.md
Expand Up @@ -192,7 +192,7 @@ spec:
# detected. If the chart is in the source tree but in a sub-directory, you should set `chart.path` to the directory
# path, relative to the action directory.
#
# If the chart is remote, you must specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the
# If the chart is remote, you can specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the
# chart is not in the default "stable" repo).
#
# You may also specify an absolute URL to a packaged chart via `chart.url`.
Expand Down Expand Up @@ -658,7 +658,7 @@ Specify the Helm chart to use.

If the chart is defined in the same directory as the action, you can skip this, and the chart sources will be detected. If the chart is in the source tree but in a sub-directory, you should set `chart.path` to the directory path, relative to the action directory.

If the chart is remote, you must specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the chart is not in the default "stable" repo).
If the chart is remote, you can specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the chart is not in the default "stable" repo).

You may also specify an absolute URL to a packaged chart via `chart.url`.

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/action-types/Test/helm-pod.md
Expand Up @@ -192,7 +192,7 @@ spec:
# detected. If the chart is in the source tree but in a sub-directory, you should set `chart.path` to the directory
# path, relative to the action directory.
#
# If the chart is remote, you must specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the
# If the chart is remote, you can specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the
# chart is not in the default "stable" repo).
#
# You may also specify an absolute URL to a packaged chart via `chart.url`.
Expand Down Expand Up @@ -658,7 +658,7 @@ Specify the Helm chart to use.

If the chart is defined in the same directory as the action, you can skip this, and the chart sources will be detected. If the chart is in the source tree but in a sub-directory, you should set `chart.path` to the directory path, relative to the action directory.

If the chart is remote, you must specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the chart is not in the default "stable" repo).
If the chart is remote, you can specify `chart.name` and `chart.version\, and optionally `chart.repo` (if the chart is not in the default "stable" repo).

You may also specify an absolute URL to a packaged chart via `chart.url`.

Expand Down

0 comments on commit 947b911

Please sign in to comment.