module GClouder::Resources::Compute::ProjectInfo::SSHKeys::Local

Public Class Methods

data() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 83
def self.data
  list.map do |line|
    components = line.split
    user, type = components[0].split(":")
    key = components[1]
    description = components.length >= 2 ? components[2] : components[0]

    { key: key, type: type, user: user, description: description }
  end
end
list() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 77
def self.list
  return [] unless project.key?("users")

  project["users"].sort
end
validate() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 94
def self.validate
  return if data.empty?

  info "global", heading: true, indent: 2

  data.each do |entry|
    info
    info entry[:description], indent: 3

    if entry[:user].is_a?(String)
      good "user is a String (#{entry[:user]})", indent: 4
    else
      bad "user is a String (#{entry[:user]})", indent: 4
    end

    if entry[:key].is_a?(String)
      good "key is a String (#{entry[:key].reverse.truncate(20).reverse})", indent: 4
    else
      bad "key isn't a String (#{entry[:key]})", indent: 4
    end

    if entry[:type].is_a?(String)
      good "type is a String (#{entry[:type]})", indent: 4
    else
      bad "type isn't a String (#{entry[:type]})", indent: 4
    end

    # check if description exists for key
    # output useruser
    # output key.truncate
    # output description
  end
end