Skip to content

Commit

Permalink
🗺️ Add Helm and Helm Chart Testing (#59)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Woffenden <jacob.woffenden@digital.justice.gov.uk>
  • Loading branch information
Jacob Woffenden authored Apr 16, 2024
1 parent 8429479 commit a11567c
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 2 deletions.
6 changes: 6 additions & 0 deletions features/src/kubernetes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.5] - 2024-04-16

## Added

- Helm and Helm Chart Testing

## [0.0.4] - 2024-04-05

## Changed
Expand Down
14 changes: 12 additions & 2 deletions features/src/kubernetes/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"id": "kubernetes",
"version": "0.0.4",
"version": "0.0.5",
"name": "Kubernetes",
"description": "Installs the Kubernetes CLI",
"description": "Installs the Kubernetes CLI, Helm CLI and Helm Chart Testing CLI",
"options": {
"kubernetesCliVersion": {
"type": "string",
"description": "Version of the Kubernetes CLI to install",
"default": "latest"
},
"helmCliVersion": {
"type": "string",
"description": "Version of the Helm CLI to install",
"default": "latest"
},
"helmCtCliVersion": {
"type": "string",
"description": "Version of the Helm Chart Testing CLI to install",
"default": "latest"
}
},
"customizations": {
Expand Down
34 changes: 34 additions & 0 deletions features/src/kubernetes/install-helm-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -e

# shellcheck source=/dev/null
# file not accessible until being built
source /usr/local/bin/devcontainer-utils

get_system_architecture

GITHUB_REPOSITORY="helm/helm"
VERSION="${HELMCLIVERSION:-"latest"}"

if [[ "${VERSION}" == "latest" ]]; then
get_github_latest_tag "${GITHUB_REPOSITORY}"
VERSION="${GITHUB_LATEST_TAG}"
VERSION_STRIP_V="${GITHUB_LATEST_TAG_STRIP_V}"
else
# shellcheck disable=SC2034
VERSION_STRIP_V="${VERSION#v}"
fi

curl --fail-with-body --location "https://get.helm.sh/helm-${VERSION}-linux-${ARCHITECTURE}.tar.gz" \
--output "helm-${VERSION}-linux-${ARCHITECTURE}.tar.gz"

tar --extract --file "helm-${VERSION}-linux-${ARCHITECTURE}.tar.gz"

install --owner=vscode --group=vscode --mode=775 "linux-${ARCHITECTURE}/helm" /usr/local/bin/helm

install --directory --owner=vscode --group=vscode /home/vscode/.config/helm

install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.devcontainer/featurerc.d/helm.sh /home/vscode/.devcontainer/featurerc.d/helm.sh

rm --recursive --force "linux-${ARCHITECTURE}" "helm-${VERSION}-linux-${ARCHITECTURE}.tar.gz"
36 changes: 36 additions & 0 deletions features/src/kubernetes/install-helm-ct-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e

# shellcheck source=/dev/null
# file not accessible until being built
source /usr/local/bin/devcontainer-utils

get_system_architecture

GITHUB_REPOSITORY="helm/chart-testing"
VERSION="${HELMCTCLIVERSION:-"latest"}"

if [[ "${VERSION}" == "latest" ]]; then
get_github_latest_tag "${GITHUB_REPOSITORY}"
VERSION="${GITHUB_LATEST_TAG}"
VERSION_STRIP_V="${GITHUB_LATEST_TAG_STRIP_V}"
else
# shellcheck disable=SC2034
VERSION_STRIP_V="${VERSION#v}"
fi

curl --fail-with-body --location "https://github.com/helm/chart-testing/releases/download/${VERSION}/chart-testing_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.tar.gz" \
--output "chart-testing_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.tar.gz"

tar --extract --file "chart-testing_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.tar.gz"

install --owner=vscode --group=vscode --mode=775 ct /usr/local/bin/ct

install --directory --owner=vscode --group=vscode /home/vscode/.ct

install --owner=vscode --group=vscode --mode=644 etc/chart_schema.yaml /home/vscode/.ct/chart_schema.yaml

install --owner=vscode --group=vscode --mode=644 etc/lintconf.yaml /home/vscode/.ct/lintconf.yaml

rm --recursive --force ct LICENSE README.md etc/chart_schema.yaml etc/lintconf.yaml "chart-testing_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.tar.gz"
6 changes: 6 additions & 0 deletions features/src/kubernetes/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ source /usr/local/bin/devcontainer-utils

logger "info" "Installing Kubernetes CLI (version: ${KUBERNETESCLIVERSION})"
bash "$(dirname "${0}")"/install-kubernetes-cli.sh

logger "info" "Installing Helm CLI (version: ${HELMCLIVERSION})"
bash "$(dirname "${0}")"/install-helm-cli.sh

logger "info" "Installing Helm Chart Testing CLI (version: ${HELMCTCLIVERSION})"
bash "$(dirname "${0}")"/install-helm-ct-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# shellcheck disable=SC1090
source <(helm completion zsh)
5 changes: 5 additions & 0 deletions features/test/kubernetes/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ source dev-container-features-test-lib

check "kubectl version" kubectl version --client=true --output yaml
check "kubectl featurerc existence" stat /home/vscode/.devcontainer/featurerc.d/kubectl.sh
check "helm version" helm version
check "helm featurerc existence" stat /home/vscode/.devcontainer/featurerc.d/helm.sh
check "helm ct version" ct version
check "helm chart_schema.yaml existence" stat /home/vscode/.ct/chart_schema.yaml
check "helm lintconf.yaml existence" stat /home/vscode/.ct/lintconf.yaml

reportResults

0 comments on commit a11567c

Please sign in to comment.