summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab_config.rb17
-rw-r--r--lib/gitlab_keys.rb8
-rw-r--r--lib/gitlab_shell.rb5
3 files changed, 22 insertions, 8 deletions
diff --git a/lib/gitlab_config.rb b/lib/gitlab_config.rb
new file mode 100644
index 0000000..aa20d6e
--- /dev/null
+++ b/lib/gitlab_config.rb
@@ -0,0 +1,17 @@
+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
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 3612bca..7eae17c 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -1,5 +1,5 @@
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
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 93acc57..32ee2ac 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -1,5 +1,5 @@
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