From 251dad5a487fa5a2882fe1cbf43e087099b2e5d7 Mon Sep 17 00:00:00 2001 From: timdeluxe <5765175+timdeluxe@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:55:42 +0200 Subject: [PATCH] feat: Adding sops feature --- README.md | 13 +++++++++++++ feature/sops/feature.yaml | 6 ++++++ feature/sops/goss/.env | 1 + feature/sops/goss/goss.yaml | 6 ++++++ feature/sops/install.sh | 23 +++++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 feature/sops/feature.yaml create mode 100644 feature/sops/goss/.env create mode 100644 feature/sops/goss/goss.yaml create mode 100644 feature/sops/install.sh diff --git a/README.md b/README.md index 260d1d7..d9f4626 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Following features and tools are supported: * 📦 Packages * 📦 Packer * 👟 Run +* 🔑 sops * 📜 Stern * 🌏 Terraform * 🐗 Terragrunt @@ -64,6 +65,7 @@ Following features and tools are supported: * [Packages](#packages) * [Packer](#packer) * [Run](#run) + * [sops](#sops) * [Stern](#stern) * [Terraform](#terraform) * [Terragrunt](#terragrunt) @@ -540,6 +542,17 @@ Runs commands inside the shell when entering the cloud control container * DEBUG_run: Debug this feature * Environment RUN_COMMANDS: Valid shell commands to run +### sops + +Installs [sops](https://github.com/getsops/sops) + +#### Configuration + +* USE_sops: Enable this feature +* DEBUG_sops: Debug this feature +* Environment SOPS_VERSION (required): Valid sops version (e.g. 3.8.1) +* Environment specific for the key you use, see [sops documentation](https://github.com/getsops/sops?tab=readme-ov-file#22encrypting-using-age) + ### Stern Installs [stern](https://github.com/stern/stern), a multi pod and container log tailing for Kubernetes diff --git a/feature/sops/feature.yaml b/feature/sops/feature.yaml new file mode 100644 index 0000000..5fe5405 --- /dev/null +++ b/feature/sops/feature.yaml @@ -0,0 +1,6 @@ +icon: "🔑" +title: "sops" +description: "Installs [sops](https://github.com/getsops/sops)" +configuration: + - "Environment SOPS_VERSION (required): Valid sops version (e.g. 3.8.1)" + - "Environment specific for the key you use, see [sops documentation](https://github.com/getsops/sops?tab=readme-ov-file#22encrypting-using-age)" diff --git a/feature/sops/goss/.env b/feature/sops/goss/.env new file mode 100644 index 0000000..4a9e6df --- /dev/null +++ b/feature/sops/goss/.env @@ -0,0 +1 @@ +SOPS_VERSION=3.8.1 \ No newline at end of file diff --git a/feature/sops/goss/goss.yaml b/feature/sops/goss/goss.yaml new file mode 100644 index 0000000..6ecf167 --- /dev/null +++ b/feature/sops/goss/goss.yaml @@ -0,0 +1,6 @@ +command: + sops: + exec: "/home/cloudcontrol/bin/sops --version" + exit-status: 0 + stdout: + - "sops" diff --git a/feature/sops/install.sh b/feature/sops/install.sh new file mode 100644 index 0000000..471cc21 --- /dev/null +++ b/feature/sops/install.sh @@ -0,0 +1,23 @@ +. /feature-installer-utils.sh + +if [ -z "${SOPS_VERSION}" ] +then + echo "The sops feature requires a version set using SOPS_VERSION. See https://github.com/getsops/sops/releases/ for valid versions" + exit 1 +fi + +SOPS_VERSION=$(checkAndCleanVersion "${SOPS_VERSION}") + +TEMPDIR=$(mktemp -d) +cd "${TEMPDIR}" || exit + +execHandle "Downloading sops" curl -f -s -L "https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.$(getPlatform)" --output sops +execHandle "Installing sops" mv sops /home/cloudcontrol/bin +execHandle "Making sops executable" chmod +x /home/cloudcontrol/bin/sops + +cd - &>/dev/null || exit +rm -rf "${TEMPDIR}" + + + +