Module: GClouder::Resources::Compute::ProjectInfo::SSHKeys::Local

Includes:
Config::Project, Logging
Defined in:
lib/gclouder/resources/compute/project_info/ssh_keys.rb

Class Method Summary collapse

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 Config::Project

load, #project, project

Methods included from Helpers

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

Class Method Details

.dataObject



83
84
85
86
87
88
89
90
91
92
# 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

.listObject



77
78
79
80
81
# File 'lib/gclouder/resources/compute/project_info/ssh_keys.rb', line 77

def self.list
  return [] unless project.key?("users")

  project["users"].sort
end

.validateObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# 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