Skip to content

Commit 2b79bbd

Browse files
author
Jacob Woffenden
committed
Add Kubernetes and Terraform features
Signed-off-by: Jacob Woffenden <jacob.woffenden@digital.justice.gov.uk>
1 parent fa57952 commit 2b79bbd

File tree

11 files changed

+128
-0
lines changed

11 files changed

+128
-0
lines changed

features/src/aws/NOTES.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"id": "kubernetes",
3+
"version": "1.0.0",
4+
"name": "Kubernetes",
5+
"description": "Installs the Kubernetes CLI",
6+
"options": {
7+
"kubernetesCliVersion": {
8+
"type": "string",
9+
"description": "Version of the Kubernetes CLI to install",
10+
"default": "latest"
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source /usr/local/bin/devcontainer-utils
6+
7+
get_system_architecture
8+
9+
GITHUB_REPOSITORY="ministryofjustice/cloud-platform-cli"
10+
VERSION=${KUBERNETESCLIVERSION:-"latest"}
11+
12+
if [[ "${VERSION}" == "latest" ]]; then
13+
VERSION=$( curl --location --silent https://dl.k8s.io/release/stable.txt )
14+
VERSION_STRIP_V="${VERSION#v}"
15+
else
16+
VERSION_STRIP_V="${VERSION#v}"
17+
fi
18+
19+
curl --fail-with-body --location "https://dl.k8s.io/release/${VERSION}/bin/linux/${ARCHITECTURE}/kubectl" \
20+
--output "kubectl"
21+
22+
install --owner=vscode --group=vscode --mode=775 kubectl /usr/local/bin/kubectl
23+
24+
install --directory --owner=vscode --group=vscode /home/vscode/.kube
25+
26+
install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.devcontainer/featurerc.d/kubectl.sh /home/vscode/.devcontainer/featurerc.d/kubectl.sh

features/src/kubernetes/install.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck source=/dev/null
4+
# file not accessible until being built
5+
source /usr/local/bin/devcontainer-utils
6+
7+
logger "info" "Installing Kubernetes CLI (version: ${KUBERNETESCLIVERSION})"
8+
bash "$(dirname "${0}")"/install-kubernetes-cli.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
source <(kubectl completion zsh)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"id": "terraform",
3+
"version": "1.0.0",
4+
"name": "Terraform",
5+
"description": "Installs the Terraform CLI",
6+
"options": {
7+
"terraformCliVersion": {
8+
"type": "string",
9+
"description": "Version of the Terraform CLI to install",
10+
"default": "latest"
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# shellcheck source=/dev/null
6+
# file not accessible until being built
7+
source /usr/local/bin/devcontainer-utils
8+
9+
get_system_architecture
10+
11+
GITHUB_REPOSITORY="hashicorp/terraform"
12+
VERSION="${TERRAFORMCLIVERSION:-"latest"}"
13+
14+
if [[ "${VERSION}" == "latest" ]]; then
15+
get_github_latest_tag "${GITHUB_REPOSITORY}"
16+
VERSION="${GITHUB_LATEST_TAG}"
17+
VERSION_STRIP_V="${GITHUB_LATEST_TAG_STRIP_V}"
18+
else
19+
# shellcheck disable=SC2034
20+
VERSION_STRIP_V="${VERSION#v}"
21+
fi
22+
23+
curl --fail-with-body --location "https://releases.hashicorp.com/terraform/${VERSION_STRIP_V}/terraform_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip" \
24+
--output "terraform_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip"
25+
26+
unzip "terraform_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip"
27+
28+
install --owner=vscode --group=vscode --mode=775 terraform /usr/local/bin/terraform
29+
30+
rm --recursive --force terraform "terraform_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip"
31+
32+
install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.devcontainer/featurerc.d/terraform.sh /home/vscode/.devcontainer/featurerc.d/terraform.sh

features/src/terraform/install.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck source=/dev/null
4+
# file not accessible until being built
5+
source /usr/local/bin/devcontainer-utils
6+
7+
logger "info" "Installing Terraform CLI (version: ${TERRAFORMCLIVERSION})"
8+
bash "$(dirname "${0}")"/install-terraform-cli.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
complete -o nospace -C /usr/local/bin/terraform terraform

features/test/kubernetes/test.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "kubectl version" kubectl version --client=true --output yaml
8+
check "kubectl featurerc existence" stat /home/vscode/.devcontainer/featurerc.d/kubectl.sh
9+
10+
reportResults

features/test/terraform/test.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# shellcheck source=/dev/null
6+
# file only accessible when using devcontainer CLI
7+
source dev-container-features-test-lib
8+
9+
check "terraform version" terraform version
10+
check "terraform featurerc existence" stat /home/vscode/.devcontainer/featurerc.d/terraform.sh
11+
12+
reportResults

0 commit comments

Comments
 (0)