Sha256: a346c20e442c0ffd15d184d026f8978d7bb62ca113425049426e6b329a2ff020

Contents?: true

Size: 644 Bytes

Versions: 34

Compression:

Stored size: 644 Bytes

Contents

require 'fileutils'

module RubyTerraform
  module Commands
    class Clean
      attr_reader :logger

      def initialize(directory: nil, logger: nil)
        @directory = directory ? directory : '.terraform'
        @logger = logger || RubyTerraform.configuration.logger
      end

      def execute(opts = {})
        directory = opts[:directory] || @directory
        begin
          logger.info "Cleaning terraform directory '#{directory}'."
          FileUtils.rm_r(directory, :secure => true)
        rescue Errno::ENOENT => e
          logger.error "Couldn't clean '#{directory}': #{e.message}"
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
ruby-terraform-0.65.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.64.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.63.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.62.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.61.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.60.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.59.0.pre.2 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.59.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.58.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.57.0.pre.2 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.57.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.56.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.55.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.54.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.53.0.pre.2 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.53.0.pre.1 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.52.0 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.51.0.pre.3 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.51.0.pre.2 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.51.0.pre.1 lib/ruby_terraform/commands/clean.rb