Class: Kitchen::Driver::Azure::Environments::Environment

Inherits:
Struct
  • Object
show all
Defined in:
lib/kitchen/driver/azure/environments.rb

Overview

One Azure cloud's endpoints.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authentication_endpointString (readonly)

Returns Entra ID (Azure AD) token endpoint.

Returns:

  • (String)

    Entra ID (Azure AD) token endpoint.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kitchen/driver/azure/environments.rb', line 21

Environment = Struct.new(:name, :resource_manager_url, :authentication_endpoint, :token_audience) do
  # The OAuth2 v1.0 token URL for a tenant in this cloud.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/token"
  end

  # The OAuth2 v2.0 token URL for a tenant in this cloud.
  #
  # Federated (assertion-based) client credentials are documented
  # against v2.0, which takes a +scope+ rather than a +resource+.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url_v2(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/v2.0/token"
  end

  # The v2.0 scope covering every permission this driver needs.
  #
  # @return [String] e.g. +"https://management.azure.com/.default"+
  def default_scope
    "#{resource_manager_url.chomp("/")}/.default"
  end

  # A copy of this cloud pointed at a different Entra ID authority.
  #
  # Platforms that issue federated tokens - AKS in particular - set
  # +AZURE_AUTHORITY_HOST+ to say where those tokens should be
  # exchanged.
  #
  # @param authority [String, nil] the authority URL, or nil to keep this one.
  # @return [Environment]
  def with_authority(authority)
    return self if authority.to_s.empty?

    self.class.new(name, resource_manager_url, authority, token_audience).freeze
  end
end

#nameString (readonly)

Returns canonical cloud name, e.g. "AzureUSGovernment".

Returns:

  • (String)

    canonical cloud name, e.g. "AzureUSGovernment".



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kitchen/driver/azure/environments.rb', line 21

Environment = Struct.new(:name, :resource_manager_url, :authentication_endpoint, :token_audience) do
  # The OAuth2 v1.0 token URL for a tenant in this cloud.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/token"
  end

  # The OAuth2 v2.0 token URL for a tenant in this cloud.
  #
  # Federated (assertion-based) client credentials are documented
  # against v2.0, which takes a +scope+ rather than a +resource+.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url_v2(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/v2.0/token"
  end

  # The v2.0 scope covering every permission this driver needs.
  #
  # @return [String] e.g. +"https://management.azure.com/.default"+
  def default_scope
    "#{resource_manager_url.chomp("/")}/.default"
  end

  # A copy of this cloud pointed at a different Entra ID authority.
  #
  # Platforms that issue federated tokens - AKS in particular - set
  # +AZURE_AUTHORITY_HOST+ to say where those tokens should be
  # exchanged.
  #
  # @param authority [String, nil] the authority URL, or nil to keep this one.
  # @return [Environment]
  def with_authority(authority)
    return self if authority.to_s.empty?

    self.class.new(name, resource_manager_url, authority, token_audience).freeze
  end
end

#resource_manager_urlString (readonly)

Returns base URL for Azure Resource Manager requests.

Returns:

  • (String)

    base URL for Azure Resource Manager requests.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kitchen/driver/azure/environments.rb', line 21

Environment = Struct.new(:name, :resource_manager_url, :authentication_endpoint, :token_audience) do
  # The OAuth2 v1.0 token URL for a tenant in this cloud.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/token"
  end

  # The OAuth2 v2.0 token URL for a tenant in this cloud.
  #
  # Federated (assertion-based) client credentials are documented
  # against v2.0, which takes a +scope+ rather than a +resource+.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url_v2(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/v2.0/token"
  end

  # The v2.0 scope covering every permission this driver needs.
  #
  # @return [String] e.g. +"https://management.azure.com/.default"+
  def default_scope
    "#{resource_manager_url.chomp("/")}/.default"
  end

  # A copy of this cloud pointed at a different Entra ID authority.
  #
  # Platforms that issue federated tokens - AKS in particular - set
  # +AZURE_AUTHORITY_HOST+ to say where those tokens should be
  # exchanged.
  #
  # @param authority [String, nil] the authority URL, or nil to keep this one.
  # @return [Environment]
  def with_authority(authority)
    return self if authority.to_s.empty?

    self.class.new(name, resource_manager_url, authority, token_audience).freeze
  end
end

#token_audienceString (readonly)

Returns audience/resource the access token is requested for.

Returns:

  • (String)

    audience/resource the access token is requested for.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kitchen/driver/azure/environments.rb', line 21

Environment = Struct.new(:name, :resource_manager_url, :authentication_endpoint, :token_audience) do
  # The OAuth2 v1.0 token URL for a tenant in this cloud.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/token"
  end

  # The OAuth2 v2.0 token URL for a tenant in this cloud.
  #
  # Federated (assertion-based) client credentials are documented
  # against v2.0, which takes a +scope+ rather than a +resource+.
  #
  # @param tenant_id [String]
  # @return [String]
  def token_url_v2(tenant_id)
    "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/v2.0/token"
  end

  # The v2.0 scope covering every permission this driver needs.
  #
  # @return [String] e.g. +"https://management.azure.com/.default"+
  def default_scope
    "#{resource_manager_url.chomp("/")}/.default"
  end

  # A copy of this cloud pointed at a different Entra ID authority.
  #
  # Platforms that issue federated tokens - AKS in particular - set
  # +AZURE_AUTHORITY_HOST+ to say where those tokens should be
  # exchanged.
  #
  # @param authority [String, nil] the authority URL, or nil to keep this one.
  # @return [Environment]
  def with_authority(authority)
    return self if authority.to_s.empty?

    self.class.new(name, resource_manager_url, authority, token_audience).freeze
  end
end

Instance Method Details

#default_scopeString

The v2.0 scope covering every permission this driver needs.

Returns:

  • (String)

    e.g. "https://management.azure.com/.default"



44
45
46
# File 'lib/kitchen/driver/azure/environments.rb', line 44

def default_scope
  "#{resource_manager_url.chomp("/")}/.default"
end

#token_url(tenant_id) ⇒ String

The OAuth2 v1.0 token URL for a tenant in this cloud.

Parameters:

  • tenant_id (String)

Returns:

  • (String)


26
27
28
# File 'lib/kitchen/driver/azure/environments.rb', line 26

def token_url(tenant_id)
  "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/token"
end

#token_url_v2(tenant_id) ⇒ String

The OAuth2 v2.0 token URL for a tenant in this cloud.

Federated (assertion-based) client credentials are documented against v2.0, which takes a scope rather than a resource.

Parameters:

  • tenant_id (String)

Returns:

  • (String)


37
38
39
# File 'lib/kitchen/driver/azure/environments.rb', line 37

def token_url_v2(tenant_id)
  "#{authentication_endpoint.chomp("/")}/#{tenant_id}/oauth2/v2.0/token"
end

#with_authority(authority) ⇒ Environment

A copy of this cloud pointed at a different Entra ID authority.

Platforms that issue federated tokens - AKS in particular - set AZURE_AUTHORITY_HOST to say where those tokens should be exchanged.

Parameters:

  • authority (String, nil)

    the authority URL, or nil to keep this one.

Returns:



56
57
58
59
60
# File 'lib/kitchen/driver/azure/environments.rb', line 56

def with_authority(authority)
  return self if authority.to_s.empty?

  self.class.new(name, resource_manager_url, authority, token_audience).freeze
end