Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terraform-backend-git feature #10

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
matrix:
features:
- infisical-cli
- terraform-backend-git
baseImage:
- alpine:latest
- debian:latest
Expand All @@ -24,6 +25,13 @@ jobs:
- mcr.microsoft.com/devcontainers/base:alpine
- mcr.microsoft.com/devcontainers/base:debian
- mcr.microsoft.com/devcontainers/base:ubuntu
exclude:
- features: terraform-backend-git
baseImage: alpine:latest
- features: terraform-backend-git
baseImage: fedora:latest
- features: terraform-backend-git
baseImage: mcr.microsoft.com/devcontainers/base:alpine

steps:
- name: Checkout
Expand All @@ -43,6 +51,7 @@ jobs:
matrix:
features:
- infisical-cli
- terraform-backend-git

steps:
- name: Checkout
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This repository contains a _collection_ of dev container Features.
Please take a closer look at the detailed instructions for the individual features:

- [Infisical CLI](src/infisical-cli)
- [Terraform State management using Git](src/terraform-backend-git)

## Repo and Feature Structure

Expand All @@ -19,6 +20,9 @@ Each Feature has its own sub-folder, containing at least a `devcontainer-feature
│ ├── infisical-cli
│ │ ├── devcontainer-feature.json
│ │ └── install.sh
│ ├── terraform-backend-git
│ │ ├── devcontainer-feature.json
│ │ └── install.sh
| ├── ...
│ │ ├── devcontainer-feature.json
│ │ └── install.sh
Expand All @@ -29,6 +33,9 @@ Each Feature has its own sub-folder, containing at least a `devcontainer-feature
│ ├── infisical-cli
│ │ ├── scenarios.json
│ │ └── test.sh
│ ├── terraform-backend-git
│ │ ├── scenarios.json
│ │ └── test.sh
| ├── ...
│ │ └── test.sh
...
Expand Down
20 changes: 20 additions & 0 deletions src/terraform-backend-git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Terraform State management using Git (terraform-backend-git)

Installs terraform-backend-git binary.

## Example Usage

```json
"features": {
"ghcr.io/skriptfabrik/devcontainer-features/terraform-backend-git:1": {}
}
```





---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/skriptfabrik/devcontainer-features/blob/main/src/terraform-backend-git/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
10 changes: 10 additions & 0 deletions src/terraform-backend-git/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "terraform-backend-git",
"version": "1.0.0",
"name": "Terraform State management using Git",
"documentationURL": "https://github.com/skriptfabrik/devcontainer-features/tree/main/src/terraform-backend-git",
"description": "Installs terraform-backend-git binary.",
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
54 changes: 54 additions & 0 deletions src/terraform-backend-git/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

set -e

ADJUSTED_VERSION="${VERSION:-"latest"}"

# Debian / Ubuntu packages
install_debian_packages() {
# Install prerequisites
apt-get -y update
apt-get -y install --no-install-recommends curl ca-certificates

# Clean up
apt-get -y clean
rm -rf /var/lib/apt/lists/*
}

# Bring in ID, ID_LIKE, VERSION_ID, VERSION_CODENAME
. /etc/os-release

# Get an adjusted ID independent of distro variants
if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then
ADJUSTED_ID="debian"
else
echo "Linux distro ${ID} not supported."
exit 1
fi

# Install packages for appropriate OS
case "${ADJUSTED_ID}" in
"debian")
install_debian_packages
;;
esac

# Fetch latest version if needed
if [ "${ADJUSTED_VERSION}" = "latest" ]; then
ADJUSTED_VERSION=$(curl -s https://api.github.com/repos/plumber-cd/terraform-backend-git/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
fi

# Detect current machine architecture
if [ "$(uname -m)" = "aarch64" ]; then
ARCH="arm64"
else
ARCH="amd64"
fi

# Download URL
DOWNLOAD_URL="https://github.com/plumber-cd/terraform-backend-git/releases/download/v${ADJUSTED_VERSION}/terraform-backend-git-linux-${ARCH}"

# Download and install terraform-backend-git
echo "Downloading terraform-backend-git from ${DOWNLOAD_URL}"
curl -sSLo /usr/local/bin/terraform-backend-git "${DOWNLOAD_URL}"
chmod +x /usr/local/bin/terraform-backend-git
1 change: 1 addition & 0 deletions test/_global/all_the_clis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ source dev-container-features-test-lib
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "check for infisical" infisical --version
check "check for terraform-backend-git" terraform-backend-git version

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
Expand Down
3 changes: 2 additions & 1 deletion test/_global/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"all_the_clis": {
"image": "ubuntu:latest",
"features": {
"infisical-cli": {}
"infisical-cli": {},
"terraform-backend-git": {}
}
}
}
21 changes: 21 additions & 0 deletions test/terraform-backend-git/debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Definition specific tests
. /etc/os-release

# Scenario-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "distro" test "${ID}" = "debian"
check "check for terraform-backend-git" terraform-backend-git version

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
14 changes: 14 additions & 0 deletions test/terraform-backend-git/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"debian": {
"image": "debian:latest",
"features": {
"terraform-backend-git": {}
}
},
"ubuntu": {
"image": "ubuntu:latest",
"features": {
"terraform-backend-git": {}
}
}
}
17 changes: 17 additions & 0 deletions test/terraform-backend-git/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "check for terraform-backend-git" terraform-backend-git version

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
21 changes: 21 additions & 0 deletions test/terraform-backend-git/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Definition specific tests
. /etc/os-release

# Scenario-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "distro" test "${ID}" = "ubuntu"
check "check for terraform-backend-git" terraform-backend-git version

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
Loading