Sha256: 38bb5c592b072d3bd0f9143587cfaeceb326e5daf78a979caca9567d2d46dea0

Contents?: true

Size: 797 Bytes

Versions: 30

Compression:

Stored size: 797 Bytes

Contents

class Kamal::Configuration::Validator::Registry < Kamal::Configuration::Validator
  STRING_OR_ONE_ITEM_ARRAY_KEYS = [ "username", "password" ]

  def validate!
    validate_against_example! \
      config.except(*STRING_OR_ONE_ITEM_ARRAY_KEYS),
      example.except(*STRING_OR_ONE_ITEM_ARRAY_KEYS)

    validate_string_or_one_item_array! "username"
    validate_string_or_one_item_array! "password"
  end

  private
    def validate_string_or_one_item_array!(key)
      with_context(key) do
        value = config[key]

        error "is required" unless value.present?

        unless value.is_a?(String) || (value.is_a?(Array) && value.size == 1 && value.first.is_a?(String))
          error "should be a string or an array with one string (for secret lookup)"
        end
      end
    end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
kamal-2.4.0 lib/kamal/configuration/validator/registry.rb
nocoffee-kamal-2.3.0.3 lib/kamal/configuration/validator/registry.rb
nocoffee-kamal-2.3.0.2 lib/kamal/configuration/validator/registry.rb
nocoffee-kamal-2.3.0.1 lib/kamal/configuration/validator/registry.rb
kamal-2.3.0 lib/kamal/configuration/validator/registry.rb
kamal-2.2.2 lib/kamal/configuration/validator/registry.rb
kamal-2.2.1 lib/kamal/configuration/validator/registry.rb
kamal-2.2.0 lib/kamal/configuration/validator/registry.rb
kamal-1.9.2 lib/kamal/configuration/validator/registry.rb
kamal-2.1.2 lib/kamal/configuration/validator/registry.rb
kamal-2.1.1 lib/kamal/configuration/validator/registry.rb
kamal-2.1.0 lib/kamal/configuration/validator/registry.rb
kamal-1.9.1 lib/kamal/configuration/validator/registry.rb
kamal-2.0.0 lib/kamal/configuration/validator/registry.rb
kamal-1.9.0 lib/kamal/configuration/validator/registry.rb
kamal-2.0.0.rc4 lib/kamal/configuration/validator/registry.rb
kamal-2.0.0.rc3 lib/kamal/configuration/validator/registry.rb
kamal-2.0.0.rc2 lib/kamal/configuration/validator/registry.rb
kamal-2.0.0.rc1 lib/kamal/configuration/validator/registry.rb
kamal-2.0.0.beta2 lib/kamal/configuration/validator/registry.rb