dpl 2.0.3.beta.4 → 2.0.3.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -3
  3. data/Gemfile.lock +444 -211
  4. data/Rakefile +36 -34
  5. data/bin/dpl +3 -1
  6. data/dpl.gemspec +25 -0
  7. data/lib/dpl/cli.rb +19 -14
  8. data/lib/dpl/ctx/bash.rb +18 -12
  9. data/lib/dpl/ctx/test.rb +21 -15
  10. data/lib/dpl/ctx.rb +2 -0
  11. data/lib/dpl/helper/assets.rb +4 -2
  12. data/lib/dpl/helper/cmd.rb +20 -18
  13. data/lib/dpl/helper/config_file.rb +5 -3
  14. data/lib/dpl/helper/cookbook_site_streaming_uploader.rb +249 -0
  15. data/lib/dpl/helper/env.rb +26 -22
  16. data/lib/dpl/helper/github.rb +2 -0
  17. data/lib/dpl/helper/interpolate.rb +8 -4
  18. data/lib/dpl/helper/memoize.rb +4 -1
  19. data/lib/dpl/helper/squiggle.rb +3 -1
  20. data/lib/dpl/helper/transliterate.rb +3 -1
  21. data/lib/dpl/helper/wrap.rb +3 -1
  22. data/lib/dpl/helper/zip.rb +3 -1
  23. data/lib/dpl/provider/dsl.rb +18 -4
  24. data/lib/dpl/provider/examples.rb +6 -2
  25. data/lib/dpl/provider/status.rb +26 -24
  26. data/lib/dpl/providers/anynines.rb +22 -20
  27. data/lib/dpl/providers/azure_web_apps.rb +21 -19
  28. data/lib/dpl/providers/bintray.rb +44 -37
  29. data/lib/dpl/providers/bluemixcloudfoundry.rb +38 -36
  30. data/lib/dpl/providers/boxfuse.rb +12 -10
  31. data/lib/dpl/providers/cargo.rb +7 -5
  32. data/lib/dpl/providers/chef_supermarket.rb +82 -80
  33. data/lib/dpl/providers/cloud66.rb +17 -15
  34. data/lib/dpl/providers/cloudfiles.rb +8 -6
  35. data/lib/dpl/providers/cloudformation.rb +191 -187
  36. data/lib/dpl/providers/cloudfoundry.rb +32 -30
  37. data/lib/dpl/providers/codedeploy.rb +35 -33
  38. data/lib/dpl/providers/convox.rb +32 -25
  39. data/lib/dpl/providers/datica.rb +30 -28
  40. data/lib/dpl/providers/ecr.rb +66 -64
  41. data/lib/dpl/providers/elasticbeanstalk.rb +14 -12
  42. data/lib/dpl/providers/engineyard.rb +60 -58
  43. data/lib/dpl/providers/firebase.rb +6 -4
  44. data/lib/dpl/providers/flynn.rb +8 -6
  45. data/lib/dpl/providers/gae.rb +28 -25
  46. data/lib/dpl/providers/gcs.rb +59 -57
  47. data/lib/dpl/providers/git_push.rb +199 -195
  48. data/lib/dpl/providers/gleis.rb +19 -17
  49. data/lib/dpl/providers/hackage.rb +15 -13
  50. data/lib/dpl/providers/hephy.rb +18 -16
  51. data/lib/dpl/providers/heroku/api.rb +72 -70
  52. data/lib/dpl/providers/heroku/git.rb +15 -13
  53. data/lib/dpl/providers/heroku.rb +40 -38
  54. data/lib/dpl/providers/lambda.rb +134 -134
  55. data/lib/dpl/providers/launchpad.rb +45 -43
  56. data/lib/dpl/providers/netlify.rb +7 -5
  57. data/lib/dpl/providers/npm.rb +61 -58
  58. data/lib/dpl/providers/nuget.rb +8 -6
  59. data/lib/dpl/providers/openshift.rb +8 -6
  60. data/lib/dpl/providers/opsworks.rb +23 -21
  61. data/lib/dpl/providers/pages/api.rb +14 -14
  62. data/lib/dpl/providers/pages/git.rb +53 -47
  63. data/lib/dpl/providers/pages.rb +3 -1
  64. data/lib/dpl/providers/puppetforge.rb +6 -4
  65. data/lib/dpl/providers/pypi.rb +55 -54
  66. data/lib/dpl/providers/releases.rb +30 -23
  67. data/lib/dpl/providers/rubygems.rb +35 -31
  68. data/lib/dpl/providers/s3.rb +148 -142
  69. data/lib/dpl/providers/scalingo.rb +18 -16
  70. data/lib/dpl/providers/script.rb +4 -2
  71. data/lib/dpl/providers/snap.rb +12 -9
  72. data/lib/dpl/providers/surge.rb +7 -5
  73. data/lib/dpl/providers/testfairy.rb +47 -43
  74. data/lib/dpl/providers/transifex.rb +20 -18
  75. data/lib/dpl/providers.rb +3 -1
  76. data/lib/dpl/string_ext.rb +3 -1
  77. data/lib/dpl/support/aws_sdk_patch.rb +4 -1
  78. data/lib/dpl/support/gems.rb +7 -3
  79. data/lib/dpl/support/gstore_patch.rb +3 -1
  80. data/lib/dpl/support/version.rb +13 -12
  81. data/lib/dpl/version.rb +3 -1
  82. data/lib/dpl.rb +2 -0
  83. data/status.json +237 -0
  84. metadata +32 -15
  85. /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 Heroku
@@ -8,22 +10,22 @@ module Dpl
8
10
 
9
11
  full_name 'Heroku API'
10
12
 
11
- description sq(<<-str)
13
+ description sq(<<-STR)
12
14
  tbd
13
- str
15
+ STR
14
16
 
15
17
  opt '--api_key KEY', 'Heroku API key', required: true, secret: true
16
18
  opt '--version VERSION', internal: true # used in triggering a build, not sure this should be exposed?
17
19
 
18
- msgs pack: 'Creating application archive',
19
- upload: 'Uploading application archive',
20
- build: 'Triggering Heroku build (deployment)',
20
+ msgs pack: 'Creating application archive',
21
+ upload: 'Uploading application archive',
22
+ build: 'Triggering Heroku build (deployment)',
21
23
  pending: 'Heroku build still pending',
22
- failed: 'Heroku build failed'
24
+ failed: 'Heroku build failed'
23
25
 
24
- cmds pack: 'tar -zcf %{escaped_archive_file} --exclude .git .',
25
- upload: 'curl %{curl_opts} %{escaped_put_url} -X PUT -H "Content-Type:" -H "Accept: application/vnd.heroku+json; version=3" -H "User-Agent: %{user_agent}" --data-binary @%{escaped_archive_file}',
26
- log: 'curl %{curl_opts} %{escaped_output_stream_url} -H "Accept: application/vnd.heroku+json; version=3" -H "User-Agent: %{user_agent}"'
26
+ cmds pack: 'tar -zcf %{escaped_archive_file} --exclude .git .',
27
+ upload: 'curl %{curl_opts} %{escaped_put_url} -X PUT -H "Content-Type:" -H "Accept: application/vnd.heroku+json; version=3" -H "User-Agent: %{user_agent}" --data-binary @%{escaped_archive_file}',
28
+ log: 'curl %{curl_opts} %{escaped_output_stream_url} -H "Accept: application/vnd.heroku+json; version=3" -H "User-Agent: %{user_agent}"'
27
29
 
28
30
  attr_reader :data
29
31
 
@@ -37,84 +39,84 @@ module Dpl
37
39
 
38
40
  private
39
41
 
40
- def pack
41
- shell :pack
42
- end
42
+ def pack
43
+ shell :pack
44
+ end
43
45
 
44
- def upload
45
- shell :upload, echo: false
46
- end
46
+ def upload
47
+ shell :upload, echo: false
48
+ end
47
49
 
48
- def build
49
- info :build
50
- res = http.post("/apps/#{app}/builds") do |req|
51
- req.headers['Content-Type'] = 'application/json'
52
- req.body = JSON.dump(source_blob: { url: get_url, version: version })
53
- end
54
- handle_error(res) unless res.success?
55
- @data = symbolize(JSON.parse(res.body))
50
+ def build
51
+ info :build
52
+ res = http.post("/apps/#{app}/builds") do |req|
53
+ req.headers['Content-Type'] = 'application/json'
54
+ req.body = JSON.dump(source_blob: { url: get_url, version: })
56
55
  end
56
+ handle_error(res) unless res.success?
57
+ @data = symbolize(JSON.parse(res.body))
58
+ end
57
59
 
58
- def log
59
- shell :log, echo: false
60
- end
60
+ def log
61
+ shell :log, echo: false
62
+ end
61
63
 
62
- def verify
63
- loop do
64
- case build_status
65
- when 'pending'
66
- info :pending
67
- sleep 5
68
- when 'succeeded'
69
- break
70
- else
71
- error :failed
72
- end
64
+ def verify
65
+ loop do
66
+ case build_status
67
+ when 'pending'
68
+ info :pending
69
+ sleep 5
70
+ when 'succeeded'
71
+ break
72
+ else
73
+ error :failed
73
74
  end
74
75
  end
76
+ end
75
77
 
76
- def build_status
77
- res = http.get("/apps/#{app}/builds/#{build_id}")
78
- JSON.parse(res.body)['status']
79
- end
78
+ def build_status
79
+ res = http.get("/apps/#{app}/builds/#{build_id}")
80
+ JSON.parse(res.body)['status']
81
+ end
80
82
 
81
- def archive_file
82
- expand("~/.dpl.#{app}.tgz")
83
- end
83
+ def archive_file
84
+ expand("~/.dpl.#{app}.tgz")
85
+ end
84
86
 
85
- def get_url
86
- source['get_url']
87
- end
87
+ def get_url
88
+ source['get_url']
89
+ end
88
90
 
89
- def put_url
90
- source['put_url']
91
- end
91
+ def put_url
92
+ source['put_url']
93
+ end
92
94
 
93
- def source
94
- # this says the endpoint /sources is deprecated: https://devcenter.heroku.com/articles/platform-api-reference#source
95
- # this says to use /apps/example-app/sources: https://devcenter.heroku.com/articles/build-and-release-using-the-api#sources-endpoint
96
- @source ||= begin
97
- res = http.post('/sources')
98
- handle_error(res) unless res.success?
99
- JSON.parse(res.body)['source_blob']
100
- end
95
+ def source
96
+ # this says the endpoint /sources is deprecated: https://devcenter.heroku.com/articles/platform-api-reference#source
97
+ # this says to use /apps/example-app/sources: https://devcenter.heroku.com/articles/build-and-release-using-the-api#sources-endpoint
98
+ @source ||= begin
99
+ res = http.post('/sources')
100
+ handle_error(res) unless res.success?
101
+ JSON.parse(res.body)['source_blob']
101
102
  end
103
+ end
102
104
 
103
- def build_id
104
- data[:id]
105
- end
105
+ def build_id
106
+ data[:id]
107
+ end
106
108
 
107
- def output_stream_url
108
- data[:output_stream_url]
109
- end
109
+ def output_stream_url
110
+ data[:output_stream_url]
111
+ end
110
112
 
111
- def version
112
- super || git_sha
113
- end
113
+ def version
114
+ super || git_sha
115
+ end
114
116
 
115
- def curl_opts
116
- tty? ? '' : '-sS'
117
- end
117
+ def curl_opts
118
+ tty? ? '' : '-sS'
119
+ end
118
120
  end
119
121
  end
120
122
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  module Providers
3
5
  class Heroku
@@ -8,11 +10,11 @@ module Dpl
8
10
 
9
11
  full_name 'Heroku Git'
10
12
 
11
- description sq(<<-str)
13
+ description sq(<<-STR)
12
14
  tbd
13
- str
15
+ STR
14
16
 
15
- required :api_key, [:username, :password]
17
+ required :api_key, %i[username password]
16
18
 
17
19
  opt '--api_key KEY', 'Heroku API key', secret: true
18
20
  opt '--username USER', 'Heroku username', alias: :user
@@ -22,7 +24,7 @@ module Dpl
22
24
  needs :git, :git_http_user_agent
23
25
 
24
26
  cmds fetch: 'git fetch origin $TRAVIS_BRANCH --unshallow',
25
- push: 'git push %{remote} HEAD:refs/heads/master -f'
27
+ push: 'git push %{remote} HEAD:refs/heads/master -f'
26
28
 
27
29
  def prepare
28
30
  write_netrc if write_netrc?
@@ -35,17 +37,17 @@ module Dpl
35
37
 
36
38
  private
37
39
 
38
- def remote
39
- git || "https://git.heroku.com/#{app}.git"
40
- end
40
+ def remote
41
+ git || "https://git.heroku.com/#{app}.git"
42
+ end
41
43
 
42
- def write_netrc?
43
- remote.start_with?('https://')
44
- end
44
+ def write_netrc?
45
+ remote.start_with?('https://')
46
+ end
45
47
 
46
- def write_netrc
47
- super('git.heroku.com', email, api_key || password)
48
- end
48
+ def write_netrc
49
+ super('git.heroku.com', email, api_key || password)
50
+ end
49
51
  end
50
52
  end
51
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  module Providers
3
5
  class Heroku < Provider
@@ -5,30 +7,29 @@ module Dpl
5
7
 
6
8
  abstract
7
9
 
8
- gem 'faraday', '~> 0.9.2'
9
- gem 'json'
10
+ gem 'faraday', '~> 1'
10
11
  gem 'netrc', '~> 0.11.0'
11
12
  gem 'rendezvous', '~> 0.1.3'
12
13
 
13
14
  env :heroku
14
15
 
15
- opt '--strategy NAME', 'Heroku deployment strategy', default: 'api', enum: %w(api git)
16
+ opt '--strategy NAME', 'Heroku deployment strategy', default: 'api', enum: %w[api git]
16
17
  opt '--app APP', 'Heroku app name', default: :repo_name
17
18
  opt '--log_level LEVEL', internal: true
18
19
 
19
- msgs login: 'Authenticating ... ',
20
- restart: 'Restarting dynos ... ',
21
- validate: 'Checking for app %{app} ... ',
22
- run_cmd: 'Running command %s ... ',
23
- success: 'success.',
20
+ msgs login: 'Authenticating ... ',
21
+ restart: 'Restarting dynos ... ',
22
+ validate: 'Checking for app %{app} ... ',
23
+ run_cmd: 'Running command %s ... ',
24
+ success: 'success.',
24
25
  api_error: 'API request failed: %s (see %s)'
25
26
 
26
27
  URL = 'https://api.heroku.com'
27
28
 
28
29
  HEADERS = {
29
30
  'Accept': 'application/vnd.heroku+json; version=3',
30
- 'User-Agent': user_agent,
31
- }
31
+ 'User-Agent': user_agent
32
+ }.freeze
32
33
 
33
34
  attr_reader :email
34
35
 
@@ -36,7 +37,7 @@ module Dpl
36
37
  print :login
37
38
  res = http.get('/account')
38
39
  handle_error(res) unless res.success?
39
- @email = JSON.parse(res.body)["email"]
40
+ @email = JSON.parse(res.body)['email']
40
41
  info :success
41
42
  end
42
43
 
@@ -60,7 +61,7 @@ module Dpl
60
61
  print :run_cmd, cmd
61
62
  res = http.post "/apps/#{app}/dynos" do |req|
62
63
  req.headers['Content-Type'] = 'application/json'
63
- req.body = { command: cmd, attach: true}.to_json
64
+ req.body = { command: cmd, attach: true }.to_json
64
65
  end
65
66
  handle_error(res) unless res.success?
66
67
  rendezvous(JSON.parse(res.body)['attach_url'])
@@ -68,39 +69,40 @@ module Dpl
68
69
 
69
70
  private
70
71
 
71
- def http
72
- @http ||= Faraday.new(url: URL, headers: headers) do |http|
73
- http.basic_auth(username, password) if username && password
74
- http.response :logger, logger, &method(:filter) if log_level?
75
- http.adapter Faraday.default_adapter
76
- end
72
+ def http
73
+ @http ||= Faraday.new(url: URL, headers:) do |http|
74
+ http.basic_auth(username, password) if username && password
75
+ http.response :logger, logger, &method(:filter) if log_level?
76
+ http.adapter Faraday.default_adapter
77
77
  end
78
+ end
78
79
 
79
- def headers
80
- return HEADERS.dup if username && password
81
- HEADERS.merge('Authorization': "Bearer #{api_key}")
82
- end
80
+ def headers
81
+ return HEADERS.dup if username && password
83
82
 
84
- def filter(logger)
85
- logger.filter(/(.*Authorization: ).*/,'\1[REDACTED]')
86
- end
83
+ HEADERS.merge('Authorization': "Bearer #{api_key}")
84
+ end
87
85
 
88
- def logger
89
- super(log_level)
90
- end
86
+ def filter(logger)
87
+ logger.filter(/(.*Authorization: ).*/, '\1[REDACTED]')
88
+ end
91
89
 
92
- def handle_error(response)
93
- body = JSON.parse(response.body)
94
- error :api_error, body['message'], body['url']
95
- end
90
+ def logger
91
+ super(log_level)
92
+ end
96
93
 
97
- def rendezvous(url)
98
- Rendezvous.start(url: url)
99
- end
94
+ def handle_error(response)
95
+ body = JSON.parse(response.body)
96
+ error :api_error, body['message'], body['url']
97
+ end
98
+
99
+ def rendezvous(url)
100
+ Rendezvous.start(url:)
101
+ end
100
102
 
101
- # overwritten in Git, meaningless in Api
102
- def username; end
103
- def password; end
103
+ # overwritten in Git, meaningless in Api
104
+ def username; end
105
+ def password; end
104
106
  end
105
107
  end
106
108
  end