Sha256: a1942e8460c25aa10845d6b653a3384b9b85870d1a5117d567b37f98a72d9650

Contents?: true

Size: 673 Bytes

Versions: 6

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

require 'fileutils'

module RubyTerraform
  module Commands
    class Clean
      attr_reader :logger

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

      def execute(parameters = {})
        directory = parameters[: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

6 entries across 6 versions & 1 rubygems

Version Path
ruby-terraform-0.65.0.pre.15 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.65.0.pre.14 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.65.0.pre.13 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.65.0.pre.12 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.65.0.pre.11 lib/ruby_terraform/commands/clean.rb
ruby-terraform-0.65.0.pre.10 lib/ruby_terraform/commands/clean.rb