Class: VagrantPlugins::CommandDns::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vagrant-command-dns/config.rb', line 40

def initialize
  @aliases                   = UNSET_VALUE

  @route53_version           = UNSET_VALUE
  @route53_access_key_id     = UNSET_VALUE
  @route53_secret_access_key = UNSET_VALUE
  @route53_session_token     = UNSET_VALUE
  @route53_zone_id           = UNSET_VALUE

  # Internal
  @__skip = false
  @__available_providers = %w(local route53)
end

Instance Attribute Details

#__available_providersObject (readonly)

Returns the value of attribute __available_providers.



38
39
40
# File 'lib/vagrant-command-dns/config.rb', line 38

def __available_providers
  @__available_providers
end

#__skipObject

Returns the value of attribute __skip.



37
38
39
# File 'lib/vagrant-command-dns/config.rb', line 37

def __skip
  @__skip
end

#aliasesArray<String>

List of VM aliases in FQDN format

Returns:

  • (Array<String>)


8
9
10
# File 'lib/vagrant-command-dns/config.rb', line 8

def aliases
  @aliases
end

#route53_access_key_idString

The access key ID for accessing AWS

Returns:

  • (String)


20
21
22
# File 'lib/vagrant-command-dns/config.rb', line 20

def route53_access_key_id
  @route53_access_key_id
end

#route53_secret_access_keyString

The secret access key for accessing AWS

Returns:

  • (String)


25
26
27
# File 'lib/vagrant-command-dns/config.rb', line 25

def route53_secret_access_key
  @route53_secret_access_key
end

#route53_session_tokenString

The token associated with the key for accessing AWS

Returns:

  • (String)


30
31
32
# File 'lib/vagrant-command-dns/config.rb', line 30

def route53_session_token
  @route53_session_token
end

#route53_versionString

The version of the AWS api to use

Returns:

  • (String)


15
16
17
# File 'lib/vagrant-command-dns/config.rb', line 15

def route53_version
  @route53_version
end

#route53_zone_idString

The Route53 Zone ID

Returns:

  • (String)


35
36
37
# File 'lib/vagrant-command-dns/config.rb', line 35

def route53_zone_id
  @route53_zone_id
end

Instance Method Details

#finalize!Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vagrant-command-dns/config.rb', line 54

def finalize!
  @aliases = [] if @aliases == UNSET_VALUE

  @route53_version = nil if @route53_version == UNSET_VALUE
  @route53_zone_id = nil if @route53_zone_id == UNSET_VALUE

  # Try to get access keys from standard AWS environment variables; they
  # will default to nil if the environment variables are not present.
  @route53_access_key_id     = ENV['AWS_ACCESS_KEY']    if @route53_access_key_id     == UNSET_VALUE
  @route53_secret_access_key = ENV['AWS_SECRET_KEY']    if @route53_secret_access_key == UNSET_VALUE
  @route53_session_token     = ENV['AWS_SESSION_TOKEN'] if @route53_session_token     == UNSET_VALUE
end

#validate(machine) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vagrant-command-dns/config.rb', line 67

def validate(machine)
  errors = _detected_errors

  if @route53
    if machine.provider_name == :aws
      aws_config = machine.provider_config
      # If these values are still not set and the AWS provider is being used, borrow it's config values
      @route53_version           = aws_config.version           if @route53_version           == nil
      @route53_access_key_id     = aws_config.access_key_id     if @route53_access_key_id     == nil
      @route53_secret_access_key = aws_config.secret_access_key if @route53_secret_access_key == nil
      @route53_session_token     = aws_config.session_token     if @route53_session_token     == nil
    end

    errors << I18n.t('vagrant_command_dns.config.route53_zone_id_required') if @route53_zone_id.nil?
    errors << I18n.t('vagrant_command_dns.config.route53_access_key_id_required') if @route53_access_key_id.nil?
    errors << I18n.t('vagrant_command_dns.config.route53_secret_access_key_required') if @route53_secret_access_key.nil?
  end

  { 'DNS' => errors }
end