Sha256: 90b94845b31ff290fda157d1687f92304441abca8037696ad6d41aace44eba3e

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

require 'hocon'
require 'bolt_server/base_config'
require 'bolt/error'

module BoltServer
  class Config < BoltServer::BaseConfig
    def config_keys
      super + %w[concurrency cache-dir file-server-conn-timeout
                 file-server-uri projects-dir environments-codedir
                 environmentpath basemodulepath]
    end

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

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

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

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

    def service_name
      'bolt-server'
    end

    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

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bolt-2.42.0 lib/bolt_server/config.rb
bolt-2.40.2 lib/bolt_server/config.rb
bolt-2.40.1 lib/bolt_server/config.rb
bolt-2.38.0 lib/bolt_server/config.rb
bolt-2.37.0 lib/bolt_server/config.rb
bolt-2.36.0 lib/bolt_server/config.rb