Class: Evrone::CI::CSM::Git::GitSSH
- Inherits:
-
Object
- Object
- Evrone::CI::CSM::Git::GitSSH
- Includes:
- Evrone::CI::Common::Helper::Shell
- Defined in:
- lib/evrone/ci/csm/git/git_ssh.rb
Instance Attribute Summary collapse
-
#deploy_key ⇒ Object
readonly
Returns the value of attribute deploy_key.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(deploy_key) ⇒ GitSSH
constructor
A new instance of GitSSH.
- #key_location ⇒ Object
- #location ⇒ Object
- #open ⇒ Object
- #template ⇒ Object
Constructor Details
#initialize(deploy_key) ⇒ GitSSH
Returns a new instance of GitSSH.
13 14 15 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 13 def initialize(deploy_key) @deploy_key = deploy_key end |
Instance Attribute Details
#deploy_key ⇒ Object (readonly)
Returns the value of attribute deploy_key.
11 12 13 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 11 def deploy_key @deploy_key end |
Instance Method Details
#create ⇒ Object
25 26 27 28 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 25 def create key_location location end |
#destroy ⇒ Object
30 31 32 33 34 35 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 30 def destroy key_location.unlink if key_location location.unlink @location = nil @key_location = nil end |
#key_location ⇒ Object
41 42 43 44 45 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 41 def key_location if deploy_key @key_location ||= write_tmp_file 'key', deploy_key, 0600 end end |
#location ⇒ Object
37 38 39 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 37 def location @location ||= write_tmp_file 'git', template, 0700 end |
#open ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 17 def open begin yield create ensure destroy end end |
#template ⇒ Object
47 48 49 50 51 52 |
# File 'lib/evrone/ci/csm/git/git_ssh.rb', line 47 def template key = key_location ? "-i #{key_location.path}" : "" out = ['#!/bin/sh'] out << "exec /usr/bin/ssh -A -o StrictHostKeyChecking=no #{key} $@" out.join "\n" end |