Sha256: 06cacaa581070aee5ce3d2ee8df5b2d2d67da159ef8a5c7fd45934d6b4e05313

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

module GitSafe
  module PrivateKeyFile
    def ssh_cmd
      return '' unless ssh_private_key_file_path
      "GIT_SSH_COMMAND=\"ssh -i #{ssh_private_key_file_path} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\" "
    end

    def ssh_private_key_file_path
      return unless ssh_private_key

      if File.exist?(ssh_private_key)
        logger.info('ssh_private_key key is a file')
        ssh_private_key
      else
        logger.info('ssh_private_key key is a string')
        ssh_tempfile.private_key_temp_file.path
      end
    end

    def ssh_tempfile
      @ssh_tempfile ||= SshTempfile.new(ssh_private_key)
    end

    def safe_unlink_private_key_tmp_file
      ssh_tempfile&.safe_unlink_private_key_tmp_file
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-safe-0.3.0 lib/git-safe/private_key_file.rb
git-safe-0.2.0 lib/git-safe/private_key_file.rb
git-safe-0.1.0 lib/git-safe/private_key_file.rb