From ef6ee4eb84d7d1f3823522e68f583292452d088a Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Mon, 12 Aug 2024 14:07:51 -0500 Subject: [PATCH] refac(back): #1364 remove config - Remove config parameter in favor of a more flat approach --- docs/src/api/builtins/deploy.md | 54 +++++++++---------- makes.nix | 38 +++++++------ .../deploy-container-manifest/default.nix | 5 +- .../deploy-container-manifest/default.nix | 18 +++---- 4 files changed, 56 insertions(+), 59 deletions(-) diff --git a/docs/src/api/builtins/deploy.md b/docs/src/api/builtins/deploy.md index 92c3e211..35b65510 100644 --- a/docs/src/api/builtins/deploy.md +++ b/docs/src/api/builtins/deploy.md @@ -262,14 +262,6 @@ Types: - deployContainerManifest (`attrsOf targetType`): - targetType (`submodule`): - - config: - - image (`str`): - Path for the manifest that will be deployed. - - tags (`listOf str`): - List of secondary tags (aliases) for the image. - - manifests (`listOf manifestType`): - Already-existing images to be used by the new manifest. - Typically used for supporting multiple architectures. - credentials: - token (`str`): Name of the environment variable @@ -277,6 +269,11 @@ Types: - user (`str`): Name of the environment variable that stores the value of the registry user. + - image (`str`): + Path for the manifest that will be deployed. + - manifests (`listOf manifestType`): + Already-existing images to be used by the new manifest. + Typically used for supporting multiple architectures. - setup (`listOf package`): Optional. [Makes Environment][makes_environment] or [Makes Secrets][makes_secrets] @@ -289,6 +286,9 @@ Types: by using a [OIDC keyless approach](https://docs.sigstore.dev/signing/quickstart/#keyless-signing-of-a-container). Defaults to `false`. + - tags (`listOf str`): Optional. + List of secondary tags (aliases) for the image. + Defaults to `[ ]`. - manifestType (`submodule`): - image: Path to the already-deployed image. - platform: @@ -331,31 +331,29 @@ Example: }; deployContainerManifest = { makes = { - config = { - image = "ghcr.io/fluidattacks/makes:latest"; - tags = [ "24.02" ]; - manifests = [ - { - image = "ghcr.io/fluidattacks/makes:amd64"; - platform = { - architecture = "amd64"; - os = "linux"; - }; - } - { - image = "ghcr.io/fluidattacks/makes:arm64"; - platform = { - architecture = "arm64"; - os = "linux"; - }; - } - ]; - }; credentials = { token = "GITHUB_TOKEN"; user = "GITHUB_ACTOR"; }; + image = "ghcr.io/fluidattacks/makes:latest"; + manifests = [ + { + image = "ghcr.io/fluidattacks/makes:amd64"; + platform = { + architecture = "amd64"; + os = "linux"; + }; + } + { + image = "ghcr.io/fluidattacks/makes:arm64"; + platform = { + architecture = "arm64"; + os = "linux"; + }; + } + ]; sign = true; + tags = [ "24.02" ]; }; }; } diff --git a/makes.nix b/makes.nix index 82c06cd1..4ae011f2 100644 --- a/makes.nix +++ b/makes.nix @@ -46,31 +46,29 @@ }; deployContainerManifest = { makes = { - config = { - image = "ghcr.io/fluidattacks/makes:latest"; - tags = [ "24.02" ]; - manifests = [ - { - image = "ghcr.io/fluidattacks/makes:amd64"; - platform = { - architecture = "amd64"; - os = "linux"; - }; - } - { - image = "ghcr.io/fluidattacks/makes:arm64"; - platform = { - architecture = "arm64"; - os = "linux"; - }; - } - ]; - }; credentials = { token = "GITHUB_TOKEN"; user = "GITHUB_ACTOR"; }; + image = "ghcr.io/fluidattacks/makes:latest"; + manifests = [ + { + image = "ghcr.io/fluidattacks/makes:amd64"; + platform = { + architecture = "amd64"; + os = "linux"; + }; + } + { + image = "ghcr.io/fluidattacks/makes:arm64"; + platform = { + architecture = "arm64"; + os = "linux"; + }; + } + ]; sign = true; + tags = [ "24.02" ]; }; }; deployTerraform = { diff --git a/src/args/deploy-container-manifest/default.nix b/src/args/deploy-container-manifest/default.nix index b617f6b4..a13d5a9a 100644 --- a/src/args/deploy-container-manifest/default.nix +++ b/src/args/deploy-container-manifest/default.nix @@ -1,8 +1,9 @@ { __nixpkgs__, makeScript, toFileYaml, ... }: -{ config, credentials, name, setup, sign }: +{ credentials, image, manifests, name, setup, sign, tags }: makeScript { replace = { - __argConfig__ = toFileYaml "manifest.yaml " config; + __argConfig__ = + toFileYaml "manifest.yaml " { inherit image manifests tags; }; __argCredentialsToken__ = credentials.token; __argCredentialsUser__ = credentials.user; __argSign__ = sign; diff --git a/src/evaluator/modules/deploy-container-manifest/default.nix b/src/evaluator/modules/deploy-container-manifest/default.nix index 5ce63db1..2cabf5ff 100644 --- a/src/evaluator/modules/deploy-container-manifest/default.nix +++ b/src/evaluator/modules/deploy-container-manifest/default.nix @@ -4,11 +4,13 @@ let makeOutput = name: args: { name = "/deployContainerManifest/${name}"; value = deployContainerManifest { - inherit (args) config; inherit (args) credentials; + inherit (args) image; + inherit (args) manifests; inherit name; inherit (args) setup; inherit (args) sign; + inherit (args) tags; }; }; @@ -21,13 +23,6 @@ let }; }; }); - configType = lib.types.submodule (_: { - options = { - image = lib.mkOption { type = lib.types.str; }; - tags = lib.mkOption { type = lib.types.listOf lib.types.str; }; - manifests = lib.mkOption { type = lib.types.listOf manifestType; }; - }; - }); credentialsType = lib.types.submodule (_: { options = { token = lib.mkOption { type = lib.types.str; }; @@ -40,8 +35,9 @@ in { default = { }; type = lib.types.attrsOf (lib.types.submodule (_: { options = { - config = lib.mkOption { type = configType; }; credentials = lib.mkOption { type = credentialsType; }; + image = lib.mkOption { type = lib.types.str; }; + manifests = lib.mkOption { type = lib.types.listOf manifestType; }; setup = lib.mkOption { default = [ ]; type = lib.types.listOf lib.types.package; @@ -50,6 +46,10 @@ in { default = false; type = lib.types.bool; }; + tags = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.str; + }; }; })); };