Sha256: f85c295504fd25fabbcf7429f4883caa8f5d47c62b87881e21728ba1bbc8f855

Contents?: true

Size: 921 Bytes

Versions: 2

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

# takelage info status ssh
module InfoStatusSSH
  # Backend method for info status ssh.
  # @return [Boolean] is ssh available?
  # rubocop:disable Metrics/MethodLength
  def info_status_ssh
    log.debug 'Check ssh status'

    ssh_socket_path = _socket_get_agent_ssh_socket_path

    unless ENV['SSH_AUTH_SOCK'] == ssh_socket_path
      log.error 'gpg ssh socket is misconfigured'
      return false
    end

    unless _file_exists? ssh_socket_path
      log.error 'gpg ssh socket is not available'
      return false
    end

    unless _info_status_ssh_keys
      log.error 'ssh keys are not available'
      return false
    end

    log.debug 'ssh is available'
    true
  end
  # rubocop:enable Metrics/MethodLength

  private

  # Check ssh keys
  def _info_status_ssh_keys
    status_keys = try config.active['cmd_info_status_ssh_keys']
    status_keys.exitstatus.zero?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
takelage-0.26.3 lib/takelage/info/status/ssh.rb
takelage-0.26.2 lib/takelage/info/status/ssh.rb