Class: BoltServer::Config

Inherits:
BaseConfig show all
Defined in:
lib/bolt_server/config.rb

Instance Method Summary collapse

Methods inherited from BaseConfig

#[], #initialize, #load_file_config, #natural?, #ssl_keys

Constructor Details

This class inherits a constructor from BoltServer::BaseConfig

Instance Method Details

#config_keysObject



9
10
11
# File 'lib/bolt_server/config.rb', line 9

def config_keys
  super + %w[concurrency cache-dir file-server-conn-timeout file-server-uri]
end

#defaultsObject



21
22
23
24
25
26
27
28
# File 'lib/bolt_server/config.rb', line 21

def defaults
  super.merge(
    'port' => 62658,
    'concurrency' => 100,
    'cache-dir' => "/opt/puppetlabs/server/data/bolt-server/cache",
    'file-server-conn-timeout' => 120
  )
end

#env_keysObject



13
14
15
# File 'lib/bolt_server/config.rb', line 13

def env_keys
  super + %w[concurrency file-server-conn-timeout file-server-uri]
end

#int_keysObject



17
18
19
# File 'lib/bolt_server/config.rb', line 17

def int_keys
  %w[concurrency file-server-conn-timeout]
end

#load_env_configObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bolt_server/config.rb', line 38

def load_env_config
  env_keys.each do |key|
    transformed_key = "BOLT_#{key.tr('-', '_').upcase}"
    next unless ENV.key?(transformed_key)
    @data[key] = if int_keys.include?(key)
                   ENV[transformed_key].to_i
                 else
                   ENV[transformed_key]
                 end
  end
end

#required_keysObject



30
31
32
# File 'lib/bolt_server/config.rb', line 30

def required_keys
  super + %w[file-server-uri]
end

#service_nameObject



34
35
36
# File 'lib/bolt_server/config.rb', line 34

def service_name
  'bolt-server'
end

#validateObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bolt_server/config.rb', line 50

def validate
  super

  unless natural?(@data['concurrency'])
    raise Bolt::ValidationError, "Configured 'concurrency' must be a positive integer"
  end

  unless natural?(@data['file-server-conn-timeout'])
    raise Bolt::ValidationError, "Configured 'file-server-conn-timeout' must be a positive integer"
  end
end