From ffb723daf59473d205af4b0fb49cfa4419d0f68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Pl=C3=B6ger?= Date: Tue, 2 Sep 2025 13:08:12 +0200 Subject: [PATCH 1/4] feat: New feature: OpenTofu --- .vscode/launch.json | 32 +++++++++++++++++++ feature/opentofu/feature.yaml | 15 +++++++++ feature/opentofu/goss.unsetversion/.will-fail | 1 + feature/opentofu/goss/.env | 2 ++ feature/opentofu/goss/goss.yaml | 6 ++++ feature/opentofu/install.sh | 19 +++++++++++ 6 files changed, 75 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 feature/opentofu/feature.yaml create mode 100644 feature/opentofu/goss.unsetversion/.will-fail create mode 100644 feature/opentofu/goss/.env create mode 100644 feature/opentofu/goss/goss.yaml create mode 100755 feature/opentofu/install.sh diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a973637 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,32 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Run Tests", + "type": "go", + "request": "launch", + "mode": "auto", + "cwd": "/Users/dennisploger/Documents/code/dodevops/cloudcontrol", + "program": "cmd/tests/test-features.go", + "args": [ + "-f", + "simple", + "-i", + "ghcr.io/dodevops/cloudcontrol-simple:local", + "-t", + "/Users/dennisploger/work/testbed", + "-p", + "linux/arm64", + "-l", + "debug", + "-g", + "/Users/dennisploger/Downloads/goss-linux-arm64", + "-n", + "opentofu" + ] + } + ] +} \ No newline at end of file diff --git a/feature/opentofu/feature.yaml b/feature/opentofu/feature.yaml new file mode 100644 index 0000000..134a921 --- /dev/null +++ b/feature/opentofu/feature.yaml @@ -0,0 +1,15 @@ +icon: "📦" +title: "Opentofu" +description: "Installs and configures [Opentofu](https://opentofu.org/)" +configuration: + - | + Add a volume mount to the `volumes:` section of docker compose like this: + (...) + volumes: + - ":/opentofu" + - | + If you used the browser based login in gcloud, you'll probably need to authenticate using the application-default + login using the gcloud cli by running + + gcloud auth application-default login +requiresVersion: true diff --git a/feature/opentofu/goss.unsetversion/.will-fail b/feature/opentofu/goss.unsetversion/.will-fail new file mode 100644 index 0000000..b9a034c --- /dev/null +++ b/feature/opentofu/goss.unsetversion/.will-fail @@ -0,0 +1 @@ +The opentofu feature requires a version set using OPENTOFU_VERSION. diff --git a/feature/opentofu/goss/.env b/feature/opentofu/goss/.env new file mode 100644 index 0000000..f2c9589 --- /dev/null +++ b/feature/opentofu/goss/.env @@ -0,0 +1,2 @@ +OPENTOFU_VERSION=1.10.5 +DEBUG_opentofu=true \ No newline at end of file diff --git a/feature/opentofu/goss/goss.yaml b/feature/opentofu/goss/goss.yaml new file mode 100644 index 0000000..f5912ff --- /dev/null +++ b/feature/opentofu/goss/goss.yaml @@ -0,0 +1,6 @@ +command: + terraform: + exec: "/home/cloudcontrol/bin/tofu --version" + exit-status: 0 + stdout: + - "OpenTofu v1.10.5" diff --git a/feature/opentofu/install.sh b/feature/opentofu/install.sh new file mode 100755 index 0000000..7f030b0 --- /dev/null +++ b/feature/opentofu/install.sh @@ -0,0 +1,19 @@ +. /feature-installer-utils.sh + +if [ -z "${OPENTOFU_VERSION}" ] +then + echo "The opentofu feature requires a version set using OPENTOFU_VERSION. See https://github.com/opentofu/opentofu/releases for valid versions" + exit 1 +fi + +OPENTOFU_VERSION=$(checkAndCleanVersion "${OPENTOFU_VERSION}") + +TEMPDIR=$(mktemp -d) +cd "${TEMPDIR}" || exit + +execHandle "Downloading opentofu" curl -f -s -L "https://github.com/opentofu/opentofu/releases/download/v${OPENTOFU_VERSION}/tofu_${OPENTOFU_VERSION}_linux_$(getPlatform).zip" --output opentofu.zip +execHandle "Unpacking opentofu" unzip opentofu.zip +execHandle "Installing opentofu" mv tofu /home/cloudcontrol/bin/tofu + +cd - &>/dev/null || exit +rm -rf "${TEMPDIR}" From f6afe98bb387fda9414ccd249713110d593036ba Mon Sep 17 00:00:00 2001 From: DO! DevOps bot Date: Tue, 2 Sep 2025 11:09:41 +0000 Subject: [PATCH 2/4] docs: Automatic docs update --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index fb79f69..90fb70a 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ See [https://github.com/dodevops/kc](the kc website) for details. * 🟦 krew * 🐚 Kubectlnodeshell * 🐳 Kubernetes +* 📦 Opentofu * 📦 Packages * 📦 Packer * 👟 Run @@ -83,6 +84,7 @@ See [https://github.com/dodevops/kc](the kc website) for details. * [krew](#krew) * [Kubectlnodeshell](#kubectlnodeshell) * [Kubernetes](#kubernetes) + * [Opentofu](#opentofu) * [Packages](#packages) * [Packer](#packer) * [Run](#run) @@ -578,6 +580,24 @@ Installs and configures [kubernetes](https://kubernetes.io/docs/reference/kubect * Environment GCLOUD_K8S_CLUSTERS: A comma separated list of zone[@project]:cluster-name * Environment K8S_USE_GCLOUD_AUTH: Whether to use the new GKE_GCLOUD_AUTH plugin [true] +### Opentofu + +Installs and configures [Opentofu](https://opentofu.org/) + +#### Configuration + +* USE_opentofu: Enable this feature (or use the FEATURES variable instead) +* OPENTOFU_VERSION (required): Version to install (or use the FEATURES variable instead) +* DEBUG_opentofu: Debug this feature +* Add a volume mount to the `volumes:` section of docker compose like this: + (...) + volumes: + - ":/opentofu" +* If you used the browser based login in gcloud, you'll probably need to authenticate using the application-default + login using the gcloud cli by running + + gcloud auth application-default login + ### Packages Installs additional packages into the container From cd27987425fadf0b3922d30c6c61788d1915fde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Pl=C3=B6ger?= Date: Tue, 2 Sep 2025 13:08:47 +0200 Subject: [PATCH 3/4] fix: Ignore missing Dockerfile I found this problem on a clean clone of CloudControl when no Dockerfile was created before. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 53b513d..97cf0e9 100644 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ set -euo pipefail # # If no flavour is specified, all flavours will be built -mv Dockerfile Dockerfile.sav +mv Dockerfile Dockerfile.sav &>/dev/null || true TAG=latest if [ -n "$1" ] From 63a13065f7e6fca15d6eeaef7412bb854aaefacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Pl=C3=B6ger?= Date: Tue, 2 Sep 2025 13:28:15 +0200 Subject: [PATCH 4/4] fix(unrelated): Fixed AWS already including curl in the latest version --- .vscode/launch.json | 32 -------------------------------- flavour/aws/Dockerfile.flavour | 2 +- 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a973637..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Run Tests", - "type": "go", - "request": "launch", - "mode": "auto", - "cwd": "/Users/dennisploger/Documents/code/dodevops/cloudcontrol", - "program": "cmd/tests/test-features.go", - "args": [ - "-f", - "simple", - "-i", - "ghcr.io/dodevops/cloudcontrol-simple:local", - "-t", - "/Users/dennisploger/work/testbed", - "-p", - "linux/arm64", - "-l", - "debug", - "-g", - "/Users/dennisploger/Downloads/goss-linux-arm64", - "-n", - "opentofu" - ] - } - ] -} \ No newline at end of file diff --git a/flavour/aws/Dockerfile.flavour b/flavour/aws/Dockerfile.flavour index 7bfcdf3..2dd1621 100644 --- a/flavour/aws/Dockerfile.flavour +++ b/flavour/aws/Dockerfile.flavour @@ -1,6 +1,6 @@ FROM amazon/aws-cli:latest -RUN yum install -y sudo shadow-utils unzip tar net-tools curl && \ +RUN yum install -y sudo shadow-utils unzip tar net-tools && \ echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/yum *" > /etc/sudoers.d/cloudcontrol && \ echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/curl *" >> /etc/sudoers.d/cloudcontrol && \ echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/mv *" >> /etc/sudoers.d/cloudcontrol && \