Skip to content

Commit 8f6a0a5

Browse files
authored
Merge branch 'main' into feature/pre-commit-hook_support_1138
2 parents b5f8045 + 5409304 commit 8f6a0a5

11 files changed

Lines changed: 185 additions & 8 deletions

src/kubectl-helm-minikube/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "kubectl-helm-minikube",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"name": "Kubectl, Helm, and Minikube",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube",
66
"description": "Installs latest version of kubectl, Helm, and optionally minikube. Auto-detects latest versions and installs needed dependencies.",

src/kubectl-helm-minikube/install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ fi
5454
find_version_from_git_tags() {
5555
local variable_name=$1
5656
local requested_version=${!variable_name}
57+
requested_version="${requested_version#v}"
5758
if [ "${requested_version}" = "none" ]; then return; fi
5859
local repository=$2
5960
local prefix=${3:-"tags/v"}
6061
local separator=${4:-"."}
61-
local last_part_optional=${5:-"false"}
62+
local last_part_optional=${5:-"false"}
6263
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
6364
local escaped_separator=${separator//./\\.}
6465
local last_part

src/terraform/NOTES.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@
44

55
On August 10, 2023, HashiCorp announced a change of license for its products, including Terraform. After ~9 years of Terraform being open source under the MPL v2 license, it was to move under a non-open source BSL v1.1 license, starting from the next (1.6) version. See https://github.com/hashicorp/terraform/blob/main/LICENSE
66

7+
## Custom Download Server
8+
9+
The `customDownloadServer` option allows you to specify an alternative server for downloading Terraform and Sentinel packages. This is useful for organizations that maintain internal mirrors or have proxies for HashiCorp downloads.
10+
11+
When using this option:
12+
- Provide the complete URL including protocol (e.g., `https://my-mirror.example.com`)
13+
- The server should mirror the HashiCorp releases structure
14+
15+
Example:
16+
```json
17+
"features": {
18+
"ghcr.io/devcontainers/features/terraform:1": {
19+
"customDownloadServer": "https://my-mirror.example.com"
20+
}
21+
}
22+
```
23+
24+
### ⚠️ Security Considerations
25+
26+
When using a custom download server, be aware of the following security implications:
27+
28+
- **Server Verification**: Always verify that the custom server is trustworthy and maintained by your organization or a trusted entity. Using an untrusted or compromised server could lead to downloading malicious software.
29+
30+
- **Supply Chain Risks**: Malicious actors may attempt to distribute compromised versions of Terraform that contain backdoors, cryptominers, or other harmful code.
31+
32+
- **Integrity Checks**: The feature performs SHA256 checks when available, but these are only as trustworthy as the source of the checksums. If both the binaries and checksums come from a compromised server, the integrity check may pass despite the software being malicious.
33+
34+
- **Organizational Policy**: Ensure your custom download server adheres to your organization's security policies and implements proper access controls.
35+
36+
Always use the official HashiCorp download server (https://releases.hashicorp.com) unless you have a specific need for an alternative source.
37+
738
## OS Support
839

940
This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed.

src/terraform/devcontainer-feature.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "terraform",
3-
"version": "1.3.10",
3+
"version": "1.4.0",
44
"name": "Terraform, tflint, and TFGrunt",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/terraform",
66
"description": "Installs the Terraform CLI and optionally TFLint and Terragrunt. Auto-detects latest version and installs needed dependencies.",
@@ -54,6 +54,11 @@
5454
"type": "string",
5555
"default": "",
5656
"description": "Connect to a keyserver using a proxy by configuring this option"
57+
},
58+
"customDownloadServer": {
59+
"type": "string",
60+
"default": "",
61+
"description": "Custom server URL for downloading Terraform and Sentinel packages, including protocol (e.g., https://releases.hashicorp.com). If not provided, the default HashiCorp download server (https://releases.hashicorp.com) will be used."
5762
}
5863
},
5964
"customizations": {

src/terraform/install.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ TERRAGRUNT_VERSION="${TERRAGRUNT:-"latest"}"
1818
INSTALL_SENTINEL=${INSTALLSENTINEL:-false}
1919
INSTALL_TFSEC=${INSTALLTFSEC:-false}
2020
INSTALL_TERRAFORM_DOCS=${INSTALLTERRAFORMDOCS:-false}
21+
CUSTOM_DOWNLOAD_SERVER="${CUSTOMDOWNLOADSERVER:-""}"
2122

2223
TERRAFORM_SHA256="${TERRAFORM_SHA256:-"automatic"}"
2324
TFLINT_SHA256="${TFLINT_SHA256:-"automatic"}"
@@ -26,6 +27,11 @@ SENTINEL_SHA256="${SENTINEL_SHA256:-"automatic"}"
2627
TFSEC_SHA256="${TFSEC_SHA256:-"automatic"}"
2728
TERRAFORM_DOCS_SHA256="${TERRAFORM_DOCS_SHA256:-"automatic"}"
2829

30+
HASHICORP_RELEASES_URL="https://releases.hashicorp.com"
31+
if [ -n "${CUSTOM_DOWNLOAD_SERVER}" ]; then
32+
HASHICORP_RELEASES_URL="${CUSTOM_DOWNLOAD_SERVER}"
33+
fi
34+
2935
TERRAFORM_GPG_KEY="72D7468F"
3036
TFLINT_GPG_KEY_URI="https://raw.githubusercontent.com/terraform-linters/tflint/v0.46.1/8CE69160EB3F2FE9.key"
3137
KEYSERVER_PROXY="${HTTPPROXY:-"${HTTP_PROXY:-""}"}"
@@ -357,7 +363,7 @@ find_version_from_git_tags TERRAGRUNT_VERSION "$terragrunt_url"
357363
install_terraform() {
358364
local TERRAFORM_VERSION=$1
359365
terraform_filename="terraform_${TERRAFORM_VERSION}_linux_${architecture}.zip"
360-
curl -sSL -o ${terraform_filename} "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${terraform_filename}"
366+
curl -sSL -o ${terraform_filename} "${HASHICORP_RELEASES_URL}/terraform/${TERRAFORM_VERSION}/${terraform_filename}"
361367
}
362368

363369
mkdir -p /tmp/tf-downloads
@@ -373,8 +379,8 @@ fi
373379
if [ "${TERRAFORM_SHA256}" != "dev-mode" ]; then
374380
if [ "${TERRAFORM_SHA256}" = "automatic" ]; then
375381
receive_gpg_keys TERRAFORM_GPG_KEY
376-
curl -sSL -o terraform_SHA256SUMS https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS
377-
curl -sSL -o terraform_SHA256SUMS.sig https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS.${TERRAFORM_GPG_KEY}.sig
382+
curl -sSL -o terraform_SHA256SUMS "${HASHICORP_RELEASES_URL}/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS"
383+
curl -sSL -o terraform_SHA256SUMS.sig "${HASHICORP_RELEASES_URL}/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS.${TERRAFORM_GPG_KEY}.sig"
378384
gpg --verify terraform_SHA256SUMS.sig terraform_SHA256SUMS
379385
else
380386
echo "${TERRAFORM_SHA256} *${terraform_filename}" > terraform_SHA256SUMS
@@ -464,7 +470,7 @@ fi
464470

465471
if [ "${INSTALL_SENTINEL}" = "true" ]; then
466472
SENTINEL_VERSION="latest"
467-
sentinel_releases_url='https://releases.hashicorp.com/sentinel'
473+
sentinel_releases_url="${HASHICORP_RELEASES_URL}/sentinel"
468474
find_sentinel_version_from_url SENTINEL_VERSION ${sentinel_releases_url}
469475
sentinel_filename="sentinel_${SENTINEL_VERSION}_linux_${architecture}.zip"
470476
echo "(*) Downloading Sentinel... ${sentinel_filename}"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library
5+
source dev-container-features-test-lib
6+
7+
# Define expected versions
8+
KUBECTL_EXPECTED_VERSION="v1.33.0"
9+
HELM_VERSION="v3.17.3"
10+
MINIKUBE_VERSION="v1.31.1"
11+
12+
set +e
13+
kubectl version --client --output json | jq -r '.clientVersion.gitVersion' | grep "${KUBECTL_VERSION}"
14+
exit_code=$?
15+
check "kubectl-version-${KUBECTL_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
16+
echo "kubectl version:"
17+
kubectl version --client
18+
19+
helm version --short | grep "${HELM_VERSION}"
20+
exit_code=$?
21+
check "helm-version-${HELM_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
22+
echo "helm version:"
23+
helm version --short
24+
25+
minikube version --short | grep "${MINIKUBE_VERSION}"
26+
exit_code=$?
27+
check "minikube-version-${MINIKUBE_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
28+
echo "minikube version:"
29+
minikube version --short
30+
set -e
31+
32+
# Report result
33+
reportResults
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library
5+
source dev-container-features-test-lib
6+
7+
# Define expected versions
8+
KUBECTL_EXPECTED_VERSION="1.30"
9+
HELM_VERSION="3.16"
10+
MINIKUBE_VERSION="1.28"
11+
12+
set +e
13+
kubectl version --client --output json | jq -r '.clientVersion.gitVersion' | grep "${KUBECTL_VERSION}"
14+
exit_code=$?
15+
check "kubectl-version-${KUBECTL_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
16+
echo "kubectl version:"
17+
kubectl version --client
18+
19+
helm version --short | grep "${HELM_VERSION}"
20+
exit_code=$?
21+
check "helm-version-${HELM_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
22+
echo "helm version:"
23+
helm version --short
24+
25+
minikube version --short | grep "${MINIKUBE_VERSION}"
26+
exit_code=$?
27+
check "minikube-version-${MINIKUBE_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
28+
echo "minikube version:"
29+
minikube version --short
30+
set -e
31+
32+
# Report result
33+
reportResults

test/kubectl-helm-minikube/scenarios.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,25 @@
1818
"minikube": "none"
1919
}
2020
}
21+
},
22+
"install_kubectl_without_version": {
23+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
24+
"features": {
25+
"kubectl-helm-minikube": {
26+
"version": "1.30",
27+
"helm": "3.16",
28+
"minikube": "1.28"
29+
}
30+
}
31+
},
32+
"install_kubectl_with_version": {
33+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
34+
"features": {
35+
"kubectl-helm-minikube": {
36+
"version": "v1.33.0",
37+
"helm": "v3.17.3",
38+
"minikube": "v1.31.1"
39+
}
40+
}
2141
}
22-
}
42+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Import test library
6+
source dev-container-features-test-lib
7+
8+
# Check if terraform was installed correctly and it's the expected version
9+
check "terraform installed" terraform --version
10+
check "terraform version matches" terraform --version | grep "1.6.5"
11+
12+
# Report results
13+
reportResults
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Import test library
6+
source dev-container-features-test-lib
7+
8+
# Check if terraform was installed correctly and it's the expected version
9+
check "terraform installed" terraform --version
10+
check "terraform version matches" terraform --version | grep "1.6.5"
11+
12+
# Check if sentinel was installed correctly
13+
check "sentinel installed" sentinel --version
14+
15+
# Report results
16+
reportResults

0 commit comments

Comments
 (0)