Commit 1d180b7a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

GitlabConfig. Fixed adding key

parent 451b4a64
require 'yaml'
class GitlabConfig
attr_reader :config
def initialize
@config = YAML.load_file(File.join(ROOT_PATH, 'config.yml'))
end
def repos_path
@config['repos_path'] = "/home/git/repositories"
end
def auth_file
@config['auth_file'] = "/home/git/.ssh/authorized_keys"
end
end
require 'open3'
require 'yaml'
require_relative 'gitlab_config'
class GitlabKeys
attr_accessor :auth_file, :key, :username
......@@ -8,9 +8,7 @@ class GitlabKeys
@command = ARGV.shift
@username = ARGV.shift
@key = ARGV.shift
config = YAML.load_file(File.join(ROOT_PATH, 'config.yml'))
@auth_file = config['auth_file']
@auth_file = GitlabConfig.new.auth_file
end
def exec
......@@ -27,7 +25,7 @@ class GitlabKeys
def add_key
cmd = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{@username}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{@key}"
cmd = "echo \"#{cmd}\" >> #{auth_file}"
cmd = "echo \'#{cmd}\' >> #{auth_file}"
system(cmd)
end
......
require 'open3'
require 'yaml'
require_relative 'gitlab_config'
class GitlabShell
attr_accessor :username, :repo_name, :git_cmd, :repos_path
......@@ -7,8 +7,7 @@ class GitlabShell
def initialize
@username = ARGV.shift
@origin_cmd = ENV['SSH_ORIGINAL_COMMAND']
@config = YAML.load_file(File.join(ROOT_PATH, 'config.yml'))
@repos_path = @config['repos_path']
@repos_path = GitlabConfig.new.repos_path
end
def exec
......
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