Sha256: 4c5da735415e746e63eea85207a830619eb20b2ed26fd750002b312d99513436

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 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
    alias_method :region, :location

    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

1 entries across 1 versions & 1 rubygems

Version Path
terraspace_plugin_azurerm-0.2.0 lib/terraspace_plugin_azurerm/interfaces/expander.rb