Skip to content

Commit

Permalink
refac(back): fluidattacks#1364 remove config
Browse files Browse the repository at this point in the history
- Remove config parameter in favor of a more flat approach

Signed-off-by: Daniel Salazar <podany270895@gmail.com>
  • Loading branch information
dsalaza4 committed Aug 12, 2024
1 parent 9b48d0e commit 283b5e9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 59 deletions.
54 changes: 26 additions & 28 deletions docs/src/api/builtins/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,18 @@ 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
that stores the value of the registry token.
- 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]
Expand All @@ -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:
Expand Down Expand Up @@ -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" ];
};
};
}
Expand Down
38 changes: 18 additions & 20 deletions makes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions src/args/deploy-container-manifest/default.nix
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/evaluator/modules/deploy-container-manifest/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};

Expand All @@ -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; };
Expand All @@ -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;
Expand All @@ -50,6 +46,10 @@ in {
default = false;
type = lib.types.bool;
};
tags = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
};
};
}));
};
Expand Down

0 comments on commit 283b5e9

Please sign in to comment.