module GClouderUndefinedResources

Constants

VERSION

Public Class Methods

run() click to toggle source
# File lib/gclouder_undefined_resources.rb, line 19
def self.run
  CLIArgs.load

  authenticate(CLIArgs.cli_args[:key_file]) if CLIArgs.cli_args[:key_file_given]

  undefined
end

Private Class Methods

authenticate(key_file) click to toggle source
# File lib/gclouder_undefined_resources.rb, line 33
def self.authenticate(key_file)
  set_project_id
  Shell.run("gcloud --quiet auth activate-service-account --key-file #{key_file}")
end
local_resources() click to toggle source
# File lib/gclouder_undefined_resources.rb, line 38
def self.local_resources
  @local_resources ||= LocalResources.new(CLIArgs.cli_args[:local_resources])
end
set_project_id() click to toggle source
# File lib/gclouder_undefined_resources.rb, line 29
def self.set_project_id
  Shell.run("gcloud config set core/project #{local_resources['project_id']}")
end
undefined() click to toggle source
# File lib/gclouder_undefined_resources.rb, line 42
def self.undefined
  remote_resources = RemoteResources.new(local_resources["project_id"])
  remote_resources.collect

  case CLIArgs.cli_args[:group_by].to_sym
  when :location
    remote_resources.display_by_location
  when :type
    remote_resources.display_by_type
  else
    puts "unknown group-by type"
  end

  remote_resources.display_report unless CLIArgs.cli_args[:hide_report]

  exit 1 if remote_resources.any_undefined_and_unfiltered?
end