Sha256: a1774b178fadc83aac3aedd14accd9f16b70a91391c0b1cfc318c672ca5a213c

Contents?: true

Size: 778 Bytes

Versions: 69

Compression:

Stored size: 778 Bytes

Contents

class Terraspace::Terraform::Api::Vars
  class Json < Base
    def vars
      context = Terraspace::Compiler::Erb::Context.new(@mod)
      result = RenderMePretty.result(@vars_path, context: context)

      data = json_load(result)
      items = data.select do |item|
        item['data']['type'] == 'vars'
      end
      items.map { |i| i['data']['attributes'] }
    end

    def json_load(result)
      JSON.load(result)
    rescue JSON::ParserError => e
      # TODO: show exact line with error
      logger.info("ERROR in json: #{e.class}: #{e.message}")
      path = "/tmp/terraspace/debug/vars.json"
      logger.info("Result also written to #{path} for inspection")
      FileUtils.mkdir_p(File.dirname(path))
      IO.write(path, result)
      exit 1
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
terraspace-2.2.15 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.14 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.13 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.12 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.11 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.10 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.9 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.8 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.7 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.6 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.5 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.4 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.3 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.2 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.1 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.2.0 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.1.7 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.1.6 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.1.5 lib/terraspace/terraform/api/vars/json.rb
terraspace-2.1.4 lib/terraspace/terraform/api/vars/json.rb