Sha256: d34417f7b0e0e1b1701641ddede777daa0d04deaf732a615579737482fd1c211

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

require 'timeout'
require 'cloud_formation/bridge/names'
require 'cloud_formation/bridge/util'

module CloudFormation
  module Bridge
    module Resources

      class Base
        include CloudFormation::Bridge::Names

        def require_fields(request, *fields)
          empty_fields = fields.flatten.select do |field|
            request.resource_properties[field].nil? ||
              request.resource_properties[field].strip.empty?
          end

          unless empty_fields.empty?
            raise ArgumentError.new("The fields #{empty_fields.inspect} are required for this resource")
          end

        end

        def update(request)
          raise CloudFormation::Bridge::OperationNotImplementedError.new(
                  "The resource #{self.class.name} does not implement the update operation - #{request.inspect}")
        end

        def wait_until(description, seconds = 5, max_wait = 600, &block)
          Timeout.timeout(max_wait) do
            while !block.call
              Util.logger.info("Waiting for #{description}")
              sleep(seconds)
            end
          end
        end

      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cfn-bridge-0.0.16 lib/cloud_formation/bridge/resources/base.rb
cfn-bridge-0.0.15 lib/cloud_formation/bridge/resources/base.rb
cfn-bridge-0.0.14 lib/cloud_formation/bridge/resources/base.rb
cfn-bridge-0.0.13 lib/cloud_formation/bridge/resources/base.rb
cfn-bridge-0.0.11 lib/cloud_formation/bridge/resources/base.rb
cfn-bridge-0.0.10 lib/cloud_formation/bridge/resources/base.rb