Commit bde689a8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Generate key_line in separate method

parent 9e076ab2
...@@ -29,11 +29,15 @@ class GitlabKeys ...@@ -29,11 +29,15 @@ class GitlabKeys
def add_key def add_key
$logger.info "Adding key #{@key_id} => #{@key.inspect}" $logger.info "Adding key #{@key_id} => #{@key.inspect}"
auth_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{@key_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{@key}" auth_line = key_line(@key_id, @key)
open(auth_file, 'a') { |file| file.puts(auth_line) } open(auth_file, 'a') { |file| file.puts(auth_line) }
true true
end end
def key_line(key_id, public_key)
auth_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{key_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{public_key}"
end
def rm_key def rm_key
$logger.info "Removing key #{@key_id}" $logger.info "Removing key #{@key_id}"
Tempfile.open('authorized_keys') do |temp| Tempfile.open('authorized_keys') do |temp|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment