Sha256: a60636da088079fb479f74e6aa12534313b103dcd6ca5b5565c6ac2e7f7774fb

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

require 'sparkle_formation'

class SparkleFormation

  # Resources helper
  class Resources

    # Azure specific resources collection
    class Azure < Resources

      # 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

14 entries across 14 versions & 1 rubygems

Version Path
sparkle_formation-3.0.14 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.12 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.10 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.8 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.6 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.4 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.2 lib/sparkle_formation/resources/azure.rb
sparkle_formation-3.0.0 lib/sparkle_formation/resources/azure.rb
sparkle_formation-2.1.8 lib/sparkle_formation/resources/azure.rb
sparkle_formation-2.1.6 lib/sparkle_formation/resources/azure.rb
sparkle_formation-2.1.4 lib/sparkle_formation/resources/azure.rb
sparkle_formation-2.1.2 lib/sparkle_formation/resources/azure.rb
sparkle_formation-2.1.0 lib/sparkle_formation/resources/azure.rb
sparkle_formation-2.0.2 lib/sparkle_formation/resources/azure.rb