Module: GClouder::Resource::Cleaner
- Included in:
- GClouder::Resources::Compute::Addresses, GClouder::Resources::Compute::BGPVPNs, GClouder::Resources::Compute::BackendBuckets, GClouder::Resources::Compute::Disks, GClouder::Resources::Compute::FirewallRules, GClouder::Resources::Compute::ForwardingRules, GClouder::Resources::Compute::Networks, GClouder::Resources::Compute::Networks::Subnets, GClouder::Resources::Compute::Routers, GClouder::Resources::Compute::TargetHTTPSProxies, GClouder::Resources::Compute::URLMaps, GClouder::Resources::Compute::VPNs, GClouder::Resources::Container::Clusters, GClouder::Resources::Functions::Function, GClouder::Resources::Logging::Sinks, GClouder::Resources::PubSub::Subscriptions, GClouder::Resources::PubSub::Topics, GClouder::Resources::RuntimeConfig::Configs, GClouder::Resources::RuntimeConfig::Variables, GClouder::Resources::Storage::Buckets
- Defined in:
- lib/gclouder/resource_cleaner.rb
Defined Under Namespace
Modules: Default
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
6 7 8 |
# File 'lib/gclouder/resource_cleaner.rb', line 6 def self.included(klass) klass.extend Cleaner end |
Instance Method Details
#clean ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gclouder/resource_cleaner.rb', line 10 def clean return if undefined.empty? header :clean undefined.each do |namespace, resources| info namespace, indent: 2, heading: true info resources.each do |resource| = resource['name'] += " (not defined locally)" warning # FIXME: enable purge on --purge flag.. #Resource.symlink.send(:purge, namespace, resource) end end end |
#cleaner ⇒ Object
39 40 41 |
# File 'lib/gclouder/resource_cleaner.rb', line 39 def cleaner (self.const_defined?(:Cleaner) && self::Cleaner.respond_to?(:custom)) ? self::Cleaner.custom : Default.cleaner end |
#undefined ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gclouder/resource_cleaner.rb', line 43 def undefined self::Remote.list.each_with_object({}) do |(namespace, resources), collection| resources.each do |resource| namespace_resources = self::Local.list[namespace] # accept PROC for custom matching of undefined resources next if namespace_resources && cleaner.call(namespace_resources, resource["name"]) collection[namespace] ||= [] collection[namespace] << resource end end end |