Class: TerraformWrapper::Tasks::Fmt

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Shared::Logging
Defined in:
lib/terraform-wrapper/tasks/fmt.rb

Instance Method Summary collapse

Methods included from Shared::Logging

configure_logger_for, logger_for

Constructor Details

#initialize(binary:, code:) {|_self| ... } ⇒ Fmt

Returns a new instance of Fmt.

Yields:

  • (_self)

Yield Parameters:



21
22
23
24
25
26
27
28
# File 'lib/terraform-wrapper/tasks/fmt.rb', line 21

def initialize(binary:, code:)
  @binary = binary
  @code   = code

  yield self if block_given?

  fmt_task
end

Instance Method Details

#fmt_taskObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/terraform-wrapper/tasks/fmt.rb', line 32

def fmt_task
  desc 'Manages the formatting of the Terraform code for an infrastructure component.'
  task :fmt, [:check] => :binary do |_t, args|
    args.with_defaults(check: true)

    runner = TerraformWrapper::Shared::Runner.new(binary: @binary, code: @code)

    logger.info("Fmt Terraform component: #{@code.name}...")

    runner.fmt(check: args[:check])
  end
end