1
0
Fork 0
mirror of https://cgit.krebsco.de/krops synced 2024-12-23 10:19:52 +01:00

Merge pull request #19 from erikarvstedt/improve-target-opts

Improve deploy target options
This commit is contained in:
tv 2020-04-19 01:06:20 +02:00 committed by GitHub
commit 55aa2c77ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View file

@ -43,16 +43,22 @@ let {
lib.elem target.host [origin.host "localhost"]; lib.elem target.host [origin.host "localhost"];
mkTarget = s: let mkTarget = s: let
default = defVal: val: if val != null then val else defVal;
parse = lib.match "(([^@]*)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s; parse = lib.match "(([^@]*)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;
elemAt' = xs: i: if lib.length xs > i then lib.elemAt xs i else null; elemAt' = xs: i: if lib.length xs > i then lib.elemAt xs i else null;
in if lib.isString s then { filterNull = lib.filterAttrs (n: v: v != null);
user = default (lib.getEnv "LOGNAME") (elemAt' parse 1); in {
host = default (lib.maybeEnv "HOSTNAME" lib.getHostName) (elemAt' parse 3); user = lib.getEnv "LOGNAME";
port = default "22" /* "ssh"? */ (elemAt' parse 5); host = lib.maybeEnv "HOSTNAME" lib.getHostName;
path = default "/var/src" /* no default? */ (elemAt' parse 6); port = "22";
path = "/var/src";
sudo = false; sudo = false;
} else s; extraOptions = [];
} // (if lib.isString s then filterNull {
user = elemAt' parse 1;
host = elemAt' parse 3;
port = elemAt' parse 5;
path = elemAt' parse 6;
} else s);
shell = let shell = let
isSafeChar = lib.testString "[-+./0-9:=A-Z_a-z]"; isSafeChar = lib.testString "[-+./0-9:=A-Z_a-z]";

View file

@ -23,6 +23,7 @@ in
(lib.optionals (target.user != "") ["-l" target.user]) (lib.optionals (target.user != "") ["-l" target.user])
"-p" target.port "-p" target.port
"-t" "-t"
target.extraOptions
target.host target.host
(if target.sudo then "sudo ${command}" else command)])} (if target.sudo then "sudo ${command}" else command)])}
''; '';

View file

@ -194,6 +194,7 @@ let
"-o" "ControlPersist=no" "-o" "ControlPersist=no"
"-p" target.port "-p" target.port
"-T" "-T"
target.extraOptions
]); ]);
in in