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
12
13
# File 'lib/bolt_server/config.rb', line 9

def config_keys
  super + %w[concurrency cache-dir file-server-conn-timeout
             file-server-uri environments-codedir
             environmentpath basemodulepath builtin-content-dir]
end

#defaultsObject



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

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



15
16
17
# File 'lib/bolt_server/config.rb', line 15

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

#int_keysObject



19
20
21
# File 'lib/bolt_server/config.rb', line 19

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

#load_env_configObject



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

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



32
33
34
# File 'lib/bolt_server/config.rb', line 32

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

#service_nameObject



36
37
38
# File 'lib/bolt_server/config.rb', line 36

def service_name
  'bolt-server'
end

#validateObject



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

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