Class: KingslyCertbot::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/kingsly_certbot/configuration.rb

Constant Summary collapse

VARS =
%i[kingsly_server_host kingsly_server_user kingsly_server_password top_level_domain sub_domain
kingsly_http_read_timeout kingsly_http_open_timeout sentry_dsn environment server_type ipsec_root].freeze

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/kingsly_certbot/configuration.rb', line 9

def initialize(params = {})
  @kingsly_http_read_timeout = 120
  @kingsly_http_open_timeout = 5
  @sentry_dsn = params['SENTRY_DSN']
  @environment = params['ENVIRONMENT'] || 'development'
  @top_level_domain = params['TOP_LEVEL_DOMAIN']
  @sub_domain = params['SUB_DOMAIN']
  @kingsly_server_host = params['KINGSLY_SERVER_HOST']
  @kingsly_server_user = params['KINGSLY_SERVER_USER']
  @kingsly_server_password = params['KINGSLY_SERVER_PASSWORD']
  @server_type = params['SERVER_TYPE']
  @ipsec_root = params['IPSEC_ROOT'] || '/'
end

Instance Method Details

#to_sObject



32
33
34
35
36
37
38
39
40
# File 'lib/kingsly_certbot/configuration.rb', line 32

def to_s
  str = ''
  VARS.each do |key|
    value = send(key)
    value = '****' if key == :kingsly_server_password
    str += "#{key}: '#{value}'\n"
  end
  str
end

#validate!Object



23
24
25
26
27
28
29
30
# File 'lib/kingsly_certbot/configuration.rb', line 23

def validate!
  %i[top_level_domain sub_domain kingsly_server_host kingsly_server_user kingsly_server_password server_type].each do |mandatory|
    raise "Missing mandatory config '#{mandatory}'" if send(mandatory).nil? || send(mandatory) == ''
  end
  raise "Unsupported server_type '#{server_type}'" unless ['ipsec'].include?(server_type)

  self
end