Module: Miasma::Contrib::TerraformApiCore::ApiCommon

Included in:
Models::Orchestration::Terraform
Defined in:
lib/miasma/contrib/terraform.rb

Overview

Common API methods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Set attributes into model

Parameters:

  • klass (Class)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/miasma/contrib/terraform.rb', line 16

def self.included(klass)
  klass.class_eval do
    attribute :terraform_driver, String, :required => true,
              :allowed_values => ['tfe', 'boule', 'local'], :default => 'local',
              :coerce => lambda{|v| v.to_s }
    # Attributes required for terraform enterprise driver
    attribute :terraform_tfe_endpoint, String
    attribute :terraform_tfe_token, String
    # Attributes required for Boule driver
    attribute :terraform_boule_endpoint, String
    # Attributes required for local driver
    attribute :terraform_local_directory, String
    attribute :terraform_local_scrub_destroyed, [TrueClass, FalseClass], :default => false
  end
end

Instance Method Details

#custom_setup(creds) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/miasma/contrib/terraform.rb', line 32

def custom_setup(creds)
  begin
    driver_module = Miasma::Models::Orchestration::Terraform.const_get(
      Bogo::Utility.camel(creds[:terraform_driver].to_s)
    )
    extend driver_module
  rescue NameError
    raise NotImplementedError.new "Requested driver not implemented `#{creds[:terraform_driver]}`"
  end
end

#endpointObject



43
44
45
# File 'lib/miasma/contrib/terraform.rb', line 43

def endpoint
  terraform_boule_endpoint
end