Module: GClouder::Resources::Storage::Buckets::Remote

Includes:
GSUtil
Defined in:
lib/gclouder/resources/storage/buckets.rb

Class Method Summary collapse

Methods included from GSUtil

#gsutil, #gsutil_exec, included

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

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

Methods included from Shell

included, #shell

Class Method Details

.listObject

FIXME: make more robust(!)



62
63
64
65
66
67
68
69
70
# File 'lib/gclouder/resources/storage/buckets.rb', line 62

def self.list
  gsutil("ls", "-p #{project['project_id']} -L").to_s.split("gs://").delete_if(&:empty?).each_with_object({}) do |data, collection|
    normalized = data.split("\n").map! { |b| b.delete("\t") }
    bucket_name = normalized[0].delete("/ :")
    region = normalized.select { |e| e.match("^Location constraint:") }.last.split(":").last.downcase
    collection[region] ||= []
    collection[region] << { "name" => bucket_name }
  end
end