class KingslyCertbot::Configuration

Constants

VARS

Public Class Methods

new(params = {}) click to toggle source
# 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

Public Instance Methods

to_s() click to toggle source
# 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!() click to toggle source
# 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