Module: Kamal::Providers

Defined in:
lib/kamal/providers/base.rb,
lib/kamal/providers/upcloud.rb

Defined Under Namespace

Classes: AuthenticationError, Base, ProvisioningError, QuotaExceededError, RateLimitError, TimeoutError, Upcloud

Class Method Summary collapse

Class Method Details

.for(config) ⇒ Kamal::Providers::Base

Factory method to instantiate the appropriate provider

Examples:

provider = Kamal::Providers.for({
  "type" => "upcloud",
  "username" => ENV["UPCLOUD_USERNAME"],
  "password" => ENV["UPCLOUD_PASSWORD"]
})

Options Hash (config):

  • "type" (String)

    Provider type (e.g., "upcloud")

  • "username" (String)

    Provider API username (provider-specific)

  • "password" (String)

    Provider API password (provider-specific)

Raises:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/kamal/providers/base.rb', line 29

def self.for(config)
  type = config["type"] || config[:type]

  case type&.to_s&.downcase
  when "upcloud"
    require_relative "upcloud" unless defined?(Upcloud)
    Upcloud.new(
      username: config["username"] || config[:username],
      password: config["password"] || config[:password]
    )
  else
    raise Kamal::Dev::ConfigurationError, "Unknown provider type: #{type.inspect}"
  end
end