From b29d3a11b2f4358922e632c28190c5b8ba85560f Mon Sep 17 00:00:00 2001 From: David Arnold Date: Mon, 31 May 2021 22:31:37 -0500 Subject: [PATCH] testing: rename defaults to common options They are technically no defaults and competing declarations cause a module error --- examples/nginx-deployment/default.nix | 4 ++-- modules/testing/default.nix | 12 ++++++------ modules/testing/docker.nix | 4 ++-- modules/testing/evalTest.nix | 12 ++++++------ tests/default.nix | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/nginx-deployment/default.nix b/examples/nginx-deployment/default.nix index 4f37c6a..41d56b6 100644 --- a/examples/nginx-deployment/default.nix +++ b/examples/nginx-deployment/default.nix @@ -19,10 +19,10 @@ let tests = [ ./test.nix ]; docker.registryUrl = ""; # testing commonalities for tests that exhibit the respective feature - defaults = [ + common = [ { features = [ "k8s" ]; - default = { + options = { kubernetes.version = "1.20"; }; } diff --git a/modules/testing/default.nix b/modules/testing/default.nix index 09c7a11..24fea6d 100644 --- a/modules/testing/default.nix +++ b/modules/testing/default.nix @@ -39,21 +39,21 @@ in default = true; }; - defaults = mkOption { - description = "List of defaults to apply to tests"; + common = mkOption { + description = "List of common options to apply to tests"; type = types.listOf (types.submodule ({ config, ... }: { options = { features = mkOption { - description = "List of features that test has to have to apply defaults"; + description = "List of features that test has to have to apply options"; type = types.listOf types.str; default = [ ]; }; - default = mkOption { - description = "Default to apply to test"; + options = mkOption { + description = "Options to apply to test"; type = types.unspecified; default = { }; - apply = default: { _file = "testing.defaults"; } // default; + apply = default: { _file = "testing.common"; } // default; }; }; })); diff --git a/modules/testing/docker.nix b/modules/testing/docker.nix index 7b2adbd..0d829df 100644 --- a/modules/testing/docker.nix +++ b/modules/testing/docker.nix @@ -37,9 +37,9 @@ in }; }; - config.testing.defaults = [{ + config.testing.common = [{ features = [ "docker" ]; - default = { + options = { _file = "testing.docker.registryUrl"; docker.registry.url = cfg.registryUrl; }; diff --git a/modules/testing/evalTest.nix b/modules/testing/evalTest.nix index 0c4662f..fbf6c68 100644 --- a/modules/testing/evalTest.nix +++ b/modules/testing/evalTest.nix @@ -33,23 +33,23 @@ let # test features testFeatures = evaled'.config._m.features; - # defaults that can be applied on tests - defaults = + # common options that can be applied on this test + commonOpts = filter (d: (intersectLists d.features testFeatures) == d.features || (length d.features) == 0 ) - testing.defaults; + testing.common; - # add default modules to all modules - modulesWithDefaults = modules ++ (map (d: d.default) defaults); + # add common options modules to all modules + modulesWithCommonOptions = modules ++ (map (d: d.options) commonOpts); # evaled test evaled = let evaled' = kubenix.evalModules { - modules = modulesWithDefaults; + modules = modulesWithCommonOptions; }; in if testing.throwError then evaled' diff --git a/tests/default.nix b/tests/default.nix index f8a4f35..a3383a4 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -40,10 +40,10 @@ let args = { images = pkgs.callPackage ./images.nix { }; }; docker.registryUrl = registry; - defaults = [ + common = [ { features = [ "k8s" ]; - default = { + options = { kubernetes.version = k8sVersion; }; }