summaryrefslogtreecommitdiff
path: root/lib/gitlab_keys.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-10 09:02:34 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-10 09:02:34 -0700
commit79c58482962bd7ddd4979a4afcd178f697fe84fa (patch)
treeb39538ed8086aa229ee68dddfd9436d0dcab65c0 /lib/gitlab_keys.rb
parent45881f17d06c860c8fe6a0b0441a847a63b75783 (diff)
parent45b3a3a7cda1296682a2054abf89c95a55c78f0f (diff)
downloadgitlab-shell-79c58482962bd7ddd4979a4afcd178f697fe84fa.tar.gz
Merge pull request #56 from smashwilson/36-logger
Logger
Diffstat (limited to 'lib/gitlab_keys.rb')
-rw-r--r--lib/gitlab_keys.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 7e6362a..03026ed 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -1,6 +1,7 @@
require 'open3'
require_relative 'gitlab_config'
+require_relative 'gitlab_logger'
class GitlabKeys
attr_accessor :auth_file, :key
@@ -17,6 +18,7 @@ class GitlabKeys
when 'add-key'; add_key
when 'rm-key'; rm_key
else
+ $logger.warn "Attempt to execute invalid gitlab-keys command #{@command.inspect}."
puts 'not allowed'
false
end
@@ -25,12 +27,14 @@ class GitlabKeys
protected
def add_key
+ $logger.info "Adding key #{@key_id} => #{@key.inspect}"
cmd = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{@key_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{@key}"
cmd = "echo \'#{cmd}\' >> #{auth_file}"
system(cmd)
end
def rm_key
+ $logger.info "Removing key #{@key_id}"
cmd = "sed -i '/shell #{@key_id}\"/d' #{auth_file}"
system(cmd)
end