Sha256: d09635317c2c4d7deaab9dc806f0e63554b35af1f87a5cc3b325f4859f8b2e87
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
module ProspectusTerraform ## # Lookup object to find providers class Lookup PROVIDER_REGEX = /provider\.(?<key>[\w-]+) (?<value>[\d.]+)$/ REPO_REGEX = %r{^ // provider\.(?<key>[\w-]+) (?<value>[\w-]+\/[\w-]+)} def results @results ||= providers.map do |name, version| [name, version, repos[name] || default_repo(name)] end end def providers @providers ||= match_to_hash(provider_lines, PROVIDER_REGEX) end def provider_lines @provider_lines ||= `terraform providers`.lines end def repos @repos ||= match_to_hash(repo_lines, REPO_REGEX) end def repo_lines @repo_lines ||= File.read('main.tf').lines end def match_to_hash(lines, regex) lines.map { |x| x.match(regex) }.compact.map { |x| [x[1], x[2]] }.to_h end def default_repo(name) "terraform-providers/terraform-provider-#{name}" end end ## # Helper for automatically adding provider status check class Providers < Module def extended(other) # rubocop:disable Metrics/MethodLength lookup = Lookup.new other.deps do lookup.results.each do |provider_name, provider_version, provider_repo| item do name "provider-#{provider_name}" expected do github_tag repo provider_repo regex(/^v?([\d.]+)$/) end actual do static set provider_version end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prospectus_terraform-0.0.1 | lib/prospectus_terraform/providers.rb |