mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
feat(submodules): allow to match modules by version regex
This commit is contained in:
parent
5a7eefc489
commit
fc3ba14b5c
3 changed files with 83 additions and 6 deletions
|
|
@ -92,12 +92,14 @@ let
|
|||
parentConfig = config;
|
||||
};
|
||||
|
||||
findModule = {name, version ? null, latest ? true}: let
|
||||
versionPrefix = head (splitString [".x"] version);
|
||||
|
||||
findSubmodule = {name, version ? null, latest ? true}: let
|
||||
matchingSubmodules = filter (el:
|
||||
el.definition.name == name &&
|
||||
(if version != null then hasPrefix versionPrefix el.definition.version else true)
|
||||
(if version != null then
|
||||
if hasPrefix "~" version
|
||||
then (builtins.match (removePrefix "~" version) el.definition.version) != null
|
||||
else el.definition.version == version
|
||||
else true)
|
||||
) cfg.imports;
|
||||
|
||||
versionSortedSubmodules = sort (s1: s2:
|
||||
|
|
@ -191,7 +193,7 @@ in {
|
|||
description = "Attribute set of submodule instances";
|
||||
type = types.attrsOf (types.submodule ({name, config, ...}: let
|
||||
# submodule associated with
|
||||
submodule = findModule {
|
||||
submodule = findSubmodule {
|
||||
name = config.submodule;
|
||||
version = config.version;
|
||||
};
|
||||
|
|
@ -216,7 +218,10 @@ in {
|
|||
};
|
||||
|
||||
version = mkOption {
|
||||
description = "Version of submodule to use";
|
||||
description = ''
|
||||
Version of submodule to use, if version starts with "~" it is
|
||||
threated as regex pattern for example "~1.0.*"
|
||||
'';
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue