Class: Kitchen::Terraform::Client::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/terraform/client/options.rb

Overview

Represents supported options for client commands.

Instance Method Summary collapse

Instance Method Details

#backend_config(key:, value:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -backend-config with arguments to the options.

Parameters:

  • key (#to_s)

    the backend configuration key

  • value (#to_s)

    the backend configuration value

Returns:



26
27
28
# File 'lib/kitchen/terraform/client/options.rb', line 26

def backend_config(key:, value:)
  add option: "-backend-config='#{key}=#{value}'"
end

#backend_configs(keys_and_values:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -backend-config with arguments to the options multiple times.

Parameters:

  • keys_and_values (::Hash<#to_s, #to_s>)

    the backend configuration keys and values

Returns:



34
35
36
37
38
39
40
41
42
43
# File 'lib/kitchen/terraform/client/options.rb', line 34

def backend_configs(keys_and_values:)
  keys_and_values
    .inject self do |additional_options, (key, value)|
      additional_options
        .backend_config(
          key: key,
          value: value
        )
    end
end

#disable_input::Kitchen::Terraform::Client::Options

Adds -input=false to the options.

Returns:



48
49
50
# File 'lib/kitchen/terraform/client/options.rb', line 48

def disable_input
  add option: "-input=false"
end

#enable_auto_approve::Kitchen::Terraform::Client::Options

Adds -auto-approve=true to the options.

Returns:



55
56
57
# File 'lib/kitchen/terraform/client/options.rb', line 55

def enable_auto_approve
  add option: "-auto-approve=true"
end

#enable_backend::Kitchen::Terraform::Client::Options

Adds -backend=true to the options.

Returns:



62
63
64
# File 'lib/kitchen/terraform/client/options.rb', line 62

def enable_backend
  add option: "-backend=true"
end

#enable_check_variables::Kitchen::Terraform::Client::Options

Adds -check-variables=true to the options.

Returns:



69
70
71
# File 'lib/kitchen/terraform/client/options.rb', line 69

def enable_check_variables
  add option: "-check-variables=true"
end

#enable_get::Kitchen::Terraform::Client::Options

Adds -get=true to the options.

Returns:



76
77
78
# File 'lib/kitchen/terraform/client/options.rb', line 76

def enable_get
  add option: "-get=true"
end

#enable_lock::Kitchen::Terraform::Client::Options

Adds -lock=true to the options.

Returns:



112
113
114
# File 'lib/kitchen/terraform/client/options.rb', line 112

def enable_lock
  add option: "-lock=true"
end

#enable_refresh::Kitchen::Terraform::Client::Options

Adds -refresh=true to the options.

Returns:



119
120
121
# File 'lib/kitchen/terraform/client/options.rb', line 119

def enable_refresh
  add option: "-refresh=true"
end

#force::Kitchen::Terraform::Client::Options

Adds -force to the options.

Returns:



83
84
85
# File 'lib/kitchen/terraform/client/options.rb', line 83

def force
  add option: "-force"
end

#force_copy::Kitchen::Terraform::Client::Options

Adds -force-copy to the options.

Returns:



90
91
92
# File 'lib/kitchen/terraform/client/options.rb', line 90

def force_copy
  add option: "-force-copy"
end

#from_module(source:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -from-module with an argument to the options.

Parameters:

  • source (#to_s)

    the module source

Returns:



98
99
100
# File 'lib/kitchen/terraform/client/options.rb', line 98

def from_module(source:)
  add option: "-from-module=#{source}"
end

#json::Kitchen::Terraform::Client::Options

Adds -json to the options.

Returns:



105
106
107
# File 'lib/kitchen/terraform/client/options.rb', line 105

def json
  add option: "-json"
end

#lock_timeout(duration:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -lock-timeout with an argument to the options.

Parameters:

  • duration (#to_s)

    the lock timeout duration

Returns:



127
128
129
# File 'lib/kitchen/terraform/client/options.rb', line 127

def lock_timeout(duration:)
  add option: "-lock-timeout=#{duration}"
end

#maybe_no_color(toggle:) ⇒ ::Kitchen::Terraform::Client::Options

Conditionally adds -no-color to the options.

Parameters:

  • toggle (::TrueClass, ::FalseClass)

    the flag toggle

Returns:



135
136
137
# File 'lib/kitchen/terraform/client/options.rb', line 135

def maybe_no_color(toggle:)
  toggle and no_color or self
end

#maybe_plugin_dir(path:) ⇒ ::Kitchen::Terraform::Client::Options

Conditionally adds -plugin-dir to the options.

Parameters:

  • path (::TrueClass, ::FalseClass)

    the path to the plugin directory

Returns:



143
144
145
# File 'lib/kitchen/terraform/client/options.rb', line 143

def maybe_plugin_dir(path:)
  path and plugin_dir path: path or self
end

#no_color::Kitchen::Terraform::Client::Options

Adds -no-color to the options.

Returns:



150
151
152
# File 'lib/kitchen/terraform/client/options.rb', line 150

def no_color
  add option: "-no-color"
end

#parallelism(concurrent_operations:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -parallelism with an argument to the options.

Parameters:

  • concurrent_operations (#to_s)

    the number of concurrent operations

Returns:



158
159
160
# File 'lib/kitchen/terraform/client/options.rb', line 158

def parallelism(concurrent_operations:)
  add option: "-parallelism=#{concurrent_operations}"
end

#plugin_dir(path:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -plugin-dir with an argument to the options.

Parameters:

  • path (#to_s)

    the path to the plugin directory

Returns:



166
167
168
# File 'lib/kitchen/terraform/client/options.rb', line 166

def plugin_dir(path:)
  add option: "-plugin-dir=#{path}"
end

#state(path:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -state with an argument to the options.

Parameters:

  • path (#to_s)

    the path to the input state file

Returns:



174
175
176
# File 'lib/kitchen/terraform/client/options.rb', line 174

def state(path:)
  add option: "-state=#{path}"
end

#state_out(path:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -state-out with an argument to the options.

Parameters:

  • path (#to_s)

    the path to the output state file

Returns:



182
183
184
# File 'lib/kitchen/terraform/client/options.rb', line 182

def state_out(path:)
  add option: "-state-out=#{path}"
end

#to_s::String

The options expressed as a space delimited string.

Returns:

  • (::String)

    the options string



247
248
249
# File 'lib/kitchen/terraform/client/options.rb', line 247

def to_s
  @options.join " "
end

#upgrade::Kitchen::Terraform::Client::Options

Adds -upgrade to the options.

Returns:



189
190
191
# File 'lib/kitchen/terraform/client/options.rb', line 189

def upgrade
  add option: "-upgrade"
end

#var(key:, value:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -var with arguments to the options.

Parameters:

  • key (#to_s)

    the variable key

  • value (#to_s)

    the variable value

Returns:



198
199
200
# File 'lib/kitchen/terraform/client/options.rb', line 198

def var(key:, value:)
  add option: "-var='#{key}=#{value}'"
end

#var_file(path:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -var-file with an argument to the options.

Parameters:

  • path (#to_s)

    the path to the variable file

Returns:



221
222
223
# File 'lib/kitchen/terraform/client/options.rb', line 221

def var_file(path:)
  add option: "-var-file=#{path}"
end

#var_files(paths:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -var-file with an argument to the options multiple times.

Parameters:

  • paths (::Array<#to_s>)

    the paths to the variable files

Returns:



229
230
231
232
233
234
# File 'lib/kitchen/terraform/client/options.rb', line 229

def var_files(paths:)
  paths
    .inject self do |additional_options, path|
      additional_options.var_file path: path
    end
end

#vars(keys_and_values:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -var with arguments to the options multiple times.

Parameters:

  • keys_and_values (::Hash<#to_s, #to_s>)

    the variable keys and values

Returns:



206
207
208
209
210
211
212
213
214
215
# File 'lib/kitchen/terraform/client/options.rb', line 206

def vars(keys_and_values:)
  keys_and_values
    .inject self do |additional_options, (key, value)|
      additional_options
        .var(
          key: key,
          value: value
        )
    end
end

#verify_plugins(toggle:) ⇒ ::Kitchen::Terraform::Client::Options

Adds -verify-plugins with an argument to the options.

Parameters:

  • toggle (#to_s)

    toggle to enable or disable

Returns:



240
241
242
# File 'lib/kitchen/terraform/client/options.rb', line 240

def verify_plugins(toggle:)
  add option: "-verify-plugins=#{toggle}"
end