ruby-terraform 0.65.0.pre.4 → 0.65.0.pre.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -5
- data/Rakefile +7 -3
- data/bin/console +1 -0
- data/lib/ruby-terraform.rb +2 -0
- data/lib/ruby_terraform.rb +5 -2
- data/lib/ruby_terraform/commands.rb +2 -0
- data/lib/ruby_terraform/commands/apply.rb +32 -40
- data/lib/ruby_terraform/commands/base.rb +59 -18
- data/lib/ruby_terraform/commands/clean.rb +2 -0
- data/lib/ruby_terraform/commands/destroy.rb +28 -38
- data/lib/ruby_terraform/commands/format.rb +15 -17
- data/lib/ruby_terraform/commands/get.rb +15 -8
- data/lib/ruby_terraform/commands/import.rb +25 -34
- data/lib/ruby_terraform/commands/init.rb +21 -34
- data/lib/ruby_terraform/commands/output.rb +23 -22
- data/lib/ruby_terraform/commands/plan.rb +24 -37
- data/lib/ruby_terraform/commands/refresh.rb +22 -33
- data/lib/ruby_terraform/commands/remote_config.rb +14 -16
- data/lib/ruby_terraform/commands/show.rb +13 -13
- data/lib/ruby_terraform/commands/validate.rb +22 -30
- data/lib/ruby_terraform/commands/workspace.rb +15 -10
- data/lib/ruby_terraform/errors.rb +2 -0
- data/lib/ruby_terraform/errors/execution_error.rb +2 -0
- data/lib/ruby_terraform/options.rb +7 -0
- data/lib/ruby_terraform/options/factory.rb +118 -0
- data/lib/ruby_terraform/options/name.rb +45 -0
- data/lib/ruby_terraform/options/types/base.rb +26 -0
- data/lib/ruby_terraform/options/types/boolean.rb +18 -0
- data/lib/ruby_terraform/options/types/flag.rb +18 -0
- data/lib/ruby_terraform/options/types/standard.rb +43 -0
- data/lib/ruby_terraform/options/values/boolean.rb +31 -0
- data/lib/ruby_terraform/output.rb +17 -11
- data/lib/ruby_terraform/version.rb +3 -1
- data/ruby_terraform.gemspec +58 -0
- metadata +27 -4
| @@ -1,16 +1,23 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require_relative 'base'
         | 
| 2 4 |  | 
| 3 5 | 
             
            module RubyTerraform
         | 
| 4 6 | 
             
              module Commands
         | 
| 5 7 | 
             
                class Get < Base
         | 
| 6 | 
            -
                  def  | 
| 7 | 
            -
                     | 
| 8 | 
            -
                       | 
| 9 | 
            -
                       | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -no-color
         | 
| 11 | 
            +
                      -update
         | 
| 12 | 
            +
                    ]
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def subcommands(_parameters)
         | 
| 16 | 
            +
                    %w[get]
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def arguments(parameters)
         | 
| 20 | 
            +
                    [parameters[:directory]]
         | 
| 14 21 | 
             
                  end
         | 
| 15 22 | 
             
                end
         | 
| 16 23 | 
             
              end
         | 
| @@ -1,45 +1,36 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require 'json'
         | 
| 4 3 | 
             
            require_relative 'base'
         | 
| 5 4 |  | 
| 6 5 | 
             
            module RubyTerraform
         | 
| 7 6 | 
             
              module Commands
         | 
| 8 7 | 
             
                class Import < Base
         | 
| 9 | 
            -
                  def  | 
| 10 | 
            -
                     | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
                     | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -config
         | 
| 11 | 
            +
                      -backup
         | 
| 12 | 
            +
                      -input
         | 
| 13 | 
            +
                      -no-color
         | 
| 14 | 
            +
                      -state
         | 
| 15 | 
            +
                      -var
         | 
| 16 | 
            +
                      -var-file
         | 
| 17 | 
            +
                    ]
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def subcommands(_parameters)
         | 
| 21 | 
            +
                    %w[import]
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def arguments(parameters)
         | 
| 25 | 
            +
                    [parameters[:address], parameters[:id]]
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def parameter_defaults(_parameters)
         | 
| 29 | 
            +
                    { vars: {}, var_files: [] }
         | 
| 30 | 
            +
                  end
         | 
| 21 31 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
                        sub = sub.with_option('-config', directory)
         | 
| 25 | 
            -
                        vars.each do |key, value|
         | 
| 26 | 
            -
                          var_value = value.is_a?(String) ? value : JSON.generate(value)
         | 
| 27 | 
            -
                          sub = sub.with_option(
         | 
| 28 | 
            -
                            '-var', "'#{key}=#{var_value}'", separator: ' '
         | 
| 29 | 
            -
                          )
         | 
| 30 | 
            -
                        end
         | 
| 31 | 
            -
                        sub = sub.with_option('-var-file', var_file) if var_file
         | 
| 32 | 
            -
                        var_files.each do |file|
         | 
| 33 | 
            -
                          sub = sub.with_option('-var-file', file)
         | 
| 34 | 
            -
                        end
         | 
| 35 | 
            -
                        sub = sub.with_option('-state', state) if state
         | 
| 36 | 
            -
                        sub = sub.with_option('-input', input) if input
         | 
| 37 | 
            -
                        sub = sub.with_option('-backup', backup) if backup
         | 
| 38 | 
            -
                        sub = sub.with_flag('-no-color') if no_color
         | 
| 39 | 
            -
                        sub
         | 
| 40 | 
            -
                      end
         | 
| 41 | 
            -
                      .with_argument(address)
         | 
| 42 | 
            -
                      .with_argument(id)
         | 
| 32 | 
            +
                  def parameter_overrides(parameters)
         | 
| 33 | 
            +
                    { backup: parameters[:no_backup] ? '-' : parameters[:backup] }
         | 
| 43 34 | 
             
                  end
         | 
| 44 35 | 
             
                end
         | 
| 45 36 | 
             
              end
         | 
| @@ -1,45 +1,32 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require_relative 'base'
         | 
| 2 4 |  | 
| 3 5 | 
             
            module RubyTerraform
         | 
| 4 6 | 
             
              module Commands
         | 
| 5 7 | 
             
                class Init < Base
         | 
| 6 | 
            -
                  def  | 
| 7 | 
            -
                     | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -backend
         | 
| 11 | 
            +
                      -backend-config
         | 
| 12 | 
            +
                      -force-copy
         | 
| 13 | 
            +
                      -from-module
         | 
| 14 | 
            +
                      -get
         | 
| 15 | 
            +
                      -no-color
         | 
| 16 | 
            +
                      -plugin-dir
         | 
| 17 | 
            +
                    ]
         | 
| 18 | 
            +
                  end
         | 
| 15 19 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
                      unless force_copy.nil?
         | 
| 20 | 
            -
                        sub = sub.with_option('-force-copy',
         | 
| 21 | 
            -
                                              force_copy)
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
                      sub = sub.with_option('-get', get) unless get.nil?
         | 
| 24 | 
            -
                      sub = sub.with_option('-from-module', source) if source
         | 
| 25 | 
            -
                      sub = sub.with_flag('-no-color') if no_color
         | 
| 26 | 
            -
                      unless plugin_dir.nil?
         | 
| 27 | 
            -
                        sub = sub.with_option('-plugin-dir',
         | 
| 28 | 
            -
                                              plugin_dir)
         | 
| 29 | 
            -
                      end
         | 
| 30 | 
            -
                      backend_config.each do |key, value|
         | 
| 31 | 
            -
                        sub = sub.with_option(
         | 
| 32 | 
            -
                          '-backend-config',
         | 
| 33 | 
            -
                          "'#{key}=#{value}'",
         | 
| 34 | 
            -
                          separator: ' '
         | 
| 35 | 
            -
                        )
         | 
| 36 | 
            -
                      end
         | 
| 37 | 
            -
                      sub
         | 
| 38 | 
            -
                    end
         | 
| 20 | 
            +
                  def subcommands(_parameters)
         | 
| 21 | 
            +
                    %w[init]
         | 
| 22 | 
            +
                  end
         | 
| 39 23 |  | 
| 40 | 
            -
             | 
| 24 | 
            +
                  def arguments(parameters)
         | 
| 25 | 
            +
                    [parameters[:path]]
         | 
| 26 | 
            +
                  end
         | 
| 41 27 |  | 
| 42 | 
            -
             | 
| 28 | 
            +
                  def parameter_defaults(_parameters)
         | 
| 29 | 
            +
                    { backend_config: {} }
         | 
| 43 30 | 
             
                  end
         | 
| 44 31 | 
             
                end
         | 
| 45 32 | 
             
              end
         | 
| @@ -1,37 +1,38 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'stringio'
         | 
| 2 4 | 
             
            require_relative 'base'
         | 
| 3 5 |  | 
| 4 6 | 
             
            module RubyTerraform
         | 
| 5 7 | 
             
              module Commands
         | 
| 6 8 | 
             
                class Output < Base
         | 
| 7 | 
            -
                  def  | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 9 | 
            +
                  def initialize_command
         | 
| 10 | 
            +
                    return if defined?(@stdout) && @stdout.respond_to?(:string)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    @stdout = StringIO.new
         | 
| 11 13 | 
             
                  end
         | 
| 12 14 |  | 
| 13 | 
            -
                  def  | 
| 14 | 
            -
                     | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 15 | 
            +
                  def options
         | 
| 16 | 
            +
                    %w[
         | 
| 17 | 
            +
                      -json
         | 
| 18 | 
            +
                      -module
         | 
| 19 | 
            +
                      -no-color
         | 
| 20 | 
            +
                      -raw
         | 
| 21 | 
            +
                      -state
         | 
| 22 | 
            +
                    ]
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def subcommands(_parameters)
         | 
| 26 | 
            +
                    %w[output]
         | 
| 27 | 
            +
                  end
         | 
| 19 28 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                      sub = sub.with_flag('-no-color') if no_color
         | 
| 23 | 
            -
                      sub = sub.with_flag('-json') if json
         | 
| 24 | 
            -
                      sub = sub.with_option('-state', state) if state
         | 
| 25 | 
            -
                      sub = sub.with_option('-module', mod) if mod
         | 
| 26 | 
            -
                      sub
         | 
| 27 | 
            -
                    end
         | 
| 28 | 
            -
                    builder = builder.with_argument(name) if name
         | 
| 29 | 
            -
                    builder
         | 
| 29 | 
            +
                  def arguments(parameters)
         | 
| 30 | 
            +
                    [parameters[:name]]
         | 
| 30 31 | 
             
                  end
         | 
| 31 32 |  | 
| 32 | 
            -
                  def do_after( | 
| 33 | 
            +
                  def do_after(parameters)
         | 
| 33 34 | 
             
                    result = stdout.string
         | 
| 34 | 
            -
                     | 
| 35 | 
            +
                    parameters[:name] ? result.chomp : result
         | 
| 35 36 | 
             
                  end
         | 
| 36 37 | 
             
                end
         | 
| 37 38 | 
             
              end
         | 
| @@ -1,46 +1,33 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            require_relative 'base'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module RubyTerraform
         | 
| 5 6 | 
             
              module Commands
         | 
| 6 7 | 
             
                class Plan < Base
         | 
| 7 | 
            -
                  def  | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
                     | 
| 18 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -destroy
         | 
| 11 | 
            +
                      -input
         | 
| 12 | 
            +
                      -no-color
         | 
| 13 | 
            +
                      -out
         | 
| 14 | 
            +
                      -state
         | 
| 15 | 
            +
                      -target
         | 
| 16 | 
            +
                      -var
         | 
| 17 | 
            +
                      -var-file
         | 
| 18 | 
            +
                    ]
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def subcommands(_parameters)
         | 
| 22 | 
            +
                    %w[plan]
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def arguments(parameters)
         | 
| 26 | 
            +
                    [parameters[:directory]]
         | 
| 27 | 
            +
                  end
         | 
| 19 28 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                      vars.each do |key, value|
         | 
| 23 | 
            -
                        var_value = value.is_a?(String) ? value : JSON.generate(value)
         | 
| 24 | 
            -
                        sub = sub.with_option(
         | 
| 25 | 
            -
                          '-var', "'#{key}=#{var_value}'", separator: ' '
         | 
| 26 | 
            -
                        )
         | 
| 27 | 
            -
                      end
         | 
| 28 | 
            -
                      sub = sub.with_option('-var-file', var_file) if var_file
         | 
| 29 | 
            -
                      var_files.each do |file|
         | 
| 30 | 
            -
                        sub = sub.with_option('-var-file', file)
         | 
| 31 | 
            -
                      end
         | 
| 32 | 
            -
                      sub = sub.with_option('-target', target) if target
         | 
| 33 | 
            -
                      targets.each do |file|
         | 
| 34 | 
            -
                        sub = sub.with_option('-target', file)
         | 
| 35 | 
            -
                      end
         | 
| 36 | 
            -
                      sub = sub.with_option('-state', state) if state
         | 
| 37 | 
            -
                      sub = sub.with_option('-out', plan) if plan
         | 
| 38 | 
            -
                      sub = sub.with_option('-input', input) if input
         | 
| 39 | 
            -
                      sub = sub.with_flag('-destroy') if destroy
         | 
| 40 | 
            -
                      sub = sub.with_flag('-no-color') if no_color
         | 
| 41 | 
            -
                      sub
         | 
| 42 | 
            -
                    end
         | 
| 43 | 
            -
                      .with_argument(directory)
         | 
| 29 | 
            +
                  def parameter_defaults(_parameters)
         | 
| 30 | 
            +
                    { vars: {}, var_files: [], targets: [] }
         | 
| 44 31 | 
             
                  end
         | 
| 45 32 | 
             
                end
         | 
| 46 33 | 
             
              end
         | 
| @@ -1,42 +1,31 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            require_relative 'base'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module RubyTerraform
         | 
| 5 6 | 
             
              module Commands
         | 
| 6 7 | 
             
                class Refresh < Base
         | 
| 7 | 
            -
                  def  | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                     | 
| 16 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -input
         | 
| 11 | 
            +
                      -no-color
         | 
| 12 | 
            +
                      -state
         | 
| 13 | 
            +
                      -target
         | 
| 14 | 
            +
                      -var
         | 
| 15 | 
            +
                      -var-file
         | 
| 16 | 
            +
                    ]
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def subcommands(_parameters)
         | 
| 20 | 
            +
                    %w[refresh]
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def arguments(parameters)
         | 
| 24 | 
            +
                    [parameters[:directory]]
         | 
| 25 | 
            +
                  end
         | 
| 17 26 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
                      vars.each do |key, value|
         | 
| 21 | 
            -
                        var_value = value.is_a?(String) ? value : JSON.generate(value)
         | 
| 22 | 
            -
                        sub = sub.with_option(
         | 
| 23 | 
            -
                          '-var', "'#{key}=#{var_value}'", separator: ' '
         | 
| 24 | 
            -
                        )
         | 
| 25 | 
            -
                      end
         | 
| 26 | 
            -
                      sub = sub.with_option('-var-file', var_file) if var_file
         | 
| 27 | 
            -
                      var_files.each do |file|
         | 
| 28 | 
            -
                        sub = sub.with_option('-var-file', file)
         | 
| 29 | 
            -
                      end
         | 
| 30 | 
            -
                      sub = sub.with_option('-state', state) if state
         | 
| 31 | 
            -
                      sub = sub.with_option('-input', input) if input
         | 
| 32 | 
            -
                      sub = sub.with_option('-target', target) if target
         | 
| 33 | 
            -
                      targets.each do |target_name|
         | 
| 34 | 
            -
                        sub = sub.with_option('-target', target_name)
         | 
| 35 | 
            -
                      end
         | 
| 36 | 
            -
                      sub = sub.with_flag('-no-color') if no_color
         | 
| 37 | 
            -
                      sub
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
                      .with_argument(directory)
         | 
| 27 | 
            +
                  def parameter_defaults(_parameters)
         | 
| 28 | 
            +
                    { vars: {}, var_files: [], targets: [] }
         | 
| 40 29 | 
             
                  end
         | 
| 41 30 | 
             
                end
         | 
| 42 31 | 
             
              end
         | 
| @@ -1,26 +1,24 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require_relative 'base'
         | 
| 2 4 |  | 
| 3 5 | 
             
            module RubyTerraform
         | 
| 4 6 | 
             
              module Commands
         | 
| 5 7 | 
             
                class RemoteConfig < Base
         | 
| 6 | 
            -
                  def  | 
| 7 | 
            -
                     | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -backend
         | 
| 11 | 
            +
                      -backend-config
         | 
| 12 | 
            +
                      -no-color
         | 
| 13 | 
            +
                    ]
         | 
| 14 | 
            +
                  end
         | 
| 10 15 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
                      sub = sub.with_option('-backend', backend) if backend
         | 
| 15 | 
            -
                      backend_config.each do |key, value|
         | 
| 16 | 
            -
                        sub = sub.with_option(
         | 
| 17 | 
            -
                          '-backend-config', "'#{key}=#{value}'", separator: ' '
         | 
| 18 | 
            -
                        )
         | 
| 19 | 
            -
                      end
         | 
| 16 | 
            +
                  def subcommands(_parameters)
         | 
| 17 | 
            +
                    %w[remote config]
         | 
| 18 | 
            +
                  end
         | 
| 20 19 |  | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
                    end
         | 
| 20 | 
            +
                  def parameter_defaults(_parameters)
         | 
| 21 | 
            +
                    { backend_config: {} }
         | 
| 24 22 | 
             
                  end
         | 
| 25 23 | 
             
                end
         | 
| 26 24 | 
             
              end
         | 
| @@ -5,20 +5,20 @@ require_relative 'base' | |
| 5 5 | 
             
            module RubyTerraform
         | 
| 6 6 | 
             
              module Commands
         | 
| 7 7 | 
             
                class Show < Base
         | 
| 8 | 
            -
                  def  | 
| 9 | 
            -
                     | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -json
         | 
| 11 | 
            +
                      -module-depth
         | 
| 12 | 
            +
                      -no-color
         | 
| 13 | 
            +
                    ]
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def subcommands(_parameters)
         | 
| 17 | 
            +
                    %w[show]
         | 
| 18 | 
            +
                  end
         | 
| 13 19 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                      sub = sub.with_option('-module-depth', module_depth) if module_depth
         | 
| 17 | 
            -
                      sub = sub.with_flag('-no-color') if no_color
         | 
| 18 | 
            -
                      sub = sub.with_flag('-json') if json_format
         | 
| 19 | 
            -
                      sub
         | 
| 20 | 
            -
                    end
         | 
| 21 | 
            -
                      .with_argument(path)
         | 
| 20 | 
            +
                  def arguments(parameters)
         | 
| 21 | 
            +
                    [parameters[:path] || parameters[:directory]]
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 | 
             
                end
         | 
| 24 24 | 
             
              end
         | 
| @@ -1,39 +1,31 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            require_relative 'base'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module RubyTerraform
         | 
| 5 6 | 
             
              module Commands
         | 
| 6 7 | 
             
                class Validate < Base
         | 
| 7 | 
            -
                  def  | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                     | 
| 8 | 
            +
                  def options
         | 
| 9 | 
            +
                    %w[
         | 
| 10 | 
            +
                      -check-variables
         | 
| 11 | 
            +
                      -json
         | 
| 12 | 
            +
                      -no-color
         | 
| 13 | 
            +
                      -state
         | 
| 14 | 
            +
                      -var
         | 
| 15 | 
            +
                      -var-file
         | 
| 16 | 
            +
                    ]
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def subcommands(_parameters)
         | 
| 20 | 
            +
                    %w[validate]
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def arguments(parameters)
         | 
| 24 | 
            +
                    [parameters[:directory]]
         | 
| 25 | 
            +
                  end
         | 
| 16 26 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
                      vars.each do |key, value|
         | 
| 20 | 
            -
                        var_value = value.is_a?(String) ? value : JSON.generate(value)
         | 
| 21 | 
            -
                        sub = sub.with_option(
         | 
| 22 | 
            -
                          '-var', "'#{key}=#{var_value}'", separator: ' '
         | 
| 23 | 
            -
                        )
         | 
| 24 | 
            -
                      end
         | 
| 25 | 
            -
                      sub = sub.with_option('-var-file', var_file) if var_file
         | 
| 26 | 
            -
                      var_files.each do |file|
         | 
| 27 | 
            -
                        sub = sub.with_option('-var-file', file)
         | 
| 28 | 
            -
                      end
         | 
| 29 | 
            -
                      sub = sub.with_option('-state', state) if state
         | 
| 30 | 
            -
                      sub = sub.with_option('-check-variables', check_variables) unless
         | 
| 31 | 
            -
                          check_variables.nil?
         | 
| 32 | 
            -
                      sub = sub.with_flag('-no-color') if no_color
         | 
| 33 | 
            -
                      sub = sub.with_flag('-json') if json_format
         | 
| 34 | 
            -
                      sub
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                      .with_argument(directory)
         | 
| 27 | 
            +
                  def parameter_defaults(_parameters)
         | 
| 28 | 
            +
                    { vars: {}, var_files: [] }
         | 
| 37 29 | 
             
                  end
         | 
| 38 30 | 
             
                end
         | 
| 39 31 | 
             
              end
         |