Sha256: 4729919348e294ff10d54e3479d8fb09e07df6debc73d8c2aecfcf28cc3b1f2d
Contents?: true
Size: 856 Bytes
Versions: 53
Compression:
Stored size: 856 Bytes
Contents
require "hcl_parser" class Terraspace::Compiler::Backend class Parser extend Memoist def initialize(mod) @mod = mod end def result return {} unless exist?(backend_path) if backend_path.include?('.json') json_backend else hcl_backend end end def json_backend data = JSON.load(IO.read(backend_path)) data.dig("terraform", "backend") || {} end def hcl_backend return {} unless File.exist?(backend_path) backend_raw = HclParser.load(IO.read(backend_path)) return {} unless backend_raw backend_raw.dig("terraform", "backend") || {} end def exist?(path) path && File.exist?(path) end def backend_path expr = "#{@mod.cache_dir}/backend.tf*" Dir.glob(expr).first end memoize :backend_path end end
Version data entries
53 entries across 53 versions & 1 rubygems