Module: Kitchen::Driver::Azure::Environments

Defined in:
lib/kitchen/driver/azure/environments.rb

Overview

Endpoints for each Azure cloud the driver can target.

These used to come from MsRestAzure2::AzureEnvironments and MsRestAzure2::ActiveDirectoryServiceSettings. They are stable, published values, so carrying the table ourselves costs a few lines and removes a dependency on a retired SDK.

Defined Under Namespace

Classes: Environment

Constant Summary collapse

ALL =

Every supported cloud, keyed by its downcased name so that lookups are case-insensitive.

Returns:

[
  Environment.new("Azure",
    "https://management.azure.com/",
    "https://login.microsoftonline.com/",
    "https://management.core.windows.net/"),
  Environment.new("AzureUSGovernment",
    "https://management.usgovcloudapi.net",
    "https://login.microsoftonline.us/",
    "https://management.core.usgovcloudapi.net/"),
  Environment.new("AzureChina",
    "https://management.chinacloudapi.cn",
    "https://login.chinacloudapi.cn/",
    "https://management.core.chinacloudapi.cn/"),
  Environment.new("AzureGermanCloud",
    "https://management.microsoftazure.de",
    "https://login.microsoftonline.de/",
    "https://management.core.cloudapi.de/"),
].each(&:freeze).to_h { |environment| [environment.name.downcase, environment] }.freeze

Class Method Summary collapse

Class Method Details

.fetch(name) ⇒ Environment

Looks a cloud up by name.

Parameters:

  • name (String)

    cloud name, case-insensitive.

Returns:

Raises:

  • (Kitchen::UserError)

    if the name is not a known Azure cloud.



91
92
93
94
95
96
# File 'lib/kitchen/driver/azure/environments.rb', line 91

def self.fetch(name)
  ALL.fetch(name.to_s.downcase) do
    raise Kitchen::UserError,
      "Unknown azure_environment '#{name}'. Valid values are: #{names.join(", ")} (case-insensitive)."
  end
end

.namesArray<String>

Returns the canonical name of every supported cloud.

Returns:

  • (Array<String>)

    the canonical name of every supported cloud.



99
100
101
# File 'lib/kitchen/driver/azure/environments.rb', line 99

def self.names
  ALL.values.map(&:name)
end