Class: VagrantPlugins::DnsUpdater::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-dns-updater/config.rb', line 16

def initialize
  @registrar = UNSET_VALUE
  @appkey = UNSET_VALUE
  @appsecret = UNSET_VALUE
  @consumerkey = UNSET_VALUE
  @zone = UNSET_VALUE
  @subdomain = UNSET_VALUE
  @interface = UNSET_VALUE
  @ttl = UNSET_VALUE
end

Instance Attribute Details

#appkeyObject

Returns the value of attribute appkey.



7
8
9
# File 'lib/vagrant-dns-updater/config.rb', line 7

def appkey
  @appkey
end

#appsecretObject

Returns the value of attribute appsecret.



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

def appsecret
  @appsecret
end

#consumerkeyObject

Returns the value of attribute consumerkey.



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

def consumerkey
  @consumerkey
end

#interfaceObject

Returns the value of attribute interface.



12
13
14
# File 'lib/vagrant-dns-updater/config.rb', line 12

def interface
  @interface
end

#registrarObject

Returns the value of attribute registrar.



6
7
8
# File 'lib/vagrant-dns-updater/config.rb', line 6

def registrar
  @registrar
end

#subdomainObject

Returns the value of attribute subdomain.



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

def subdomain
  @subdomain
end

#ttlObject

Returns the value of attribute ttl.



13
14
15
# File 'lib/vagrant-dns-updater/config.rb', line 13

def ttl
  @ttl
end

#zoneObject

Returns the value of attribute zone.



10
11
12
# File 'lib/vagrant-dns-updater/config.rb', line 10

def zone
  @zone
end

Instance Method Details

#finalize!Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-dns-updater/config.rb', line 27

def finalize!
  @registrar = nil if @registrar == UNSET_VALUE
  @appkey = nil if @appkey == UNSET_VALUE
  @appsecret = nil if @appsecret == UNSET_VALUE
  @consumerkey = nil if @consumerkey == UNSET_VALUE
  @zone = nil if @zone == UNSET_VALUE
  @subdomain = nil if @subdomain == UNSET_VALUE
  @interface = nil if @interface == UNSET_VALUE
  @ttl = 60 if @ttl == UNSET_VALUE
end

#validate(machine) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vagrant-dns-updater/config.rb', line 38

def validate(machine)
  finalize!
  errors = []
  errors << 'appkey parameter is required' if @appkey.nil? && @registrar == 'ovh'
  errors << 'appsecret parameter is required' if @appsecret.nil? && @registrar == 'ovh'
  errors << 'consumerkey parameter is required' if @consumerkey.nil? && @registrar == 'ovh'
  errors << 'zone parameter is required' if @zone.nil? && !@registrar.nil?
  errors << 'subdomain parameter is required' if @subdomain.nil? && !@registrar.nil?
  errors << 'interface parameter is required' if @interface.nil? && !@registrar.nil?

  { "DnsUpdater" => errors }
end