class Terraspace::Compiler::Backend

Public Class Methods

new(mod) click to toggle source
# File lib/terraspace/compiler/backend.rb, line 5
def initialize(mod)
  @mod = mod
end

Public Instance Methods

backend() click to toggle source
# File lib/terraspace/compiler/backend.rb, line 35
def backend
  Parser.new(@mod).result
end
backend_info() click to toggle source
# File lib/terraspace/compiler/backend.rb, line 31
def backend_info
  backend.values.first # structure within the s3 or gcs key
end
backend_interface(name) click to toggle source
# File lib/terraspace/compiler/backend.rb, line 40
def backend_interface(name)
  return unless name
  # IE: TerraspacePluginAws::Interfaces::Backend
  klass_name = Terraspace::Plugin.klass("Backend", backend: name)
  klass_name.constantize if klass_name
rescue NameError
end
backend_name() click to toggle source
# File lib/terraspace/compiler/backend.rb, line 27
def backend_name
  backend.keys.first # IE: s3, gcs, etc
end
cache_key() click to toggle source
# File lib/terraspace/compiler/backend.rb, line 23
def cache_key
  @mod.build_dir
end
create() click to toggle source
# File lib/terraspace/compiler/backend.rb, line 10
def create
  return if @@created[cache_key]
  # set immediately, since local storage wont reach bottom.
  # if fail for other backends, there will be an exception anyway
  @@created[cache_key] = true

  klass = backend_interface(backend_name)
  return unless klass # in case auto-creation is not supported for specific backend

  interface = klass.new(backend_info)
  interface.call
end