Merge pull request #120209 from considerate/considerate/multiple-tags-buildkite-agents

services.buildkite-agents: support multi-tags
This commit is contained in:
Luke Granger-Brown 2021-05-01 19:07:56 +01:00 committed by GitHub
commit 152fa5414c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,7 +76,7 @@ let
}; };
tags = mkOption { tags = mkOption {
type = types.attrsOf types.str; type = types.attrsOf (types.either types.str (types.listOf types.str));
default = {}; default = {};
example = { queue = "default"; docker = "true"; ruby2 ="true"; }; example = { queue = "default"; docker = "true"; ruby2 ="true"; };
description = '' description = ''
@ -230,7 +230,11 @@ in
## don't end up in the Nix store. ## don't end up in the Nix store.
preStart = let preStart = let
sshDir = "${cfg.dataDir}/.ssh"; sshDir = "${cfg.dataDir}/.ssh";
tagStr = lib.concatStringsSep "," (lib.mapAttrsToList (name: value: "${name}=${value}") cfg.tags); tagStr = name: value:
if lib.isList value
then lib.concatStringsSep "," (builtins.map (v: "${name}=${v}") value)
else "${name}=${value}";
tagsStr = lib.concatStringsSep "," (lib.mapAttrsToList tagStr cfg.tags);
in in
optionalString (cfg.privateSshKeyPath != null) '' optionalString (cfg.privateSshKeyPath != null) ''
mkdir -m 0700 -p "${sshDir}" mkdir -m 0700 -p "${sshDir}"
@ -241,7 +245,7 @@ in
token="$(cat ${toString cfg.tokenPath})" token="$(cat ${toString cfg.tokenPath})"
name="${cfg.name}" name="${cfg.name}"
shell="${cfg.shell}" shell="${cfg.shell}"
tags="${tagStr}" tags="${tagsStr}"
build-path="${cfg.dataDir}/builds" build-path="${cfg.dataDir}/builds"
hooks-path="${cfg.hooksPath}" hooks-path="${cfg.hooksPath}"
${cfg.extraConfig} ${cfg.extraConfig}