Sha256: 917f2d9d4b15ff9daaa2e8a49c2da3ca76912f12ef53ec2acaffc5f83c6e529a

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 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(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

1 entries across 1 versions & 1 rubygems

Version Path
ruby-terraform-0.65.0.pre.9 lib/ruby_terraform/commands/clean.rb