Skip to content

Commit

Permalink
refac(back): fluidattacks#1007 redefine cache module
Browse files Browse the repository at this point in the history
- make the cache module generic
- add more options
  • Loading branch information
drestrepoatfluid authored and Diego Restrepo committed Feb 20, 2023
1 parent dcfa9a5 commit 0c5603e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 15 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ David Acevedo <dacevedoa12@gmail.com> David Acevedo <dacevedoa12@gmail.com>
David Arnold <david.arnold@iohk.io> David Arnold <david.arnold@iohk.io>
David Arnold <david.arnold@iohk.io> David Arnold <dgx.arnold@gmail.com>
Diego Restrepo <drestrepo@fluidattacks.com> Diego Restrepo Mesa <36453706+drestrepom@users.noreply.github.com>
Diego Restrepo <drestrepo@fluidttacks.com> Diego Restrepo <drestrepo@fluidttacks.com>
Diego Restrepo <restrepomesadiego@gmail.com> Diego Restrepo Mesa <36453706+drestrepom@users.noreply.github.com>
Fluid Attacks <help@fluidattacks.com> Fluid Attacks <help@fluidattacks.com>
Github Dependabot <49699333+dependabot[bot]@users.noreply.github.com> dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Expand Down
48 changes: 48 additions & 0 deletions src/evaluator/modules/cache-with-attic/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-FileCopyrightText: 2022 Fluid Attacks and Makes contributors
#
# SPDX-License-Identifier: MIT
{listOptional, ...}: {
config,
lib,
...
}: {
options = {
cacheWithAttic = {
readAndWrite = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
name = lib.mkOption {
type = lib.types.str;
};
url = lib.mkOption {
type = lib.types.str;
};
token = lib.mkOption {
type = lib.types.str;
};
pubKey = lib.mkOption {
type = lib.types.str;
};
priority = lib.mkOption {
type = lib.type.int;
default = 10;
};
};
};
};
config = {
config = {
cacheWithAttic = builtins.concatLists [
(listOptional config.cacheWithAttic.readAndWrite.enable {
name = config.cacheWithAttic.readAndWrite.name;
url = config.cacheWithAttic.readAndWrite.url;
token = config.cacheWithAttic.readAndWrite.token;
pubKey = config.cacheWithAttic.readAndWrite.pubKey;
type = "attic";
})
];
};
};
}
40 changes: 25 additions & 15 deletions src/evaluator/modules/cache/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,38 @@
}: {
options = {
cache = {
readAndWrite = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
name = lib.mkOption {
type = lib.types.str;
};
pubKey = lib.mkOption {
type = lib.types.str;
};
};
readExtra = lib.mkOption {
default = [];
type = lib.types.listOf (lib.types.submodule (_: {
extra = lib.mkOption {
default = {};
type = lib.types.attrsOf (lib.types.submodule (_: {
options = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
name = lib.mkOption {
type = lib.types.str;
};
token = lib.mkOption {
type = lib.types.str;
default = "";
};
priority = lib.mkOption {
type = lib.types.int;
};
pubKey = lib.mkOption {
default = "";
type = lib.types.str;
};
type = lib.mkOption {
type = lib.types.enum ["cachix" "attic"];
};
url = lib.mkOption {
type = lib.types.str;
};
write = lib.mkOption {
default = false;
type = lib.types.bool;
};
};
}));
};
Expand Down
1 change: 1 addition & 0 deletions src/evaluator/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
} @ args: {
imports = [
(import ./cache/default.nix args)
(import ./cache-with-attic/default.nix args)
(import ./calculate-scorecard/default.nix args)
(import ./compute-on-aws-batch/default.nix args)
(import ./dev/default.nix args)
Expand Down

0 comments on commit 0c5603e

Please sign in to comment.