Class: VagrantPlugins::Certificates::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  @certs = UNSET_VALUE
  @enabled = UNSET_VALUE
end

Instance Attribute Details

#certsObject

Returns the value of attribute certs.



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

def certs
  @certs
end

#enabledObject

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

Instance Method Details

#disable!Object



21
22
23
# File 'lib/vagrant-certificates/config.rb', line 21

def disable!
  @enabled = false
end

#disabled?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/vagrant-certificates/config.rb', line 17

def disabled?
  !enabled?
end

#enabled?Boolean

Returns:

  • (Boolean)


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

def enabled?
  @enabled == true
end

#finalize!Object



39
40
41
42
# File 'lib/vagrant-certificates/config.rb', line 39

def finalize!
  @enabled = false if @enabled == UNSET_VALUE
  @certs = [] if @certs == UNSET_VALUE
end

#validate(machine) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vagrant-certificates/config.rb', line 25

def validate(machine)
  errors = []
  if enabled?
    # If the certificates specified do not exist on the host
    # disk we should error out very loudly. Because this will
    # likely affect guest operation.
    @certs.reject { |f| f =~ /^http[s]?/ || File.exist?(f) }.each do |f|
      errors << I18n.t('vagrant_certificates.certificate.not_found', filepath: f)
    end
  end

  { 'vagrant-certificates' => errors }
end