From aed29d514457b906a3ce57baa42c1be9745765d9 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Thu, 19 Dec 2024 10:02:01 -0500 Subject: [PATCH] refac(back): #1378 deprecate builtins - Deprecate makeEnvVars - Deprecate makeEnvVarsForTerraform - Deprecate makeSecretForEnvFromSops - Deprecate makeSecretForTerraformFromEnv Signed-off-by: Daniel Salazar --- src/args/agnostic.nix | 7 ----- .../make-env-vars-for-terraform/default.nix | 10 ------- .../make-env-vars-for-terraform/template.sh | 14 --------- src/args/make-env-vars/default.nix | 10 ------- src/args/make-env-vars/template.sh | 14 --------- .../make-secret-for-env-from-sops/default.nix | 12 -------- .../make-secret-for-env-from-sops/template.sh | 15 ---------- .../default.nix | 10 ------- .../template.sh | 15 ---------- src/evaluator/modules/default.nix | 4 --- .../env-vars-for-terraform/default.nix | 22 -------------- src/evaluator/modules/env-vars/default.nix | 19 ------------ .../secrets-for-env-from-sops/default.nix | 30 ------------------- .../default.nix | 22 -------------- 14 files changed, 204 deletions(-) delete mode 100644 src/args/make-env-vars-for-terraform/default.nix delete mode 100644 src/args/make-env-vars-for-terraform/template.sh delete mode 100644 src/args/make-env-vars/default.nix delete mode 100644 src/args/make-env-vars/template.sh delete mode 100644 src/args/make-secret-for-env-from-sops/default.nix delete mode 100644 src/args/make-secret-for-env-from-sops/template.sh delete mode 100644 src/args/make-secret-for-terraform-from-env/default.nix delete mode 100644 src/args/make-secret-for-terraform-from-env/template.sh delete mode 100644 src/evaluator/modules/env-vars-for-terraform/default.nix delete mode 100644 src/evaluator/modules/env-vars/default.nix delete mode 100644 src/evaluator/modules/secrets-for-env-from-sops/default.nix delete mode 100644 src/evaluator/modules/secrets-for-terraform-from-env/default.nix diff --git a/src/args/agnostic.nix b/src/args/agnostic.nix index b3400078..0888fccc 100644 --- a/src/args/agnostic.nix +++ b/src/args/agnostic.nix @@ -58,9 +58,6 @@ let makeContainerImage = import ./make-container-image/default.nix self; makeDerivation = import ./make-derivation/default.nix self; makeDynamoDb = import ./make-dynamodb/default.nix self; - makeEnvVars = import ./make-env-vars/default.nix self; - makeEnvVarsForTerraform = - import ./make-env-vars-for-terraform/default.nix self; makePythonEnvironment = import ./make-python-environment/default.nix self; makePythonPoetryEnvironment = import ./make-python-poetry-environment/default.nix self; @@ -75,10 +72,6 @@ let makeSearchPaths = import ./make-search-paths/default.nix self; makeSecretForAwsFromEnv = import ./make-secret-for-aws-from-env/default.nix self; - makeSecretForEnvFromSops = - import ./make-secret-for-env-from-sops/default.nix self; - makeSecretForTerraformFromEnv = - import ./make-secret-for-terraform-from-env/default.nix self; makeTerraformEnvironment = import ./make-terraform-environment/default.nix self; makeSslCertificate = import ./make-ssl-certificate/default.nix self; diff --git a/src/args/make-env-vars-for-terraform/default.nix b/src/args/make-env-vars-for-terraform/default.nix deleted file mode 100644 index 88eed02c..00000000 --- a/src/args/make-env-vars-for-terraform/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ __nixpkgs__, toBashMap, makeTemplate, toDerivationName, ... }: -{ mapping, name, }: -makeTemplate { - replace = { - __argName__ = toDerivationName name; - __argMap__ = toBashMap mapping; - }; - name = "make-env-vars-for-terraform-for-${name}"; - template = ./template.sh; -} diff --git a/src/args/make-env-vars-for-terraform/template.sh b/src/args/make-env-vars-for-terraform/template.sh deleted file mode 100644 index 2137ab82..00000000 --- a/src/args/make-env-vars-for-terraform/template.sh +++ /dev/null @@ -1,14 +0,0 @@ -# shellcheck shell=bash - -function main { - source __argMap__/template map - - info Making environment variables for Terraform for __argName__: \ - && for var in "${!map[@]}"; do - info - "TF_VAR_${var}=${map[${var}]}" \ - && export "TF_VAR_${var}=${map[${var}]}" \ - || return 1 - done -} - -main "${@}" diff --git a/src/args/make-env-vars/default.nix b/src/args/make-env-vars/default.nix deleted file mode 100644 index a55ba5d0..00000000 --- a/src/args/make-env-vars/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ __nixpkgs__, toBashMap, makeTemplate, toDerivationName, ... }: -{ mapping, name, }: -makeTemplate { - replace = { - __argName__ = toDerivationName name; - __argMap__ = toBashMap mapping; - }; - name = "make-env-vars-for-${name}"; - template = ./template.sh; -} diff --git a/src/args/make-env-vars/template.sh b/src/args/make-env-vars/template.sh deleted file mode 100644 index ffa15f63..00000000 --- a/src/args/make-env-vars/template.sh +++ /dev/null @@ -1,14 +0,0 @@ -# shellcheck shell=bash - -function main { - source __argMap__/template map - - info Making environment variables for __argName__: \ - && for var in "${!map[@]}"; do - info - "${var}=${map[${var}]}" \ - && export "${var}=${map[${var}]}" \ - || return 1 - done -} - -main "${@}" diff --git a/src/args/make-secret-for-env-from-sops/default.nix b/src/args/make-secret-for-env-from-sops/default.nix deleted file mode 100644 index 9b5f0c33..00000000 --- a/src/args/make-secret-for-env-from-sops/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ __nixpkgs__, toBashArray, makeTemplate, toDerivationName, ... }: -{ vars, name, manifest, }: -makeTemplate { - replace = { - __argManifest__ = manifest; - __argName__ = toDerivationName name; - __argVars__ = toBashArray vars; - }; - name = "make-secret-for-env-from-sops-for-${name}"; - searchPaths = { bin = [ __nixpkgs__.jq __nixpkgs__.sops ]; }; - template = ./template.sh; -} diff --git a/src/args/make-secret-for-env-from-sops/template.sh b/src/args/make-secret-for-env-from-sops/template.sh deleted file mode 100644 index 011f0177..00000000 --- a/src/args/make-secret-for-env-from-sops/template.sh +++ /dev/null @@ -1,15 +0,0 @@ -# shellcheck shell=bash - -function main { - source __argVars__/template local vars - - info Making secrets for env from sops for __argName__: \ - && decrypted="$(sops --decrypt --output-type json '__argManifest__')" \ - && for var in "${vars[@]}"; do - info - "${var}" \ - && export "${var//./__}=$(echo "${decrypted}" | jq -erc ".${var}")" \ - || return 1 - done -} - -main "${@}" diff --git a/src/args/make-secret-for-terraform-from-env/default.nix b/src/args/make-secret-for-terraform-from-env/default.nix deleted file mode 100644 index 1765a44c..00000000 --- a/src/args/make-secret-for-terraform-from-env/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ __nixpkgs__, toBashMap, makeTemplate, toDerivationName, ... }: -{ mapping, name, }: -makeTemplate { - replace = { - __argName__ = toDerivationName name; - __argMap__ = toBashMap mapping; - }; - name = "make-secret-for-terraform-from-env-for-${name}"; - template = ./template.sh; -} diff --git a/src/args/make-secret-for-terraform-from-env/template.sh b/src/args/make-secret-for-terraform-from-env/template.sh deleted file mode 100644 index 9d5af507..00000000 --- a/src/args/make-secret-for-terraform-from-env/template.sh +++ /dev/null @@ -1,15 +0,0 @@ -# shellcheck shell=bash - -function main { - source __argMap__/template map - - info Making secret for Terraform from environment variables for __argName__: \ - && for var in "${!map[@]}"; do - require_env_var "${map[${var}]}" \ - && info - "TF_VAR_${var}" \ - && export "TF_VAR_${var}=${!map[${var}]}" \ - || return 1 - done -} - -main "${@}" diff --git a/src/evaluator/modules/default.nix b/src/evaluator/modules/default.nix index 6630160b..dfea3ff8 100644 --- a/src/evaluator/modules/default.nix +++ b/src/evaluator/modules/default.nix @@ -8,8 +8,6 @@ (import ./deploy-container-manifest/default.nix args) (import ./deploy-terraform/default.nix args) (import ./dynamodb/default.nix args) - (import ./env-vars/default.nix args) - (import ./env-vars-for-terraform/default.nix args) (import ./format-bash/default.nix args) (import ./format-markdown/default.nix args) (import ./format-nix/default.nix args) @@ -24,8 +22,6 @@ (import ./lint-with-ajv/default.nix args) (import ./pipelines/default.nix args) (import ./secrets-for-aws-from-env/default.nix args) - (import ./secrets-for-env-from-sops/default.nix args) - (import ./secrets-for-terraform-from-env/default.nix args) (import ./test-license/default.nix args) (import ./test-terraform/default.nix args) ]; diff --git a/src/evaluator/modules/env-vars-for-terraform/default.nix b/src/evaluator/modules/env-vars-for-terraform/default.nix deleted file mode 100644 index fa5e05bc..00000000 --- a/src/evaluator/modules/env-vars-for-terraform/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ __toModuleOutputs__, makeEnvVarsForTerraform, ... }: -{ config, lib, ... }: -let - makeEnvVarsForTerraformOutput = name: mapping: { - name = "/envVarsForTerraform/${name}"; - value = makeEnvVarsForTerraform { - inherit name; - inherit mapping; - }; - }; -in { - options = { - envVarsForTerraform = lib.mkOption { - default = { }; - type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); - }; - }; - config = { - outputs = __toModuleOutputs__ makeEnvVarsForTerraformOutput - config.envVarsForTerraform; - }; -} diff --git a/src/evaluator/modules/env-vars/default.nix b/src/evaluator/modules/env-vars/default.nix deleted file mode 100644 index 0b4369e8..00000000 --- a/src/evaluator/modules/env-vars/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ __toModuleOutputs__, makeEnvVars, ... }: -{ config, lib, ... }: -let - makeEnvVarsOutput = name: mapping: { - name = "/envVars/${name}"; - value = makeEnvVars { - inherit name; - inherit mapping; - }; - }; -in { - options = { - envVars = lib.mkOption { - default = { }; - type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); - }; - }; - config = { outputs = __toModuleOutputs__ makeEnvVarsOutput config.envVars; }; -} diff --git a/src/evaluator/modules/secrets-for-env-from-sops/default.nix b/src/evaluator/modules/secrets-for-env-from-sops/default.nix deleted file mode 100644 index 0d8ed114..00000000 --- a/src/evaluator/modules/secrets-for-env-from-sops/default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ __toModuleOutputs__, makeSecretForEnvFromSops, projectPath, ... }: -{ config, lib, ... }: -let - secretForEnvFromSopsType = lib.types.submodule (_: { - options = { - manifest = lib.mkOption { type = lib.types.str; }; - vars = lib.mkOption { type = lib.types.listOf lib.types.str; }; - }; - }); - - makeOutput = name: - { manifest, vars, }: { - name = "/secretsForEnvFromSops/${name}"; - value = makeSecretForEnvFromSops { - manifest = projectPath manifest; - inherit name; - inherit vars; - }; - }; -in { - options = { - secretsForEnvFromSops = lib.mkOption { - default = { }; - type = lib.types.attrsOf secretForEnvFromSopsType; - }; - }; - config = { - outputs = __toModuleOutputs__ makeOutput config.secretsForEnvFromSops; - }; -} diff --git a/src/evaluator/modules/secrets-for-terraform-from-env/default.nix b/src/evaluator/modules/secrets-for-terraform-from-env/default.nix deleted file mode 100644 index beee753a..00000000 --- a/src/evaluator/modules/secrets-for-terraform-from-env/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ __toModuleOutputs__, makeSecretForTerraformFromEnv, ... }: -{ config, lib, ... }: -let - makeSecretForTerraformFromEnvOutput = name: mapping: { - name = "/secretsForTerraformFromEnv/${name}"; - value = makeSecretForTerraformFromEnv { - inherit name; - inherit mapping; - }; - }; -in { - options = { - secretsForTerraformFromEnv = lib.mkOption { - default = { }; - type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); - }; - }; - config = { - outputs = __toModuleOutputs__ makeSecretForTerraformFromEnvOutput - config.secretsForTerraformFromEnv; - }; -}