Class: VagrantDockerCertificatesManager::Config

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

Overview

Vagrant configuration for certificate generation, installation, and cleanup.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 26

def initialize
  @cert_path            = UNSET_VALUE
  @cert_name            = UNSET_VALUE
  @install_on_up        = UNSET_VALUE
  @remove_on_destroy    = UNSET_VALUE
  @manage_firefox       = UNSET_VALUE
  @manage_nss_browsers  = UNSET_VALUE
  @locale               = UNSET_VALUE
  @verbose              = UNSET_VALUE
  @container_name       = UNSET_VALUE
  @generate_on_up       = UNSET_VALUE
  @ca_cn                = UNSET_VALUE
  @ca_days              = UNSET_VALUE
  @server_domain        = UNSET_VALUE
  @crl_url              = UNSET_VALUE
end

Instance Attribute Details

#ca_cnObject

Returns the value of attribute ca_cn.



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

def ca_cn
  @ca_cn
end

#ca_daysObject

Returns the value of attribute ca_days.



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

def ca_days
  @ca_days
end

#cert_nameString

Returns Friendly certificate name used in host trust stores.

Returns:

  • (String)

    Friendly certificate name used in host trust stores.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#cert_pathString

Returns Path to the CA certificate installed into the trust store.

Returns:

  • (String)

    Path to the CA certificate installed into the trust store.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#container_nameObject

Returns the value of attribute container_name.



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

def container_name
  @container_name
end

#crl_urlObject

Returns the value of attribute crl_url.



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

def crl_url
  @crl_url
end

#generate_on_upBoolean

Returns Whether local certificate material should be generated during vagrant up.

Returns:

  • (Boolean)

    Whether local certificate material should be generated during vagrant up.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#install_on_upBoolean

Returns Whether to install the certificate during vagrant up.

Returns:

  • (Boolean)

    Whether to install the certificate during vagrant up.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#localeObject

Returns the value of attribute locale.



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

def locale
  @locale
end

#manage_firefoxBoolean

Returns Whether Firefox stores should be managed where supported.

Returns:

  • (Boolean)

    Whether Firefox stores should be managed where supported.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#manage_nss_browsersBoolean

Returns Whether NSS browser stores should be managed where supported.

Returns:

  • (Boolean)

    Whether NSS browser stores should be managed where supported.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#remove_on_destroyBoolean

Returns Whether to remove the certificate during vagrant destroy.

Returns:

  • (Boolean)

    Whether to remove the certificate during vagrant destroy.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 20

class Config < Vagrant.plugin("2", :config)
  attr_accessor :cert_path, :cert_name, :install_on_up, :remove_on_destroy,
                :manage_firefox, :manage_nss_browsers, :locale, :verbose,
                :container_name,
                :generate_on_up, :ca_cn, :ca_days, :server_domain, :crl_url

  def initialize
    @cert_path            = UNSET_VALUE
    @cert_name            = UNSET_VALUE
    @install_on_up        = UNSET_VALUE
    @remove_on_destroy    = UNSET_VALUE
    @manage_firefox       = UNSET_VALUE
    @manage_nss_browsers  = UNSET_VALUE
    @locale               = UNSET_VALUE
    @verbose              = UNSET_VALUE
    @container_name       = UNSET_VALUE
    @generate_on_up       = UNSET_VALUE
    @ca_cn                = UNSET_VALUE
    @ca_days              = UNSET_VALUE
    @server_domain        = UNSET_VALUE
    @crl_url              = UNSET_VALUE
  end

  def finalize!
    @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
    @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
    @install_on_up       = false                   if @install_on_up == UNSET_VALUE
    @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
    @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
    @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
    @locale              = "en"                    if @locale == UNSET_VALUE
    @verbose             = false                   if @verbose == UNSET_VALUE
    @container_name      = nil                     if @container_name == UNSET_VALUE
    @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
    @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
    @ca_days             = 3650                    if @ca_days == UNSET_VALUE
    @server_domain       = nil                     if @server_domain == UNSET_VALUE
    @crl_url             = nil                     if @crl_url == UNSET_VALUE

    @install_on_up       = !!@install_on_up
    @remove_on_destroy   = !!@remove_on_destroy
    @manage_firefox      = !!@manage_firefox
    @manage_nss_browsers = !!@manage_nss_browsers
    @verbose             = !!@verbose
    @generate_on_up      = !!@generate_on_up
    @locale              = (@locale || "en").to_s
    @ca_cn               = (@ca_cn || "local-ca").to_s
    @ca_days             = @ca_days.to_i
  end

  def validate(_machine)
    errors = []
    errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
    errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
    unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
      errors << "locale must be 'en' or 'fr'"
    end
    errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
    { "vagrant-docker-certificates-manager" => errors }
  end

  def cert_dir
    d = File.dirname(@cert_path.to_s)
    d.empty? ? "certs" : d
  end
end

#server_domainObject

Returns the value of attribute server_domain.



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

def server_domain
  @server_domain
end

#verboseObject

Returns the value of attribute verbose.



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

def verbose
  @verbose
end

Instance Method Details

#cert_dirObject



81
82
83
84
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 81

def cert_dir
  d = File.dirname(@cert_path.to_s)
  d.empty? ? "certs" : d
end

#finalize!Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 43

def finalize!
  @cert_path           = "certs/rootca.cert.pem" if @cert_path == UNSET_VALUE
  @cert_name           = "local.dev"             if @cert_name == UNSET_VALUE
  @install_on_up       = false                   if @install_on_up == UNSET_VALUE
  @remove_on_destroy   = false                   if @remove_on_destroy == UNSET_VALUE
  @manage_firefox      = false                   if @manage_firefox == UNSET_VALUE
  @manage_nss_browsers = true                    if @manage_nss_browsers == UNSET_VALUE
  @locale              = "en"                    if @locale == UNSET_VALUE
  @verbose             = false                   if @verbose == UNSET_VALUE
  @container_name      = nil                     if @container_name == UNSET_VALUE
  @generate_on_up      = false                   if @generate_on_up == UNSET_VALUE
  @ca_cn               = "local-ca"              if @ca_cn == UNSET_VALUE
  @ca_days             = 3650                    if @ca_days == UNSET_VALUE
  @server_domain       = nil                     if @server_domain == UNSET_VALUE
  @crl_url             = nil                     if @crl_url == UNSET_VALUE

  @install_on_up       = !!@install_on_up
  @remove_on_destroy   = !!@remove_on_destroy
  @manage_firefox      = !!@manage_firefox
  @manage_nss_browsers = !!@manage_nss_browsers
  @verbose             = !!@verbose
  @generate_on_up      = !!@generate_on_up
  @locale              = (@locale || "en").to_s
  @ca_cn               = (@ca_cn || "local-ca").to_s
  @ca_days             = @ca_days.to_i
end

#validate(_machine) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/vagrant-docker-certificates-manager/config.rb', line 70

def validate(_machine)
  errors = []
  errors << "cert_path must be provided" if @cert_path.to_s.strip.empty?
  errors << "cert_name must be provided" if @cert_name.to_s.strip.empty?
  unless @locale.is_a?(String) && %w[en fr].include?(@locale.to_s[0, 2].downcase)
    errors << "locale must be 'en' or 'fr'"
  end
  errors << "ca_days must be a positive integer" if @generate_on_up && @ca_days.to_i <= 0
  { "vagrant-docker-certificates-manager" => errors }
end