Sha256: 89c86a104de798aa27d7845c4439627203e3486b89b1e0b16028ecd72a53d838

Contents?: true

Size: 693 Bytes

Versions: 16

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

require "service_skeleton/config_variable"

class ServiceSkeleton::ConfigVariable::KVList < ServiceSkeleton::ConfigVariable
  def redact!(env)
    env.keys.each { |k| env[k] = "*SENSITIVE*" if k =~ @opts[:key_pattern] }
  end

  private

  def pluck_value(env)
    matches = env.select { |k, _| k.to_s =~ @opts[:key_pattern] }

    if matches.empty?
      if @opts.has_key?(:default)
        @opts[:default]
      else
        raise ServiceSkeleton::Error::InvalidEnvironmentError,
              "no keys for key-value list #{@name} specified"
      end
    else
      matches.transform_keys { |k| @opts[:key_pattern].match(k.to_s)[1].to_sym }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
service_skeleton-2.2.0 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-2.1.0 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-1.0.5 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-2.0.2 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-2.0.1 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-2.0.0 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-1.0.4 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-0.0.0.1.ENOTAG lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-1.0.3 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-1.0.2 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-1.0.1 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-0.0.0.49.g47046b9 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-0.0.0.48.g4a40599 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-0.0.0.44.g75d07d7 lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-0.0.0.43.g678698a lib/service_skeleton/config_variable/kv_list.rb
service_skeleton-0.0.0.41.g9507cda lib/service_skeleton/config_variable/kv_list.rb