Module: GClouder::Resources::Compute::ProjectInfo::SSHKeys::Remote

Includes:
GCloud
Defined in:
lib/gclouder/resources/compute/project_info/ssh_keys.rb

Class Method Summary collapse

Methods included from GCloud

#gcloud, included, #verify

Methods included from Config::CLIArgs

check, #cli_args, cli_args, included, load, valid_resources

Methods included from Config::Project

load, #project, project

Methods included from Helpers

#hash_to_args, included, #module_exists?, #to_arg, #to_deep_merge_hash, #valid_json?

Methods included from Logging

#add, #bad, #change, #debug, #error, #fatal, #good, included, #info, log, loggers, #remove, report, #resource_state, setup, #warn, #warning

Methods included from Shell

included, #shell

Class Method Details

.dataObject



142
143
144
145
146
147
148
149
150
151
# File 'lib/gclouder/resources/compute/project_info/ssh_keys.rb', line 142

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

.listObject



132
133
134
135
136
137
138
139
140
# File 'lib/gclouder/resources/compute/project_info/ssh_keys.rb', line 132

def self.list
  keys = .dig("items")

  return [] unless keys
  return [] if keys.empty?

  keys.delete_if { |h| h["key"] != "sshKeys" }
  keys[0]["value"].split("\n").delete_if { |key| key =~ /^gke-/ }.sort
end

.metadataObject



153
154
155
# File 'lib/gclouder/resources/compute/project_info/ssh_keys.rb', line 153

def self.
  gcloud("compute project-info describe | jq -r '.commonInstanceMetadata'", force: true)
end