Class: VagrantPlugins::AMI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ami/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region_specific = false) ⇒ Config

Returns a new instance of Config.



11
12
13
# File 'lib/vagrant-ami/config.rb', line 11

def initialize(region_specific=false)
  @tags           = {}
end

Instance Attribute Details

#tagsHash<String, String>

The tags for created AMIs.

Returns:

  • (Hash<String, String>)


9
10
11
# File 'lib/vagrant-ami/config.rb', line 9

def tags
  @tags
end

Instance Method Details

#get_region_config(name) ⇒ Object

This gets the configuration for a specific region. It shouldn’t be called by the general public and is only used internally.



40
41
42
43
44
45
46
47
# File 'lib/vagrant-ami/config.rb', line 40

def get_region_config(name)
  if !@__finalized
    raise "Configuration must be finalized before calling this method."
  end

  # Return the compiled region config
  @__compiled_region_configs[name] || self
end

#validate(machine) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-ami/config.rb', line 15

def validate(machine)
  errors = _detected_errors

  errors << I18n.t("vagrant_aws.config.region_required") if @region.nil?

  if @region
    # Get the configuration for the region we're using and validate only
    # that region.
    config = get_region_config(@region)

    if !config.use_iam_profile
      errors << I18n.t("vagrant_aws.config.access_key_id_required") if \
        config.access_key_id.nil?
      errors << I18n.t("vagrant_aws.config.secret_access_key_required") if \
        config.secret_access_key.nil?
    end

    errors << I18n.t("vagrant_aws.config.ami_required") if config.ami.nil?
  end

  { "AWS Provider" => errors }
end