class ProspectusTerraform::Modules

Helper for automatically adding module status check

Public Instance Methods

cmd_name() click to toggle source
# File lib/prospectus_terraform/modules.rb, line 60
def cmd_name
  'terraform-config-inspect --json'
end
config_json() click to toggle source
# File lib/prospectus_terraform/modules.rb, line 53
def config_json
  return @config_json if @config_json
  stdout, stderr, status = Open3.capture3(cmd_name)
  raise("#{cmd_name} failed") unless status.success? && stderr.empty?
  @config_json = stdout
end
extended(other) click to toggle source
# File lib/prospectus_terraform/modules.rb, line 31
def extended(other) # rubocop:disable Metrics/MethodLength
  modules_object = modules

  other.deps do
    modules_object.each do |m|
      item do
        name "module-#{m.name}"

        expected do
          static
          set m.latest
        end

        actual do
          static
          set m.version
        end
      end
    end
  end
end
modules() click to toggle source
# File lib/prospectus_terraform/modules.rb, line 64
def modules
  @modules ||= JSON.parse(config_json)['module_calls'].values.map do |x|
    next unless x['version']
    ModuleData.new(x)
  end.compact
end