Sha256: e56c4a0679bfcd7e5d32f5989befdcaf1f351bb4302d2417c627a7de3714cff3

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'digest/sha1'

# This is where you define variable substitions for the Terraspace expander.
# Methods are available as variables.  For example:
#
#    variable          | method
#    ------------------|--------
#    :LOCATION         | location
#    :SUSCRIPTION      | suscription
#    :SUSCRIPTION_HASH | suscription_hash
#    :NAMESPACE_HASH   | namespace_hash
#
module TerraspacePluginAzurerm::Interfaces
  class Expander
    include Terraspace::Plugin::Expander::Interface

    delegate :subscription_id, :subscription, :tenant_id, :tenant_id, :group, :location, to: :azure_info
    alias_method :namespace, :subscription

    def azure_info
      AzureInfo
    end

    # subscription_hash is a short 4-char consistent hash of the longer subscription id.
    # This is useful because azure storage accounts not allowed special characters and can only be 24 chars long.
    # NOTE: be careful to not change this! or else state path will change
    def subscription_hash
      Digest::SHA1.hexdigest(subscription)[0..3]
    end
    alias_method :namespace_hash, :subscription_hash
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
terraspace_plugin_azurerm-0.1.1 lib/terraspace_plugin_azurerm/interfaces/expander.rb
terraspace_plugin_azurerm-0.1.0 lib/terraspace_plugin_azurerm/interfaces/expander.rb