mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
feat(k8s): allow to expose with api alias
This commit is contained in:
parent
9cd6a67c5e
commit
978ada4312
1 changed files with 61 additions and 37 deletions
|
|
@ -109,34 +109,9 @@ let
|
|||
|
||||
indexOf = lst: value:
|
||||
head (filter (v: v != -1) (imap0 (i: v: if v == value then i else -1) lst));
|
||||
in {
|
||||
# expose k8s helper methods as module argument
|
||||
config._module.args.k8s = import ../lib/k8s.nix { inherit lib; };
|
||||
|
||||
options.kubernetes.version = mkOption {
|
||||
description = "Kubernetes version to use";
|
||||
type = types.enum ["1.7" "1.8" "1.9" "1.10" "1.11" "1.12" "1.13"];
|
||||
default = "1.13";
|
||||
};
|
||||
|
||||
options.kubernetes.resourceOrder = mkOption {
|
||||
description = "Preffered resource order";
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
"CustomResourceDefinition"
|
||||
"Namespace"
|
||||
];
|
||||
};
|
||||
|
||||
options.kubernetes.api = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
(./generated + ''/v'' + cfg.version + ".nix")
|
||||
apiOptions
|
||||
] ++ (map (cr: {config, ...}: {
|
||||
options.${cr.group}.${cr.version}.${cr.kind} = mkOption {
|
||||
description = cr.description;
|
||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||
customResourceModules = map (cr: {config, ...}: let
|
||||
module = {name, ...}: {
|
||||
imports = getDefaults cr.resource cr.group cr.version cr.kind;
|
||||
options = {
|
||||
apiVersion = mkOption {
|
||||
|
|
@ -166,10 +141,53 @@ in {
|
|||
kind = mkOptionDefault cr.kind;
|
||||
metadata.name = mkOptionDefault name;
|
||||
};
|
||||
}));
|
||||
};
|
||||
in if cr.alias != null then {
|
||||
options.${cr.group}.${cr.version}.${cr.kind} = mkOption {
|
||||
description = cr.description;
|
||||
type = types.attrsOf (types.submodule module);
|
||||
default = {};
|
||||
};
|
||||
}) cfg.customResources);
|
||||
|
||||
options.${cr.alias} = mkOption {
|
||||
description = cr.description;
|
||||
type = types.attrsOf (types.submodule module);
|
||||
default = {};
|
||||
};
|
||||
|
||||
config.${cr.group}.${cr.version}.${cr.kind} = config.${cr.alias};
|
||||
} else {
|
||||
options.${cr.group}.${cr.version}.${cr.kind} = mkOption {
|
||||
description = cr.description;
|
||||
type = types.attrsOf (types.submodule module);
|
||||
default = {};
|
||||
};
|
||||
}) cfg.customResources;
|
||||
in {
|
||||
# expose k8s helper methods as module argument
|
||||
config._module.args.k8s = import ../lib/k8s.nix { inherit lib; };
|
||||
|
||||
options.kubernetes.version = mkOption {
|
||||
description = "Kubernetes version to use";
|
||||
type = types.enum ["1.7" "1.8" "1.9" "1.10" "1.11" "1.12" "1.13"];
|
||||
default = "1.13";
|
||||
};
|
||||
|
||||
options.kubernetes.resourceOrder = mkOption {
|
||||
description = "Preffered resource order";
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
"CustomResourceDefinition"
|
||||
"Namespace"
|
||||
];
|
||||
};
|
||||
|
||||
options.kubernetes.api = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
(./generated + ''/v'' + cfg.version + ".nix")
|
||||
apiOptions
|
||||
] ++ customResourceModules;
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
|
|
@ -210,6 +228,12 @@ in {
|
|||
description = "Custom resource definition module";
|
||||
default = types.unspecified;
|
||||
};
|
||||
|
||||
alias = mkOption {
|
||||
description = "Alias to create for API";
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue