diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-01-22 13:59:17 +0000 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-02-15 14:49:33 +0000 |
commit | 786286638d1f2bb300246400010adcd32bb047d3 (patch) | |
tree | 9d80cb1e95a13391912583f9a66f65ddf3379973 | |
parent | 94f18dc4b7bc95f56f0779a467ba88ac9ee3eba0 (diff) | |
download | gitano-786286638d1f2bb300246400010adcd32bb047d3.tar.gz |
Fix some indentation in usercommand
-rw-r--r-- | lib/gitano/usercommand.lua | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/lib/gitano/usercommand.lua b/lib/gitano/usercommand.lua index 49e66dd..3c8b467 100644 --- a/lib/gitano/usercommand.lua +++ b/lib/gitano/usercommand.lua @@ -169,50 +169,55 @@ local function builtin_sshkey_run(conf, _, cmdline, env) local utab = conf.users[env.GITANO_USER] if cmdline[2] == "list" then if not next(utab.keys) then - log.warn("There are no SSH keys registered for", env.GITANO_USER .. ", sorry") + log.warn("There are no SSH keys registered for", env.GITANO_USER + .. ", sorry") else - local pfx = " SSH key:" - for tagname, keydata in pairs(utab.keys) do - local suffix = (env.GITANO_KEYTAG == tagname) and " [*]" or "" - log.state(pfx, tagname, "=>", keydata.keytag .. suffix) - pfx = " " - end + local pfx = " SSH key:" + for tagname, keydata in pairs(utab.keys) do + local suffix = (env.GITANO_KEYTAG == tagname) and " [*]" or "" + log.state(pfx, tagname, "=>", keydata.keytag .. suffix) + pfx = " " + end end elseif cmdline[2] == "add" then local sshkey = sio.stdin:read("*l") local keytype, keydata, keytag = sshkey:match("^([^ ]+) ([^ ]+) ([^ ].*)$") if not (keytype and keydata and keytag) then - log.error("Unable to parse key,", filename, - "did not smell like an OpenSSH v2 key") - return "exit", 1 + log.error("Unable to parse key,", filename, + "did not smell like an OpenSSH v2 key") + return "exit", 1 end + if (keytype ~= "ssh-rsa") and (keytype ~= "ssh-dss") and - (keytype ~= "ecdsa-sha2-nistp256") and - (keytype ~= "ecdsa-sha2-nistp384") and - (keytype ~= "ecdsa-sha2-nistp521") then - log.error("Unknown key type", keytype) - return "exit", 1 + (keytype ~= "ecdsa-sha2-nistp256") and + (keytype ~= "ecdsa-sha2-nistp384") and + (keytype ~= "ecdsa-sha2-nistp521") then + log.error("Unknown key type", keytype) + return "exit", 1 end + local keytab = { - data = sshkey, - keyname = cmdline[3], - username = env.GITANO_USER, - keytag = keytag, + data = sshkey, + keyname = cmdline[3], + username = env.GITANO_USER, + keytag = keytag, } + utab.keys[cmdline[3]] = keytab - elseif cmdline[2] == "del" then utab.keys[cmdline[3]] = nil end if cmdline[2] ~= "list" then -- Store the config back. + local action = (cmdline[2] == "add") and "Added" or "Deleted" action = action .. " " .. cmdline[3] .. " for " .. env.GITANO_USER local ok, msg = config.commit(conf, action, env.GITANO_USER) + if not ok then - log.error(msg) - return "exit", 1 + log.error(msg) + return "exit", 1 end end |