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