Sha256: fbc1c1eb9324edc9c52f759242ae9e1328b5c5586f821343159ea21fbfda3ac0

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

require 'sparkle_formation'

class SparkleFormation

  # Resources helper
  class Resources

    # Azure specific resources collection
    class Azure < Resources

      # Characters to be removed from supplied key on matching
      RESOURCE_TYPE_TR = '/._'
      # String to split for resource namespacing
      RESOURCE_TYPE_NAMESPACE_SPLITTER = ['.', '/']

      class << self

        include Bogo::Memoization

        # Load the builtin AWS resources
        #
        # @return [TrueClass]
        def load!
          memoize(:azure_resources, :global) do
            load(
              File.join(
                File.dirname(__FILE__),
                'azure_resources.json'
              )
            )
            true
          end
        end

        # Auto load data when included
        def included(_klass)
          load!
        end

        # Automatically add api version information and location if
        # required by resource and not provided
        #
        # @param struct [SparkleStruct]
        # @param lookup_key [String]
        # @return [SparkleStruct]
        def resource_customizer(struct, lookup_key)
          info = registry[lookup_key]
          if(info[:required].include?('apiVersion') && struct.api_version.nil?)
            struct.api_version info[:api_version]
          end
          if(info[:required].include?('location') && struct.location.nil?)
            struct.location struct.resource_group!.location
          end
          struct
        end

      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sparkle_formation-3.0.26 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.24 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.22 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.20 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.18 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.16 lib/sparkle_formation/resources/azure.rb