opendelivery 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,13 @@ require 'aws-sdk'
3
3
  module OpenDelivery
4
4
  class Stack
5
5
 
6
- def initialize(region=nil, silent=false, sleep_time=30)
6
+ def initialize(region=nil)
7
7
  if region.nil?
8
8
  @cfn = AWS::CloudFormation.new
9
9
  else
10
10
  @cfn = AWS::CloudFormation.new(:region => region)
11
11
  end
12
-
13
- @sleep_time = sleep_time
14
- @silent = silent
12
+ @domain = OpenDelivery::Domain.new
15
13
  end
16
14
 
17
15
 
@@ -36,11 +34,11 @@ module OpenDelivery
36
34
 
37
35
  attr_accessor :sleep_time, :silent, :cfm
38
36
 
39
- def watch stack_name
37
+ def watch(stack_name, sleep_time, silent=false)
40
38
  success = false
41
39
  begin
42
40
  stack = @cfn.stacks[stack_name]
43
- success = watch_loop stack
41
+ success = watch_loop(stack, sleep_time, silent)
44
42
  rescue AWS::CloudFormation::Errors::ValidationError => msg
45
43
  print_status "Exception raised: #{msg}"
46
44
  success = false
@@ -100,7 +98,7 @@ module OpenDelivery
100
98
  end
101
99
  end
102
100
 
103
- def watch_loop stack
101
+ def watch_loop(stack, sleep_time, silent)
104
102
  keep_watching = true
105
103
  success = false
106
104
  abort_count = 10
@@ -108,29 +106,34 @@ module OpenDelivery
108
106
  begin
109
107
  stack_status = stack.status
110
108
  if (SUCCESS_STATUSES.include? stack_status)
111
- print_status "Success: #{stack_status}"
109
+ status = "Success: #{stack_status}"
110
+ print_status(status, silent)
112
111
  success = true
113
112
  keep_watching = false
114
113
  elsif (PROGRESS_STATUSES.include? stack_status)
115
- print_status "In Progress: #{stack_status}"
114
+ status = "In Progress: #{stack_status}"
115
+ print_status(status, silent)
116
116
  success = false
117
117
  keep_watching = true
118
118
  elsif (FAILURE_STATUSES.include? stack_status)
119
- print_status "Failed: #{stack_status}"
119
+ status = "Failed: #{stack_status}"
120
+ print_status(status, silent)
120
121
  success = false
121
122
  keep_watching = false
122
123
  else
123
- print_status "didn't find #{stack_status} in the list of expected statuses"
124
+ status = "didn't find #{stack_status} in the list of expected statuses"
125
+ print_status(status, silent)
124
126
  success = false
125
127
  abort_count = abort_count - 1
126
128
  # if we get too many unknown statuses, assume something has gone horribly wrong and quit.
127
129
  keep_watching = (abort_count > 0)
128
130
  end
129
131
  rescue AWS::CloudFormation::Errors::Throttling
130
- print_status "Rate limit exceeded, retrying..."
131
- sleep (@sleep_time * 0.1)
132
+ status = "Rate limit exceeded, retrying..."
133
+ print_status(status, silent)
134
+ sleep (sleep_time * 0.1)
132
135
  end
133
- sleep(@sleep_time)
136
+ sleep(sleep_time)
134
137
  end
135
138
  return success
136
139
  end
@@ -1,3 +1,3 @@
1
1
  module OpenDelivery
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opendelivery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: