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

Public Class Methods

check() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 21
def self.check
end
clean() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 16
def self.clean
  return unless project.key?("users")
  header :clean
end
ensure() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 30
def self.ensure
  return unless project.key?("users")
  header :ensure

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

  Local.data.each do |user_data|
    description = user_data[:description]

    user = Remote.data.find { |entry| entry[:description] == description }

    # user doesn't exist, add it..
    if user.nil?
      add description
      next
    end

    # user exists but has been modified
    if user_data[:key] != user[:key]
      change description
      next
    end

    # user exists and is the same
    good description
  end

  Remote.data.each do |user_data|
    description = user_data[:description]

    next if Local.data.find { |entry| entry[:description] == description }

    # user isn't defined locally, remove it
    remove description, indent: 3
  end

  return if Local.list == Remote.list
  return if cli_args[:dry_run]

  Key.ensure(Local.list)
end
header(stage = :ensure) click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 12
def self.header(stage = :ensure)
  info "[#{stage}] compute / metadata / ssh_keys", title: true
end
validate() click to toggle source
# File lib/gclouder/resources/compute/project_info/ssh_keys.rb, line 24
def self.validate
  return if Local.data.empty?
  header :validate
  Local.validate
end