Merge pull request #89748 from heinic/krb5-lists

This commit is contained in:
Jörg Thalheim 2020-09-03 07:31:22 +01:00 committed by GitHub
commit 02a2649220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 18 deletions

View File

@ -41,31 +41,30 @@ let
value) value)
else value; else value;
mkIndent = depth: concatStrings (builtins.genList (_: " ") (2 * depth)); indent = " ";
mkRelation = name: value: "${name} = ${mkVal { inherit value; }}"; mkRelation = name: value:
if (isList value) then
concatMapStringsSep "\n" (mkRelation name) value
else "${name} = ${mkVal value}";
mkVal = { value, depth ? 0 }: mkVal = value:
if (value == true) then "true" if (value == true) then "true"
else if (value == false) then "false" else if (value == false) then "false"
else if (isInt value) then (toString value) else if (isInt value) then (toString value)
else if (isList value) then
concatMapStringsSep " " mkVal { inherit value depth; }
else if (isAttrs value) then else if (isAttrs value) then
(concatStringsSep "\n${mkIndent (depth + 1)}" let configLines = concatLists
([ "{" ] ++ (mapAttrsToList (map (splitString "\n")
(attrName: attrValue: let (mapAttrsToList mkRelation value));
mappedAttrValue = mkVal { in
value = attrValue; (concatStringsSep "\n${indent}"
depth = depth + 1; ([ "{" ] ++ configLines))
}; + "\n}"
in "${attrName} = ${mappedAttrValue}")
value))) + "\n${mkIndent depth}}"
else value; else value;
mkMappedAttrsOrString = value: concatMapStringsSep "\n" mkMappedAttrsOrString = value: concatMapStringsSep "\n"
(line: if builtins.stringLength line > 0 (line: if builtins.stringLength line > 0
then "${mkIndent 1}${line}" then "${indent}${line}"
else line) else line)
(splitString "\n" (splitString "\n"
(if isAttrs value then (if isAttrs value then
@ -114,7 +113,10 @@ in {
{ {
"ATHENA.MIT.EDU" = { "ATHENA.MIT.EDU" = {
admin_server = "athena.mit.edu"; admin_server = "athena.mit.edu";
kdc = "athena.mit.edu"; kdc = [
"athena01.mit.edu"
"athena02.mit.edu"
];
}; };
}; };
''; '';

View File

@ -18,7 +18,10 @@ import ../make-test-python.nix ({ pkgs, ...} : {
realms = { realms = {
"ATHENA.MIT.EDU" = { "ATHENA.MIT.EDU" = {
admin_server = "athena.mit.edu"; admin_server = "athena.mit.edu";
kdc = "athena.mit.edu"; kdc = [
"athena01.mit.edu"
"athena02.mit.edu"
];
}; };
}; };
domain_realm = { domain_realm = {
@ -65,7 +68,8 @@ import ../make-test-python.nix ({ pkgs, ...} : {
[realms] [realms]
ATHENA.MIT.EDU = { ATHENA.MIT.EDU = {
admin_server = athena.mit.edu admin_server = athena.mit.edu
kdc = athena.mit.edu kdc = athena01.mit.edu
kdc = athena02.mit.edu
} }
[domain_realm] [domain_realm]