dpl 2.0.3.beta.4 → 2.0.3.beta.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.
- checksums.yaml +4 -4
- data/Gemfile +15 -3
- data/Gemfile.lock +444 -211
- data/Rakefile +36 -34
- data/bin/dpl +3 -1
- data/dpl.gemspec +25 -0
- data/lib/dpl/cli.rb +19 -14
- data/lib/dpl/ctx/bash.rb +18 -12
- data/lib/dpl/ctx/test.rb +21 -15
- data/lib/dpl/ctx.rb +2 -0
- data/lib/dpl/helper/assets.rb +4 -2
- data/lib/dpl/helper/cmd.rb +20 -18
- data/lib/dpl/helper/config_file.rb +5 -3
- data/lib/dpl/helper/cookbook_site_streaming_uploader.rb +249 -0
- data/lib/dpl/helper/env.rb +26 -22
- data/lib/dpl/helper/github.rb +2 -0
- data/lib/dpl/helper/interpolate.rb +8 -4
- data/lib/dpl/helper/memoize.rb +4 -1
- data/lib/dpl/helper/squiggle.rb +3 -1
- data/lib/dpl/helper/transliterate.rb +3 -1
- data/lib/dpl/helper/wrap.rb +3 -1
- data/lib/dpl/helper/zip.rb +3 -1
- data/lib/dpl/provider/dsl.rb +18 -4
- data/lib/dpl/provider/examples.rb +6 -2
- data/lib/dpl/provider/status.rb +26 -24
- data/lib/dpl/providers/anynines.rb +22 -20
- data/lib/dpl/providers/azure_web_apps.rb +21 -19
- data/lib/dpl/providers/bintray.rb +44 -37
- data/lib/dpl/providers/bluemixcloudfoundry.rb +38 -36
- data/lib/dpl/providers/boxfuse.rb +12 -10
- data/lib/dpl/providers/cargo.rb +7 -5
- data/lib/dpl/providers/chef_supermarket.rb +82 -80
- data/lib/dpl/providers/cloud66.rb +17 -15
- data/lib/dpl/providers/cloudfiles.rb +8 -6
- data/lib/dpl/providers/cloudformation.rb +191 -187
- data/lib/dpl/providers/cloudfoundry.rb +32 -30
- data/lib/dpl/providers/codedeploy.rb +35 -33
- data/lib/dpl/providers/convox.rb +32 -25
- data/lib/dpl/providers/datica.rb +30 -28
- data/lib/dpl/providers/ecr.rb +66 -64
- data/lib/dpl/providers/elasticbeanstalk.rb +14 -12
- data/lib/dpl/providers/engineyard.rb +60 -58
- data/lib/dpl/providers/firebase.rb +6 -4
- data/lib/dpl/providers/flynn.rb +8 -6
- data/lib/dpl/providers/gae.rb +28 -25
- data/lib/dpl/providers/gcs.rb +59 -57
- data/lib/dpl/providers/git_push.rb +199 -195
- data/lib/dpl/providers/gleis.rb +19 -17
- data/lib/dpl/providers/hackage.rb +15 -13
- data/lib/dpl/providers/hephy.rb +18 -16
- data/lib/dpl/providers/heroku/api.rb +72 -70
- data/lib/dpl/providers/heroku/git.rb +15 -13
- data/lib/dpl/providers/heroku.rb +40 -38
- data/lib/dpl/providers/lambda.rb +134 -134
- data/lib/dpl/providers/launchpad.rb +45 -43
- data/lib/dpl/providers/netlify.rb +7 -5
- data/lib/dpl/providers/npm.rb +61 -58
- data/lib/dpl/providers/nuget.rb +8 -6
- data/lib/dpl/providers/openshift.rb +8 -6
- data/lib/dpl/providers/opsworks.rb +23 -21
- data/lib/dpl/providers/pages/api.rb +14 -14
- data/lib/dpl/providers/pages/git.rb +53 -47
- data/lib/dpl/providers/pages.rb +3 -1
- data/lib/dpl/providers/puppetforge.rb +6 -4
- data/lib/dpl/providers/pypi.rb +55 -54
- data/lib/dpl/providers/releases.rb +30 -23
- data/lib/dpl/providers/rubygems.rb +35 -31
- data/lib/dpl/providers/s3.rb +148 -142
- data/lib/dpl/providers/scalingo.rb +18 -16
- data/lib/dpl/providers/script.rb +4 -2
- data/lib/dpl/providers/snap.rb +12 -9
- data/lib/dpl/providers/surge.rb +7 -5
- data/lib/dpl/providers/testfairy.rb +47 -43
- data/lib/dpl/providers/transifex.rb +20 -18
- data/lib/dpl/providers.rb +3 -1
- data/lib/dpl/string_ext.rb +3 -1
- data/lib/dpl/support/aws_sdk_patch.rb +4 -1
- data/lib/dpl/support/gems.rb +7 -3
- data/lib/dpl/support/gstore_patch.rb +3 -1
- data/lib/dpl/support/version.rb +13 -12
- data/lib/dpl/version.rb +3 -1
- data/lib/dpl.rb +2 -0
- data/status.json +237 -0
- metadata +32 -15
- /data/lib/dpl/providers/{packagecloud.rb → packagecloud.rb_} +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Dpl
|
|
2
4
|
module Providers
|
|
3
5
|
class Cloudformation < Provider
|
|
@@ -6,9 +8,9 @@ module Dpl
|
|
|
6
8
|
|
|
7
9
|
full_name 'AWS CloudFormation'
|
|
8
10
|
|
|
9
|
-
description sq(<<-
|
|
11
|
+
description sq(<<-STR)
|
|
10
12
|
tbd
|
|
11
|
-
|
|
13
|
+
STR
|
|
12
14
|
|
|
13
15
|
gem 'aws-sdk-cloudformation', '~> 1.0'
|
|
14
16
|
|
|
@@ -24,25 +26,25 @@ module Dpl
|
|
|
24
26
|
opt '--promote', 'Deploy changes', default: true, note: 'otherwise a change set is created'
|
|
25
27
|
opt '--role_arn ARN', 'AWS Role ARN'
|
|
26
28
|
opt '--sts_assume_role ARN', 'AWS Role ARN for cross account deployments (assumed by travis using given AWS credentials).'
|
|
27
|
-
opt '--capabilities STR', 'CloudFormation allowed capabilities', type: :array, enum: %w
|
|
29
|
+
opt '--capabilities STR', 'CloudFormation allowed capabilities', type: :array, enum: %w[CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND], sep: ',', see: 'https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html'
|
|
28
30
|
opt '--wait', 'Wait for CloutFormation to finish the stack creation and update', default: true
|
|
29
31
|
opt '--wait_timeout SEC', 'How many seconds to wait for stack creation and update.', type: :integer, default: 3600
|
|
30
32
|
opt '--create_timeout SEC', 'How many seconds to wait before the stack status becomes CREATE_FAILED', type: :integer, default: 3600, note: 'valid only when creating a stack'
|
|
31
33
|
opt '--parameters STR', 'key=value pairs or ENV var names', type: :array, eg: 'one=1 or ENV_VAR_TWO'
|
|
32
34
|
opt '--output_file PATH', 'Path to output file to store CloudFormation outputs to'
|
|
33
35
|
|
|
34
|
-
msgs login:
|
|
35
|
-
create_stack:
|
|
36
|
-
promote_stack:
|
|
36
|
+
msgs login: 'Using Access Key: %{access_key_id}',
|
|
37
|
+
create_stack: 'Creating stack ...',
|
|
38
|
+
promote_stack: 'Promoting stack ...',
|
|
37
39
|
create_change_set: 'Creating change set ...',
|
|
38
|
-
stack_up_to_date:
|
|
40
|
+
stack_up_to_date: 'Stack already up to date.',
|
|
39
41
|
delete_change_set: 'No changes in stack. Removing changeset.',
|
|
40
|
-
done:
|
|
41
|
-
missing_template:
|
|
42
|
-
invalid_creds:
|
|
42
|
+
done: 'Done.',
|
|
43
|
+
missing_template: 'File does not exist: %{template}',
|
|
44
|
+
invalid_creds: 'Invalid credentials'
|
|
43
45
|
|
|
44
|
-
strs change_set_name:
|
|
45
|
-
change_set_desc:
|
|
46
|
+
strs change_set_name: 'travis-ci-build-%{build_number}-%{now}',
|
|
47
|
+
change_set_desc: 'Changeset created by Travis CI job for build #%{build_number} (%{git_sha})'
|
|
46
48
|
|
|
47
49
|
def login
|
|
48
50
|
info :login
|
|
@@ -57,221 +59,223 @@ module Dpl
|
|
|
57
59
|
|
|
58
60
|
private
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
info :stack_up_to_date
|
|
65
|
-
end
|
|
62
|
+
def update
|
|
63
|
+
promote? ? promote : create_change_set(:update)
|
|
64
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
|
65
|
+
raise e unless e.message.start_with?('No updates are to be performed')
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
client.update_stack(common_params)
|
|
70
|
-
stream_events(stack_name, :stack_update_complete) if wait?
|
|
71
|
-
info :done
|
|
72
|
-
end
|
|
67
|
+
info :stack_up_to_date
|
|
68
|
+
end
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
def promote
|
|
71
|
+
info :promote_stack
|
|
72
|
+
client.update_stack(common_params)
|
|
73
|
+
stream_events(stack_name, :stack_update_complete) if wait?
|
|
74
|
+
info :done
|
|
75
|
+
end
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
client.create_stack(common_params.merge(params))
|
|
82
|
-
stream_events(stack_name, :stack_create_complete) if wait?
|
|
83
|
-
info :done
|
|
84
|
-
end
|
|
77
|
+
def create
|
|
78
|
+
promote? ? create_stack : create_change_set(:create)
|
|
79
|
+
end
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
info :delete_change_set
|
|
94
|
-
client.delete_change_set(change_set_name: set.id)
|
|
95
|
-
end
|
|
81
|
+
def create_stack
|
|
82
|
+
info :create_stack
|
|
83
|
+
params = { timeout_in_minutes: create_timeout, on_failure: 'ROLLBACK' }
|
|
84
|
+
client.create_stack(common_params.merge(params))
|
|
85
|
+
stream_events(stack_name, :stack_create_complete) if wait?
|
|
86
|
+
info :done
|
|
87
|
+
end
|
|
96
88
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
def create_change_set(type)
|
|
90
|
+
info :create_change_set
|
|
91
|
+
set = client.create_change_set(common_params.merge(change_set_params(type)))
|
|
92
|
+
wait_for(:change_set_create_complete, change_set_name: set.id) if wait? && !test?
|
|
93
|
+
info :done
|
|
94
|
+
rescue Aws::Waiters::Errors::FailureStateError => e
|
|
95
|
+
raise e unless change_set_contains_changes?(set)
|
|
104
96
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
end
|
|
97
|
+
info :delete_change_set
|
|
98
|
+
client.delete_change_set(change_set_name: set.id)
|
|
99
|
+
end
|
|
109
100
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
def change_set_params(type)
|
|
102
|
+
{
|
|
103
|
+
change_set_type: type.to_s.upcase,
|
|
104
|
+
change_set_name: interpolate(str(:change_set_name)),
|
|
105
|
+
description: interpolate(str(:change_set_desc))
|
|
106
|
+
}
|
|
107
|
+
end
|
|
117
108
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
stream.stop unless stream.nil?
|
|
123
|
-
end
|
|
109
|
+
def change_set_contains_changes?(change_set)
|
|
110
|
+
data = client.describe_change_set(change_set_name: change_set.id)
|
|
111
|
+
data.status_reason.start_with?(%(The submitted information didn't contain changes))
|
|
112
|
+
end
|
|
124
113
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
end
|
|
114
|
+
def stack_exists?
|
|
115
|
+
stack = last_stack
|
|
116
|
+
stack && stack.stack_status != 'REVIEW_IN_PROGRESS'
|
|
117
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
|
118
|
+
raise e unless e.message.include?('does not exist')
|
|
131
119
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
logs = logs.map { |log| "#{log[:output_key]}=#{log[:output_value]}" }
|
|
135
|
-
File.write(output_file, logs.join("\n"))
|
|
136
|
-
end
|
|
120
|
+
false
|
|
121
|
+
end
|
|
137
122
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
def stream_events(stack_name, condition)
|
|
124
|
+
stream = EventStream.new(client, stack_name, method(:info))
|
|
125
|
+
wait_for(condition, stack_name:) unless test? # hmm.
|
|
126
|
+
ensure
|
|
127
|
+
stream&.stop
|
|
128
|
+
end
|
|
141
129
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
params.merge!(template_param)
|
|
150
|
-
@common_params ||= compact(params)
|
|
151
|
-
end
|
|
130
|
+
def wait_for(cond, params)
|
|
131
|
+
started_at = Time.now
|
|
132
|
+
timeout = ->(*) { throw :failure if Time.now - started_at > wait_timeout }
|
|
133
|
+
# params = params.merge(max_attempts: nil, delay: 5, before_wait: timeout)
|
|
134
|
+
client.wait_until(cond, params) { |w| w.before_wait(&timeout) }
|
|
135
|
+
end
|
|
152
136
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
end
|
|
137
|
+
def store_events
|
|
138
|
+
logs = last_stack.outputs || {}
|
|
139
|
+
logs = logs.map { |log| "#{log[:output_key]}=#{log[:output_value]}" }
|
|
140
|
+
File.write(output_file, logs.join("\n"))
|
|
141
|
+
end
|
|
159
142
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
143
|
+
def last_stack
|
|
144
|
+
client.describe_stacks(stack_name:)[:stacks].first
|
|
145
|
+
end
|
|
163
146
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
147
|
+
def common_params
|
|
148
|
+
params = {
|
|
149
|
+
stack_name:,
|
|
150
|
+
role_arn:,
|
|
151
|
+
capabilities:,
|
|
152
|
+
parameters:
|
|
153
|
+
}
|
|
154
|
+
params.merge!(template_param)
|
|
155
|
+
@common_params ||= compact(params)
|
|
156
|
+
end
|
|
167
157
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
error(:missing_template)
|
|
158
|
+
def parameters
|
|
159
|
+
@parameters ||= Array(super).map do |str|
|
|
160
|
+
key, value = str.split('=', 2)
|
|
161
|
+
{ parameter_key: key, parameter_value: value || ENV[key] }
|
|
173
162
|
end
|
|
163
|
+
end
|
|
174
164
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
165
|
+
def create_timeout
|
|
166
|
+
super / 60
|
|
167
|
+
end
|
|
178
168
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
params
|
|
183
|
-
end
|
|
169
|
+
def stack_name
|
|
170
|
+
@stack_name ||= "#{stack_name_prefix}#{super}"
|
|
171
|
+
end
|
|
184
172
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
173
|
+
def template_param
|
|
174
|
+
str = template
|
|
175
|
+
return { template_url: str } if url?(str)
|
|
176
|
+
return { template_body: read(str) } if file?(str)
|
|
188
177
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
role_arn: sts_assume_role,
|
|
192
|
-
role_session_name: "travis-build-#{build_number}"
|
|
193
|
-
)
|
|
194
|
-
Aws::Credentials.new(
|
|
195
|
-
assumed_role.credentials.access_key_id,
|
|
196
|
-
assumed_role.credentials.secret_access_key,
|
|
197
|
-
assumed_role.credentials.session_token
|
|
198
|
-
)
|
|
199
|
-
end
|
|
178
|
+
error(:missing_template)
|
|
179
|
+
end
|
|
200
180
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
def client
|
|
182
|
+
@client ||= Aws::CloudFormation::Client.new(client_options)
|
|
183
|
+
end
|
|
204
184
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
185
|
+
def client_options
|
|
186
|
+
params = { region:, credentials: }
|
|
187
|
+
params = params.merge(credentials: assume_role(params)) if sts_assume_role?
|
|
188
|
+
params
|
|
189
|
+
end
|
|
208
190
|
|
|
209
|
-
|
|
210
|
-
|
|
191
|
+
def credentials
|
|
192
|
+
Aws::Credentials.new(access_key_id, secret_access_key)
|
|
193
|
+
end
|
|
211
194
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
195
|
+
def assume_role(params)
|
|
196
|
+
assumed_role = Aws::STS::Client.new(params).assume_role(
|
|
197
|
+
role_arn: sts_assume_role,
|
|
198
|
+
role_session_name: "travis-build-#{build_number}"
|
|
199
|
+
)
|
|
200
|
+
Aws::Credentials.new(
|
|
201
|
+
assumed_role.credentials.access_key_id,
|
|
202
|
+
assumed_role.credentials.secret_access_key,
|
|
203
|
+
assumed_role.credentials.session_token
|
|
204
|
+
)
|
|
205
|
+
end
|
|
217
206
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
end
|
|
207
|
+
def now
|
|
208
|
+
Time.now.strftime('%Y%m%d%H%M%S')
|
|
209
|
+
end
|
|
222
210
|
|
|
223
|
-
|
|
211
|
+
def url?(str)
|
|
212
|
+
str =~ %r{^https?://}
|
|
213
|
+
end
|
|
224
214
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
@event, events = events_since(@event)
|
|
228
|
-
events.each { |e| handler.call(format_event(e)) }
|
|
229
|
-
sleep 5 unless ENV['ENV'] == 'test'
|
|
230
|
-
end
|
|
231
|
-
end
|
|
215
|
+
class EventStream < Struct.new(:client, :stack_name, :handler)
|
|
216
|
+
attr_reader :thread
|
|
232
217
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
218
|
+
def initialize(*)
|
|
219
|
+
super
|
|
220
|
+
@event = describe_stack_events.stack_events.first
|
|
221
|
+
@thread = Thread.new(&method(:process))
|
|
222
|
+
end
|
|
238
223
|
|
|
239
|
-
|
|
240
|
-
|
|
224
|
+
def stop
|
|
225
|
+
mutex.synchronize { @stop = true }
|
|
226
|
+
thread.join
|
|
227
|
+
end
|
|
241
228
|
|
|
229
|
+
private
|
|
242
230
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
231
|
+
def process
|
|
232
|
+
until mutex.synchronize { @stop }
|
|
233
|
+
@event, events = events_since(@event)
|
|
234
|
+
events.each { |e| handler.call(format_event(e)) }
|
|
235
|
+
sleep 5 unless ENV['ENV'] == 'test'
|
|
236
|
+
end
|
|
237
|
+
end
|
|
249
238
|
|
|
250
|
-
|
|
251
|
-
|
|
239
|
+
# source: https://github.com/rvedotrc/cfn-events/blob/master/lib/cfn-events/runner.rb
|
|
240
|
+
def events_since(event)
|
|
241
|
+
described_stack = describe_stack_events
|
|
242
|
+
stack_events = described_stack.stack_events
|
|
243
|
+
return [event, []] if stack_events.first.event_id == event.event_id
|
|
244
|
+
|
|
245
|
+
events = []
|
|
246
|
+
described_stack.each_page do |page|
|
|
247
|
+
if (oldest_new = page.stack_events.index { |e| e.event_id == event.event_id })
|
|
248
|
+
events.concat(page.stack_events[0..oldest_new - 1])
|
|
249
|
+
return [events.first, events.reverse]
|
|
252
250
|
end
|
|
251
|
+
events.concat(page.stack_events)
|
|
252
|
+
end
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
warn %(Last-seen stack event is no longer returned by AWS. Please raise this as a provider's bug.)
|
|
255
|
+
[events.first, events.reverse]
|
|
256
|
+
end
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
def describe_stack_events
|
|
259
|
+
client.describe_stack_events(stack_name:)
|
|
260
|
+
end
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
def mutex
|
|
263
|
+
@mutex ||= Mutex.new
|
|
264
|
+
end
|
|
264
265
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
parts[0] = format_timestamp(parts[0])
|
|
268
|
-
parts.join(' ')
|
|
269
|
-
end
|
|
266
|
+
EVENT_KEYS = %i[timestamp resource_type resource_status logical_resource_id
|
|
267
|
+
physical_resource_id resource_status_reason].freeze
|
|
270
268
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
269
|
+
def format_event(event)
|
|
270
|
+
parts = EVENT_KEYS.map { |key| event.send(key) }
|
|
271
|
+
parts[0] = format_timestamp(parts[0])
|
|
272
|
+
parts.join(' ')
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def format_timestamp(timestamp)
|
|
276
|
+
timestamp.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
|
274
277
|
end
|
|
278
|
+
end
|
|
275
279
|
end
|
|
276
280
|
end
|
|
277
281
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Dpl
|
|
2
4
|
module Providers
|
|
3
5
|
class Cloudfoundry < Provider
|
|
@@ -7,9 +9,9 @@ module Dpl
|
|
|
7
9
|
|
|
8
10
|
full_name 'Cloud Foundry'
|
|
9
11
|
|
|
10
|
-
description sq(<<-
|
|
12
|
+
description sq(<<-STR)
|
|
11
13
|
tbd
|
|
12
|
-
|
|
14
|
+
STR
|
|
13
15
|
|
|
14
16
|
env :cloudfoundry
|
|
15
17
|
|
|
@@ -23,20 +25,20 @@ module Dpl
|
|
|
23
25
|
opt '--manifest FILE', 'Path to the manifest'
|
|
24
26
|
opt '--skip_ssl_validation', 'Skip SSL validation'
|
|
25
27
|
opt '--deployment_strategy STRATEGY', 'Deployment strategy, either rolling or null'
|
|
26
|
-
opt '--v3',
|
|
28
|
+
opt '--v3', 'Use the v3 API version to push the application'
|
|
27
29
|
opt '--logout', default: true, internal: true
|
|
28
30
|
|
|
29
31
|
cmds install: 'test $(uname) = "Linux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&version=v7&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz',
|
|
30
|
-
api:
|
|
31
|
-
login:
|
|
32
|
-
push:
|
|
33
|
-
logout:
|
|
32
|
+
api: './cf api %{api} %{skip_ssl_validation_opt}',
|
|
33
|
+
login: './cf login -u %{username} -p %{password} -o %{organization} -s %{space}',
|
|
34
|
+
push: './cf %{push_cmd} %{push_args}',
|
|
35
|
+
logout: './cf logout'
|
|
34
36
|
|
|
35
37
|
errs install: 'Failed to install CLI tools',
|
|
36
|
-
api:
|
|
37
|
-
login:
|
|
38
|
-
push:
|
|
39
|
-
logout:
|
|
38
|
+
api: 'Failed to set api %{api}',
|
|
39
|
+
login: 'Failed to login',
|
|
40
|
+
push: 'Failed to push app',
|
|
41
|
+
logout: 'Failed to logout'
|
|
40
42
|
|
|
41
43
|
msgs manifest_missing: 'Application must have a manifest.yml for unattended deployment'
|
|
42
44
|
|
|
@@ -63,25 +65,25 @@ module Dpl
|
|
|
63
65
|
|
|
64
66
|
private
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
def push_cmd
|
|
69
|
+
v3? ? 'v3-push' : 'push'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def push_args
|
|
73
|
+
args = []
|
|
74
|
+
args << quote(app_name) if app_name?
|
|
75
|
+
args << "-f #{manifest}" if manifest?
|
|
76
|
+
args << "--strategy #{deployment_strategy}" if deployment_strategy?
|
|
77
|
+
args.join(' ')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def skip_ssl_validation_opt
|
|
81
|
+
'--skip-ssl-validation' if skip_ssl_validation?
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def manifest_missing?
|
|
85
|
+
!File.exist?(manifest)
|
|
86
|
+
end
|
|
85
87
|
end
|
|
86
88
|
end
|
|
87
89
|
end
|