Sha256: ffacc1a5562612837361ae67af275e94c3c639cf5eefe6b403b8186c02e684f1

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

require "service_skeleton/config_variable"

class ServiceSkeleton::ConfigVariable::URL < ServiceSkeleton::ConfigVariable
  def redact!(env)
    if env.has_key?(@name.to_s)
      super
      uri = URI(env[@name.to_s])
      if uri.password
        uri.password = "*REDACTED*"
        env[@name.to_s] = uri.to_s
      end
    end
  end

  private

  def pluck_value(env)
    maybe_default(env) do
      begin
        v = env[@name.to_s]
        URI(v)
      rescue URI::InvalidURIError
        raise ServiceSkeleton::Error::InvalidEnvironmentError,
              "Value for #{@name} (#{v}) does not appear to be a valid URL"
      end

      v
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
service_skeleton-0.0.0.41.g9507cda lib/service_skeleton/config_variable/url.rb