mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
statix fix
This commit is contained in:
parent
890b84be5e
commit
6a720a257e
27 changed files with 86 additions and 99 deletions
|
|
@ -1,6 +1,4 @@
|
||||||
{system ? builtins.currentSystem}: let
|
{system ? builtins.currentSystem}: (
|
||||||
in
|
|
||||||
(
|
|
||||||
(import ./compat.nix).flake-compat {
|
(import ./compat.nix).flake-compat {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
registry,
|
registry,
|
||||||
}: let
|
}: let
|
||||||
# evaluated configuration
|
# evaluated configuration
|
||||||
config =
|
inherit ((evalModules {
|
||||||
(evalModules {
|
|
||||||
module = {kubenix, ...}: {
|
module = {kubenix, ...}: {
|
||||||
imports = [
|
imports = [
|
||||||
kubenix.modules.testing
|
kubenix.modules.testing
|
||||||
|
|
@ -30,8 +29,7 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})) config;
|
||||||
.config;
|
|
||||||
in {
|
in {
|
||||||
inherit config;
|
inherit config;
|
||||||
|
|
||||||
|
|
@ -45,10 +43,10 @@ in {
|
||||||
test-script = config.testing.testsByName.nginx-deployment.script;
|
test-script = config.testing.testsByName.nginx-deployment.script;
|
||||||
|
|
||||||
# genreated kubernetes List object
|
# genreated kubernetes List object
|
||||||
generated = config.kubernetes.generated;
|
inherit (config.kubernetes) generated;
|
||||||
|
|
||||||
# JSON file you can deploy to kubernetes
|
# JSON file you can deploy to kubernetes
|
||||||
result = config.kubernetes.result;
|
inherit (config.kubernetes) result;
|
||||||
|
|
||||||
# Exported docker images
|
# Exported docker images
|
||||||
images = config.docker.export;
|
images = config.docker.export;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
inherit system;
|
inherit system;
|
||||||
};
|
};
|
||||||
|
|
||||||
lib = pkgs.lib;
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
kubenix = {
|
kubenix = {
|
||||||
lib = import ./lib {inherit lib pkgs;};
|
lib = import ./lib {inherit lib pkgs;};
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
checks = let
|
checks = let
|
||||||
wasSuccess = suite:
|
wasSuccess = suite:
|
||||||
if suite.success == true
|
if suite.success
|
||||||
then pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-succeeded" {} "echo success > $out"
|
then pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-succeeded" {} "echo success > $out"
|
||||||
else pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-failed" {} "exit 1";
|
else pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-failed" {} "exit 1";
|
||||||
mkExamples = attrs:
|
mkExamples = attrs:
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ with lib; let
|
||||||
refDefinition = attr: head (tail (tail (splitString "/" attr."$ref")));
|
refDefinition = attr: head (tail (tail (splitString "/" attr."$ref")));
|
||||||
};
|
};
|
||||||
|
|
||||||
fixJSON = content: replaceStrings ["\\u"] ["u"] content;
|
fixJSON = replaceStrings ["\\u"] ["u"];
|
||||||
|
|
||||||
fetchSpecs = path: builtins.fromJSON (fixJSON (builtins.readFile path));
|
fetchSpecs = path: builtins.fromJSON (fixJSON (builtins.readFile path));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ with lib; let
|
||||||
refType = attr: head (tail (tail (splitString "/" attr."$ref")));
|
refType = attr: head (tail (tail (splitString "/" attr."$ref")));
|
||||||
|
|
||||||
compareVersions = ver1: ver2: let
|
compareVersions = ver1: ver2: let
|
||||||
getVersion = v: substring 1 10 v;
|
getVersion = substring 1 10;
|
||||||
splitVersion = v: builtins.splitVersion (getVersion v);
|
splitVersion = v: builtins.splitVersion (getVersion v);
|
||||||
isAlpha = v: elem "alpha" (splitVersion v);
|
isAlpha = v: elem "alpha" (splitVersion v);
|
||||||
patchVersion = v:
|
patchVersion = v:
|
||||||
|
|
@ -103,7 +103,7 @@ with lib; let
|
||||||
in
|
in
|
||||||
builtins.compareVersions v1 v2;
|
builtins.compareVersions v1 v2;
|
||||||
|
|
||||||
fixJSON = content: replaceStrings ["\\u"] ["u"] content;
|
fixJSON = replaceStrings ["\\u"] ["u"];
|
||||||
|
|
||||||
fetchSpecs = path: builtins.fromJSON (fixJSON (builtins.readFile path));
|
fetchSpecs = path: builtins.fromJSON (fixJSON (builtins.readFile path));
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ with lib; let
|
||||||
else group';
|
else group';
|
||||||
version = version';
|
version = version';
|
||||||
kind = kind';
|
kind = kind';
|
||||||
description = swagger.definitions.${ref}.description;
|
inherit (swagger.definitions.${ref}) description;
|
||||||
defintion = refDefinition (head path.post.parameters).schema;
|
defintion = refDefinition (head path.post.parameters).schema;
|
||||||
})
|
})
|
||||||
(filterAttrs
|
(filterAttrs
|
||||||
|
|
@ -301,7 +301,7 @@ with lib; let
|
||||||
resourceTypesByKind;
|
resourceTypesByKind;
|
||||||
|
|
||||||
latestResourceTypesByKind =
|
latestResourceTypesByKind =
|
||||||
mapAttrs (_kind: resources: last resources) resourcesTypesByKindSortByVersion;
|
mapAttrs (_kind: last) resourcesTypesByKindSortByVersion;
|
||||||
|
|
||||||
genResourceOptions = resource:
|
genResourceOptions = resource:
|
||||||
with gen; let
|
with gen; let
|
||||||
|
|
@ -313,7 +313,7 @@ with lib; let
|
||||||
definition.version;
|
definition.version;
|
||||||
in
|
in
|
||||||
mkOption {
|
mkOption {
|
||||||
description = resource.description;
|
inherit (resource) description;
|
||||||
type = types.attrsOf (submoduleForDefinition' resource);
|
type = types.attrsOf (submoduleForDefinition' resource);
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
kubernetes-helm,
|
kubernetes-helm,
|
||||||
cacert,
|
cacert,
|
||||||
}: let
|
}: let
|
||||||
cleanName = name: lib.replaceStrings ["/"] ["-"] name;
|
cleanName = lib.replaceStrings ["/"] ["-"];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# name of the chart
|
# name of the chart
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,6 @@ with lib; rec {
|
||||||
// labels;
|
// labels;
|
||||||
};
|
};
|
||||||
|
|
||||||
toBase64 = lib.toBase64;
|
inherit (lib) toBase64;
|
||||||
octalToDecimal = lib.octalToDecimal;
|
inherit (lib) octalToDecimal;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ with lib; {
|
||||||
|
|
||||||
_m.propagate = mkOption {
|
_m.propagate = mkOption {
|
||||||
description = "Module propagation options";
|
description = "Module propagation options";
|
||||||
type = types.listOf (types.submodule ({ ...}: {
|
type = types.listOf (types.submodule (_: {
|
||||||
options = {
|
options = {
|
||||||
features = mkOption {
|
features = mkOption {
|
||||||
description = "List of features that submodule has to have to propagate module";
|
description = "List of features that submodule has to have to propagate module";
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,7 @@ in {
|
||||||
_m.propagate = [
|
_m.propagate = [
|
||||||
{
|
{
|
||||||
features = ["docker"];
|
features = ["docker"];
|
||||||
module = {
|
module = _: {
|
||||||
...
|
|
||||||
}: {
|
|
||||||
# propagate registry options
|
# propagate registry options
|
||||||
docker.registry = cfg.registry;
|
docker.registry = cfg.registry;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ with lib; let
|
||||||
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
||||||
in
|
in
|
||||||
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
||||||
getSubOptions = finalType.getSubOptions;
|
inherit (finalType) getSubOptions;
|
||||||
getSubModules = finalType.getSubModules;
|
inherit (finalType) getSubModules;
|
||||||
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
||||||
typeMerge = _t1: _t2: null;
|
typeMerge = _t1: _t2: null;
|
||||||
functor = (defaultFunctor name) // {wrapped = finalType;};
|
functor = (defaultFunctor name) // {wrapped = finalType;};
|
||||||
|
|
@ -62,7 +62,7 @@ with lib; let
|
||||||
values);
|
values);
|
||||||
|
|
||||||
submoduleOf = ref:
|
submoduleOf = ref:
|
||||||
types.submodule ({ ...}: {
|
types.submodule (_: {
|
||||||
options = definitions."${ref}".options or {};
|
options = definitions."${ref}".options or {};
|
||||||
config = definitions."${ref}".config or {};
|
config = definitions."${ref}".config or {};
|
||||||
});
|
});
|
||||||
|
|
@ -74,7 +74,7 @@ with lib; let
|
||||||
then toInt name
|
then toInt name
|
||||||
else name;
|
else name;
|
||||||
in {
|
in {
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config =
|
config =
|
||||||
definitions."${ref}".config
|
definitions."${ref}".config
|
||||||
// {
|
// {
|
||||||
|
|
@ -90,7 +90,7 @@ with lib; let
|
||||||
in
|
in
|
||||||
types.submodule ({name, ...}: {
|
types.submodule ({name, ...}: {
|
||||||
imports = getDefaults resource group version kind;
|
imports = getDefaults resource group version kind;
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
definitions."${ref}".config
|
definitions."${ref}".config
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ with lib; let
|
||||||
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
||||||
in
|
in
|
||||||
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
||||||
getSubOptions = finalType.getSubOptions;
|
inherit (finalType) getSubOptions;
|
||||||
getSubModules = finalType.getSubModules;
|
inherit (finalType) getSubModules;
|
||||||
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
||||||
typeMerge = _t1: _t2: null;
|
typeMerge = _t1: _t2: null;
|
||||||
functor = (defaultFunctor name) // {wrapped = finalType;};
|
functor = (defaultFunctor name) // {wrapped = finalType;};
|
||||||
|
|
@ -62,7 +62,7 @@ with lib; let
|
||||||
values);
|
values);
|
||||||
|
|
||||||
submoduleOf = ref:
|
submoduleOf = ref:
|
||||||
types.submodule ({ ...}: {
|
types.submodule (_: {
|
||||||
options = definitions."${ref}".options or {};
|
options = definitions."${ref}".options or {};
|
||||||
config = definitions."${ref}".config or {};
|
config = definitions."${ref}".config or {};
|
||||||
});
|
});
|
||||||
|
|
@ -74,7 +74,7 @@ with lib; let
|
||||||
then toInt name
|
then toInt name
|
||||||
else name;
|
else name;
|
||||||
in {
|
in {
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config =
|
config =
|
||||||
definitions."${ref}".config
|
definitions."${ref}".config
|
||||||
// {
|
// {
|
||||||
|
|
@ -90,7 +90,7 @@ with lib; let
|
||||||
in
|
in
|
||||||
types.submodule ({name, ...}: {
|
types.submodule ({name, ...}: {
|
||||||
imports = getDefaults resource group version kind;
|
imports = getDefaults resource group version kind;
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
definitions."${ref}".config
|
definitions."${ref}".config
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ with lib; let
|
||||||
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
||||||
in
|
in
|
||||||
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
||||||
getSubOptions = finalType.getSubOptions;
|
inherit (finalType) getSubOptions;
|
||||||
getSubModules = finalType.getSubModules;
|
inherit (finalType) getSubModules;
|
||||||
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
||||||
typeMerge = _t1: _t2: null;
|
typeMerge = _t1: _t2: null;
|
||||||
functor = (defaultFunctor name) // {wrapped = finalType;};
|
functor = (defaultFunctor name) // {wrapped = finalType;};
|
||||||
|
|
@ -62,7 +62,7 @@ with lib; let
|
||||||
values);
|
values);
|
||||||
|
|
||||||
submoduleOf = ref:
|
submoduleOf = ref:
|
||||||
types.submodule ({ ...}: {
|
types.submodule (_: {
|
||||||
options = definitions."${ref}".options or {};
|
options = definitions."${ref}".options or {};
|
||||||
config = definitions."${ref}".config or {};
|
config = definitions."${ref}".config or {};
|
||||||
});
|
});
|
||||||
|
|
@ -74,7 +74,7 @@ with lib; let
|
||||||
then toInt name
|
then toInt name
|
||||||
else name;
|
else name;
|
||||||
in {
|
in {
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config =
|
config =
|
||||||
definitions."${ref}".config
|
definitions."${ref}".config
|
||||||
// {
|
// {
|
||||||
|
|
@ -90,7 +90,7 @@ with lib; let
|
||||||
in
|
in
|
||||||
types.submodule ({name, ...}: {
|
types.submodule ({name, ...}: {
|
||||||
imports = getDefaults resource group version kind;
|
imports = getDefaults resource group version kind;
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
definitions."${ref}".config
|
definitions."${ref}".config
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ in {
|
||||||
map
|
map
|
||||||
(object: let
|
(object: let
|
||||||
apiVersion = parseApiVersion object.apiVersion;
|
apiVersion = parseApiVersion object.apiVersion;
|
||||||
name = object.metadata.name;
|
inherit (object.metadata) name;
|
||||||
in {
|
in {
|
||||||
"${apiVersion.group}"."${apiVersion.version}".${object.kind}."${name}" = mkMerge ([
|
"${apiVersion.group}"."${apiVersion.version}".${object.kind}."${name}" = mkMerge ([
|
||||||
object
|
object
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ with lib; let
|
||||||
assert finalType.check coerced; coerced;
|
assert finalType.check coerced; coerced;
|
||||||
in
|
in
|
||||||
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
||||||
getSubOptions = finalType.getSubOptions;
|
inherit (finalType) getSubOptions;
|
||||||
getSubModules = finalType.getSubModules;
|
inherit (finalType) getSubModules;
|
||||||
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
||||||
typeMerge = _t1: _t2: null;
|
typeMerge = _t1: _t2: null;
|
||||||
functor = (defaultFunctor name) // {wrapped = finalType;};
|
functor = (defaultFunctor name) // {wrapped = finalType;};
|
||||||
|
|
@ -41,9 +41,9 @@ with lib; let
|
||||||
};
|
};
|
||||||
|
|
||||||
submoduleOf = ref:
|
submoduleOf = ref:
|
||||||
types.submodule ({ ...}: {
|
types.submodule (_: {
|
||||||
options = definitions."${ref}".options;
|
inherit (definitions."${ref}") options;
|
||||||
config = definitions."${ref}".config;
|
inherit (definitions."${ref}") config;
|
||||||
});
|
});
|
||||||
|
|
||||||
definitions =
|
definitions =
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ with lib; let
|
||||||
|
|
||||||
moduleToAttrs = value:
|
moduleToAttrs = value:
|
||||||
if isAttrs value
|
if isAttrs value
|
||||||
then mapAttrs (_n: v: moduleToAttrs v) (filterAttrs (n: v: v != null && !(hasPrefix "_" n)) value)
|
then mapAttrs (_n: moduleToAttrs) (filterAttrs (n: v: v != null && !(hasPrefix "_" n)) value)
|
||||||
else if isList value
|
else if isList value
|
||||||
then map (v: moduleToAttrs v) value
|
then map moduleToAttrs value
|
||||||
else value;
|
else value;
|
||||||
|
|
||||||
apiOptions = {config, ...}: {
|
apiOptions = {config, ...}: {
|
||||||
|
|
@ -38,7 +38,7 @@ with lib; let
|
||||||
|
|
||||||
defaults = mkOption {
|
defaults = mkOption {
|
||||||
description = "Kubernetes defaults to apply to resources";
|
description = "Kubernetes defaults to apply to resources";
|
||||||
type = types.listOf (types.submodule ({ ...}: {
|
type = types.listOf (types.submodule (_: {
|
||||||
options = {
|
options = {
|
||||||
group = mkOption {
|
group = mkOption {
|
||||||
description = "Group to apply default to (all by default)";
|
description = "Group to apply default to (all by default)";
|
||||||
|
|
@ -132,7 +132,7 @@ with lib; let
|
||||||
lst));
|
lst));
|
||||||
|
|
||||||
compareVersions = ver1: ver2: let
|
compareVersions = ver1: ver2: let
|
||||||
getVersion = v: substring 1 10 v;
|
getVersion = substring 1 10;
|
||||||
splittedVer1 = builtins.splitVersion (getVersion ver1);
|
splittedVer1 = builtins.splitVersion (getVersion ver1);
|
||||||
splittedVer2 = builtins.splitVersion (getVersion ver2);
|
splittedVer2 = builtins.splitVersion (getVersion ver2);
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ with lib; let
|
||||||
customResourceTypesByAttrName;
|
customResourceTypesByAttrName;
|
||||||
|
|
||||||
latestCustomResourceTypes =
|
latestCustomResourceTypes =
|
||||||
mapAttrsToList (_: resources: last resources) customResourceTypesByAttrNameSortByVersion;
|
mapAttrsToList (_: last) customResourceTypesByAttrNameSortByVersion;
|
||||||
|
|
||||||
customResourceModuleForType = config: ct: {name, ...}: {
|
customResourceModuleForType = config: ct: {name, ...}: {
|
||||||
imports = getDefaults ct.name ct.group ct.version ct.kind;
|
imports = getDefaults ct.name ct.group ct.version ct.kind;
|
||||||
|
|
@ -207,7 +207,7 @@ with lib; let
|
||||||
module = customResourceModuleForType config ct;
|
module = customResourceModuleForType config ct;
|
||||||
in {
|
in {
|
||||||
options.resources.${ct.group}.${ct.version}.${ct.kind} = mkOption {
|
options.resources.${ct.group}.${ct.version}.${ct.kind} = mkOption {
|
||||||
description = ct.description;
|
inherit (ct) description;
|
||||||
type = types.attrsOf (types.submodule module);
|
type = types.attrsOf (types.submodule module);
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
@ -222,7 +222,7 @@ with lib; let
|
||||||
module = customResourceModuleForType config ct;
|
module = customResourceModuleForType config ct;
|
||||||
in {
|
in {
|
||||||
options.resources.${ct.attrName} = mkOption {
|
options.resources.${ct.attrName} = mkOption {
|
||||||
description = ct.description;
|
inherit (ct) description;
|
||||||
type = types.attrsOf (types.submodule module);
|
type = types.attrsOf (types.submodule module);
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
@ -255,8 +255,8 @@ with lib; let
|
||||||
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
else let coerced = coerceFunc val; in assert finalType.check coerced; coerced;
|
||||||
in
|
in
|
||||||
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
finalType.merge loc (map (def: def // {value = coerceVal def.value;}) defs);
|
||||||
getSubOptions = finalType.getSubOptions;
|
inherit (finalType) getSubOptions;
|
||||||
getSubModules = finalType.getSubModules;
|
inherit (finalType) getSubModules;
|
||||||
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
||||||
typeMerge = _t1: _t2: null;
|
typeMerge = _t1: _t2: null;
|
||||||
functor = (defaultFunctor name) // {wrapped = finalType;};
|
functor = (defaultFunctor name) // {wrapped = finalType;};
|
||||||
|
|
@ -405,7 +405,7 @@ in {
|
||||||
_m.propagate = [
|
_m.propagate = [
|
||||||
{
|
{
|
||||||
features = ["k8s"];
|
features = ["k8s"];
|
||||||
module = { ...}: {
|
module = _: {
|
||||||
# propagate kubernetes version and namespace
|
# propagate kubernetes version and namespace
|
||||||
kubernetes.version = mkDefault cfg.version;
|
kubernetes.version = mkDefault cfg.version;
|
||||||
kubernetes.namespace = mkDefault cfg.namespace;
|
kubernetes.namespace = mkDefault cfg.namespace;
|
||||||
|
|
@ -415,9 +415,7 @@ in {
|
||||||
features = ["k8s" "submodule"];
|
features = ["k8s" "submodule"];
|
||||||
module = {config, ...}: {
|
module = {config, ...}: {
|
||||||
# set module defaults
|
# set module defaults
|
||||||
kubernetes.api.defaults = (
|
kubernetes.api.defaults = (filter (default: default.propagate) cfg.api.defaults)
|
||||||
# propagate defaults if default propagation is enabled
|
|
||||||
(filter (default: default.propagate) cfg.api.defaults)
|
|
||||||
++ [
|
++ [
|
||||||
# set module name and version for all kuberentes resources
|
# set module name and version for all kuberentes resources
|
||||||
{
|
{
|
||||||
|
|
@ -426,8 +424,7 @@ in {
|
||||||
"kubenix/module-version" = config.submodule.version;
|
"kubenix/module-version" = config.submodule.version;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
@ -470,13 +467,13 @@ in {
|
||||||
# load yaml file
|
# load yaml file
|
||||||
object = importYAML i;
|
object = importYAML i;
|
||||||
groupVersion = splitString "/" object.apiVersion;
|
groupVersion = splitString "/" object.apiVersion;
|
||||||
name = object.metadata.name;
|
inherit (object.metadata) name;
|
||||||
version = last groupVersion;
|
version = last groupVersion;
|
||||||
group =
|
group =
|
||||||
if version == (head groupVersion)
|
if version == (head groupVersion)
|
||||||
then "core"
|
then "core"
|
||||||
else head groupVersion;
|
else head groupVersion;
|
||||||
kind = object.kind;
|
inherit (object) kind;
|
||||||
in {
|
in {
|
||||||
resources.${group}.${version}.${kind}.${name} = object;
|
resources.${group}.${version}.${kind}.${name} = object;
|
||||||
})
|
})
|
||||||
|
|
@ -485,7 +482,7 @@ in {
|
||||||
kubernetes.objects = flatten (mapAttrsToList
|
kubernetes.objects = flatten (mapAttrsToList
|
||||||
(
|
(
|
||||||
_: type:
|
_: type:
|
||||||
mapAttrsToList (_name: resource: moduleToAttrs resource)
|
mapAttrsToList (_name: moduleToAttrs)
|
||||||
cfg.api.resources.${type.group}.${type.version}.${type.kind}
|
cfg.api.resources.${type.group}.${type.version}.${type.kind}
|
||||||
)
|
)
|
||||||
cfg.api.types);
|
cfg.api.types);
|
||||||
|
|
@ -500,6 +497,6 @@ in {
|
||||||
pkgs.writeText "${config.kubenix.project}-generated.json" (builtins.toJSON cfg.generated);
|
pkgs.writeText "${config.kubenix.project}-generated.json" (builtins.toJSON cfg.generated);
|
||||||
|
|
||||||
kubernetes.resultYAML =
|
kubernetes.resultYAML =
|
||||||
toMultiDocumentYaml "${config.kubenix.project}-generated.yaml" (config.kubernetes.objects);
|
toMultiDocumentYaml "${config.kubenix.project}-generated.yaml" config.kubernetes.objects;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ in {
|
||||||
|
|
||||||
submodules.defaults = mkOption {
|
submodules.defaults = mkOption {
|
||||||
description = "List of defaults to apply to submodule instances";
|
description = "List of defaults to apply to submodule instances";
|
||||||
type = types.listOf (types.submodule ({ ...}: {
|
type = types.listOf (types.submodule (_: {
|
||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
description = "Name of the submodule to apply defaults for";
|
description = "Name of the submodule to apply defaults for";
|
||||||
|
|
@ -279,7 +279,7 @@ in {
|
||||||
inherit (evaledSubmodule.config.submodule) name description version tags exports;
|
inherit (evaledSubmodule.config.submodule) name description version tags exports;
|
||||||
};
|
};
|
||||||
|
|
||||||
features = evaledSubmodule.config._m.features;
|
inherit (evaledSubmodule.config._m) features;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
@ -299,7 +299,7 @@ in {
|
||||||
# submodule associated with
|
# submodule associated with
|
||||||
submodule = findSubmodule {
|
submodule = findSubmodule {
|
||||||
name = config.submodule;
|
name = config.submodule;
|
||||||
version = config.version;
|
inherit (config) version;
|
||||||
};
|
};
|
||||||
|
|
||||||
# definition of a submodule
|
# definition of a submodule
|
||||||
|
|
@ -307,10 +307,10 @@ in {
|
||||||
|
|
||||||
# submodule defaults
|
# submodule defaults
|
||||||
defaults = getDefaults {
|
defaults = getDefaults {
|
||||||
name = submoduleDefinition.name;
|
inherit (submoduleDefinition) name;
|
||||||
version = submoduleDefinition.version;
|
inherit (submoduleDefinition) version;
|
||||||
tags = submoduleDefinition.tags;
|
inherit (submoduleDefinition) tags;
|
||||||
features = submodule.features;
|
inherit (submodule) features;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
|
|
@ -390,7 +390,7 @@ in {
|
||||||
|
|
||||||
(map
|
(map
|
||||||
(propagate: {
|
(propagate: {
|
||||||
features = propagate.features;
|
inherit (propagate) features;
|
||||||
default = propagate.module;
|
default = propagate.module;
|
||||||
})
|
})
|
||||||
config._m.propagate)
|
config._m.propagate)
|
||||||
|
|
@ -404,8 +404,8 @@ in {
|
||||||
features = ["submodules"];
|
features = ["submodules"];
|
||||||
default = {
|
default = {
|
||||||
submodules = {
|
submodules = {
|
||||||
defaults = cfg.defaults;
|
inherit (cfg) defaults;
|
||||||
imports = cfg.imports;
|
inherit (cfg) imports;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ in {
|
||||||
|
|
||||||
common = mkOption {
|
common = mkOption {
|
||||||
description = "List of common options to apply to tests";
|
description = "List of common options to apply to tests";
|
||||||
type = types.listOf (types.submodule ({ ...}: {
|
type = types.listOf (types.submodule (_: {
|
||||||
options = {
|
options = {
|
||||||
features = mkOption {
|
features = mkOption {
|
||||||
description = "List of features that test has to have to apply options";
|
description = "List of features that test has to have to apply options";
|
||||||
|
|
@ -70,7 +70,7 @@ in {
|
||||||
inherit module;
|
inherit module;
|
||||||
})
|
})
|
||||||
(types.submodule testModule));
|
(types.submodule testModule));
|
||||||
apply = tests: filter isTestEnabled tests;
|
apply = filter isTestEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
testsByName = mkOption {
|
testsByName = mkOption {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with import ../../lib/docker {inherit lib pkgs;}; let
|
with import ../../lib/docker {inherit lib pkgs;}; let
|
||||||
testing = config.testing;
|
inherit (config) testing;
|
||||||
|
|
||||||
allImages = unique (flatten (map (t: t.evaled.config.docker.export or []) testing.tests));
|
allImages = unique (flatten (map (t: t.evaled.config.docker.export or []) testing.tests));
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ in {
|
||||||
images = allImages;
|
images = allImages;
|
||||||
|
|
||||||
copyScript = copyDockerImages {
|
copyScript = copyDockerImages {
|
||||||
images = cfg.images;
|
inherit (cfg) images;
|
||||||
dest = "docker://" + cfg.registryUrl;
|
dest = "docker://" + cfg.registryUrl;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
testing = config.testing;
|
inherit (config) testing;
|
||||||
cfg = testing.driver.kubetest;
|
cfg = testing.driver.kubetest;
|
||||||
|
|
||||||
kubetest = import ./kubetestdrv.nix {inherit pkgs;};
|
kubetest = import ./kubetestdrv.nix {inherit pkgs;};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
testing = config.testing;
|
inherit (config) testing;
|
||||||
|
|
||||||
script = pkgs.writeScript "run-local-k8s-tests-${testing.name}.sh" ''
|
script = pkgs.writeScript "run-local-k8s-tests-${testing.name}.sh" ''
|
||||||
#!${pkgs.runtimeShell}
|
#!${pkgs.runtimeShell}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
testing = config.testing;
|
inherit (config) testing;
|
||||||
# kubeconfig = "/etc/${config.services.kubernetes.pki.etcClusterAdminKubeconfig}";
|
# kubeconfig = "/etc/${config.services.kubernetes.pki.etcClusterAdminKubeconfig}";
|
||||||
kubeconfig = "/etc/kubernetes/cluster-admin.kubeconfig";
|
kubeconfig = "/etc/kubernetes/cluster-admin.kubeconfig";
|
||||||
kubecerts = "/var/lib/kubernetes/secrets";
|
kubecerts = "/var/lib/kubernetes/secrets";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
{system ? builtins.currentSystem}: let
|
{system ? builtins.currentSystem}: (
|
||||||
in
|
|
||||||
(
|
|
||||||
(import ./compat.nix).flake-compat {
|
(import ./compat.nix).flake-compat {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@
|
||||||
doThrowError ? true, # whether any testing error should throw an error
|
doThrowError ? true, # whether any testing error should throw an error
|
||||||
enabledTests ? null,
|
enabledTests ? null,
|
||||||
}: let
|
}: let
|
||||||
config =
|
inherit ((evalModules {
|
||||||
(evalModules {
|
|
||||||
module = {
|
module = {
|
||||||
kubenix,
|
kubenix,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
|
@ -49,7 +48,6 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})) config;
|
||||||
.config;
|
|
||||||
in
|
in
|
||||||
config.testing // {recurseForDerivations = true;}
|
config.testing // {recurseForDerivations = true;}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
pod1 = config.kubernetes.api.resources.pods.pod1;
|
inherit (config.kubernetes.api.resources.pods) pod1;
|
||||||
pod2 = config.kubernetes.api.resources.pods.pod2;
|
inherit (config.kubernetes.api.resources.pods) pod2;
|
||||||
in {
|
in {
|
||||||
imports = with kubenix.modules; [test k8s];
|
imports = with kubenix.modules; [test k8s];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ with lib; let
|
||||||
apiVersion = "v1";
|
apiVersion = "v1";
|
||||||
kind = "Pod";
|
kind = "Pod";
|
||||||
metadata = {
|
metadata = {
|
||||||
namespace = config.kubernetes.namespace;
|
inherit (config.kubernetes) namespace;
|
||||||
name = "curl";
|
name = "curl";
|
||||||
};
|
};
|
||||||
spec.containers = [
|
spec.containers = [
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
instance1 = config.submodules.instances.instance1;
|
inherit (config.submodules.instances) instance1;
|
||||||
instance2 = config.submodules.instances.instance2;
|
inherit (config.submodules.instances) instance2;
|
||||||
instance3 = config.submodules.instances.instance3;
|
inherit (config.submodules.instances) instance3;
|
||||||
instance4 = config.submodules.instances.instance4;
|
inherit (config.submodules.instances) instance4;
|
||||||
instance5 = config.submodules.instances.instance5;
|
inherit (config.submodules.instances) instance5;
|
||||||
versioned-submodule = config.submodules.instances.versioned-submodule;
|
inherit (config.submodules.instances) versioned-submodule;
|
||||||
|
|
||||||
submodule = { ...}: {
|
submodule = { ...}: {
|
||||||
imports = [kubenix.modules.submodule];
|
imports = [kubenix.modules.submodule];
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.submodules.instances.instance;
|
cfg = config.submodules.instances.instance;
|
||||||
args = cfg.config.submodule.args;
|
inherit (cfg.config.submodule) args;
|
||||||
in {
|
in {
|
||||||
imports = with kubenix.modules; [test submodules];
|
imports = with kubenix.modules; [test submodules];
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ in {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
message = "should have tag set";
|
message = "should have tag set";
|
||||||
assertion = elem "tag" (cfg.config.submodule.tags);
|
assertion = elem "tag" cfg.config.submodule.tags;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue