Class: Ruby::Terraform::Commands::InitCommand

Inherits:
Object
  • Object
show all
Includes:
ExecutionSupport
Defined in:
lib/ruby/terraform/commands/init_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ExecutionSupport

#execute, #tf_binary

Constructor Details

#initialize(opts = {}) ⇒ InitCommand

Returns a new instance of InitCommand.



11
12
13
14
15
# File 'lib/ruby/terraform/commands/init_command.rb', line 11

def initialize(opts = {})
  @dir = opts[:dir]
  @backend = opts[:backend]
  @backend_config = opts[:backend_config]
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



8
9
10
# File 'lib/ruby/terraform/commands/init_command.rb', line 8

def backend
  @backend
end

#backend_configObject

Returns the value of attribute backend_config.



9
10
11
# File 'lib/ruby/terraform/commands/init_command.rb', line 9

def backend_config
  @backend_config
end

#dirObject

Returns the value of attribute dir.



7
8
9
# File 'lib/ruby/terraform/commands/init_command.rb', line 7

def dir
  @dir
end

Instance Method Details

#commandObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby/terraform/commands/init_command.rb', line 17

def command
  cmd = %W[#{tf_binary} init]
  cmd += ['-backend', backend] if backend

  if backend_config
    backend_config.each do |key, value|
      cmd += ['-backend-config', "#{key}=#{value}"]
    end
  end

  cmd += [dir] if dir
  cmd
end