Sha256: f68b4922b6a36bc401a73873693a6f9732b84202f120c24ba538d5182b53d8c9
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require "term/ansicolor" module AwsAsCode class StackStateSemaphore include Term::ANSIColor def initialize(logger:) @logger = logger end def wait(stack) wait_for_stack_availability stack yield wait_for_stack_availability stack end def wait_for_stack_availability(stack) # Note that stack can have old state cached, hence explicit # .reload here stack.reload.wait_until(max_attempts: 360, delay: 10) do |s| if in_progress? s log_waiting s false else log_proceeding s true end end end private attr_reader :logger def log_waiting(stack) message = format( "Stack %s is in %s state, waiting...", white(stack.name), white(stack.stack_status) ) logger.info message end def log_proceeding(stack) message = format( "Stack %s is in %s state, proceeding", white(stack.name), white(stack.stack_status) ) logger.info message end def in_progress?(stack) stack.stack_status =~ /IN_PROGRESS/ end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aws_as_code-1.0.4 | lib/aws_as_code/stack_state_semaphore.rb |
aws_as_code-1.0.3 | lib/aws_as_code/stack_state_semaphore.rb |
aws_as_code-1.0.2 | lib/aws_as_code/stack_state_semaphore.rb |