Class: Shipitron::Server::Git::Configure

Inherits:
Object
  • Object
show all
Includes:
Metaractor, ConsulKeys
Defined in:
lib/shipitron/server/git/configure.rb

Instance Method Summary collapse

Methods included from ConsulKeys

#configure_consul_client!, #fetch_key, #fetch_key!, #set_key, #set_key!

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/shipitron/server/git/configure.rb', line 19

def call
  host_key = begin
               key = fetch_key(key: "shipitron/#{application}/git_host_key")
               key = fetch_key!(key: 'shipitron/git_host_key') if key.nil?
               key
             end
  Pathname.new('/home/shipitron/.ssh/known_hosts').open('a') do |file|
    file.puts(host_key.to_s)
  end

  deploy_key = begin
                 key = fetch_key(key: "shipitron/#{application}/git_deploy_key")
                 key = fetch_key!(key: 'shipitron/git_deploy_key') if key.nil?
                 key
               end
  Pathname.new('/home/shipitron/.ssh/id_rsa').open('w') do |file|
    file.puts(deploy_key.to_s)
    file.chmod(0600)
  end
end