lib/heirloom/cli/teardown.rb in heirloom-0.11.0 vs lib/heirloom/cli/teardown.rb in heirloom-0.11.1

- old
+ new

@@ -2,10 +2,14 @@ module CLI class Teardown include Heirloom::CLI::Shared + def self.command_summary + 'Teardown S3 buckets and SimpleDB domain for Heirloom name' + end + def initialize @opts = read_options @logger = HeirloomLogger.new :log_level => @opts[:level] @config = load_config :logger => @logger, :opts => @opts @@ -25,22 +29,27 @@ :catalog => @catalog, :entry => @opts[:name] end def teardown - ensure_domain_exists :name => @opts[:name], - :config => @config + ensure_domain_exists :name => @opts[:name], :config => @config - ensure_archive_domain_empty :archive => @archive, - :config => @config + if @opts[:force] + Heirloom.log.info "Removing any existing archives..." + @catalog.cleanup :num_to_keep => 0, :remove_preserved => true + else + ensure_archive_domain_empty( + :archive => @archive, + :config => @config + ) + end - @regions = @catalog.regions - @bucket_prefix = @catalog.bucket_prefix - unless @opts[:keep_buckets] - @archive.delete_buckets :regions => @regions, - :bucket_prefix => @bucket_prefix + @archive.delete_buckets( + :regions => @catalog.regions, + :bucket_prefix => @catalog.bucket_prefix + ) end @archive.delete_domain @catalog.delete_from_catalog end @@ -50,11 +59,11 @@ def read_options Trollop::options do version Heirloom::VERSION banner <<-EOS -Teardown S3 buckets and SimpleDB domain for a given Heirloom name. +#{Teardown.command_summary}. Usage: heirloom teardown -n NAME @@ -65,9 +74,10 @@ opt :level, "Log level [debug|info|warn|error].", :type => :string, :default => 'info' opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string, :default => 'us-west-1' opt :name, "Name of Heirloom.", :type => :string + opt :force, "Forces recursive deletion of existing archives." opt :keep_buckets, "Do not delete S3 buckets." opt :aws_access_key, "AWS Access Key ID", :type => :string, :short => :none opt :aws_secret_key, "AWS Secret Access Key", :type => :string, :short => :none