dpl 1.10.17.travis.6637.6 → 2.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +74 -0
  3. data/CONTRIBUTING.md +392 -0
  4. data/Gemfile +17 -3
  5. data/Gemfile.lock +373 -0
  6. data/LICENSE +16 -19
  7. data/NOTES.md +275 -0
  8. data/README.md +1977 -707
  9. data/Rakefile +2 -2
  10. data/bin/dpl +7 -3
  11. data/lib/dpl.rb +20 -0
  12. data/lib/dpl/assets/atlas/install +19 -0
  13. data/lib/dpl/assets/dpl/README.erb.md +133 -0
  14. data/lib/dpl/assets/dpl/git_ssh +2 -0
  15. data/lib/dpl/assets/git/detect_private_key +8 -0
  16. data/lib/dpl/assets/hephy/filter_log +3 -0
  17. data/lib/dpl/assets/pypi/install +4 -0
  18. data/lib/dpl/assets/scalingo/install +6 -0
  19. data/lib/dpl/cli.rb +36 -48
  20. data/lib/dpl/ctx.rb +2 -0
  21. data/lib/dpl/ctx/bash.rb +543 -0
  22. data/lib/dpl/ctx/test.rb +242 -0
  23. data/lib/dpl/helper/assets.rb +36 -0
  24. data/lib/dpl/helper/cmd.rb +167 -0
  25. data/lib/dpl/helper/config_file.rb +47 -0
  26. data/lib/dpl/helper/env.rb +39 -0
  27. data/lib/dpl/helper/interpolate.rb +126 -0
  28. data/lib/dpl/helper/memoize.rb +20 -0
  29. data/lib/dpl/helper/squiggle.rb +22 -0
  30. data/lib/dpl/helper/zip.rb +69 -0
  31. data/lib/dpl/provider.rb +562 -234
  32. data/lib/dpl/provider/dsl.rb +369 -0
  33. data/lib/dpl/provider/examples.rb +128 -0
  34. data/lib/dpl/provider/status.rb +59 -0
  35. data/lib/dpl/providers.rb +40 -0
  36. data/lib/dpl/providers/anynines.rb +65 -0
  37. data/lib/dpl/providers/atlas.rb +49 -0
  38. data/lib/dpl/providers/azure_web_apps.rb +59 -0
  39. data/lib/dpl/providers/bintray.rb +313 -0
  40. data/lib/dpl/providers/bluemixcloudfoundry.rb +92 -0
  41. data/lib/dpl/providers/boxfuse.rb +48 -0
  42. data/lib/dpl/providers/cargo.rb +19 -0
  43. data/lib/dpl/providers/chef_supermarket.rb +128 -0
  44. data/lib/dpl/providers/cloud66.rb +40 -0
  45. data/lib/dpl/providers/cloudfiles.rb +56 -0
  46. data/lib/dpl/providers/cloudfoundry.rb +81 -0
  47. data/lib/dpl/providers/codedeploy.rb +179 -0
  48. data/lib/dpl/providers/datica.rb +60 -0
  49. data/lib/dpl/providers/elasticbeanstalk.rb +195 -0
  50. data/lib/dpl/providers/engineyard.rb +107 -0
  51. data/lib/dpl/providers/firebase.rb +41 -0
  52. data/lib/dpl/providers/gae.rb +74 -0
  53. data/lib/dpl/providers/gcs.rb +105 -0
  54. data/lib/dpl/providers/hackage.rb +47 -0
  55. data/lib/dpl/providers/hephy.rb +101 -0
  56. data/lib/dpl/providers/heroku.rb +111 -0
  57. data/lib/dpl/providers/heroku/api.rb +119 -0
  58. data/lib/dpl/providers/heroku/git.rb +50 -0
  59. data/lib/dpl/providers/lambda.rb +202 -0
  60. data/lib/dpl/providers/launchpad.rb +74 -0
  61. data/lib/dpl/providers/netlify.rb +30 -0
  62. data/lib/dpl/providers/npm.rb +88 -0
  63. data/lib/dpl/providers/openshift.rb +46 -0
  64. data/lib/dpl/providers/opsworks.rb +142 -0
  65. data/lib/dpl/providers/packagecloud.rb +190 -0
  66. data/lib/dpl/providers/pages.rb +17 -0
  67. data/lib/dpl/providers/pages/api.rb +102 -0
  68. data/lib/dpl/providers/pages/git.rb +251 -0
  69. data/lib/dpl/providers/puppetforge.rb +44 -0
  70. data/lib/dpl/providers/pypi.rb +120 -0
  71. data/lib/dpl/providers/releases.rb +214 -0
  72. data/lib/dpl/providers/rubygems.rb +89 -0
  73. data/lib/dpl/providers/s3.rb +243 -0
  74. data/lib/dpl/providers/scalingo.rb +63 -0
  75. data/lib/dpl/providers/script.rb +28 -0
  76. data/lib/dpl/providers/snap.rb +59 -0
  77. data/lib/dpl/providers/surge.rb +55 -0
  78. data/lib/dpl/providers/testfairy.rb +93 -0
  79. data/lib/dpl/providers/transifex.rb +66 -0
  80. data/lib/dpl/support/aws_sdk_patch.rb +23 -0
  81. data/lib/dpl/support/gems.rb +69 -0
  82. data/lib/dpl/support/gstore_patch.rb +6 -0
  83. data/lib/dpl/support/version.rb +83 -0
  84. data/lib/dpl/version.rb +2 -2
  85. metadata +98 -169
  86. data/.coveralls.yml +0 -1
  87. data/.github/CONTRIBUTING.md +0 -173
  88. data/.github/stale.yml +0 -53
  89. data/.gitignore +0 -13
  90. data/.rspec +0 -2
  91. data/.travis.yml +0 -56
  92. data/dpl-anynines.gemspec +0 -3
  93. data/dpl-atlas.gemspec +0 -3
  94. data/dpl-azure_webapps.gemspec +0 -3
  95. data/dpl-bintray.gemspec +0 -3
  96. data/dpl-bitballoon.gemspec +0 -3
  97. data/dpl-bluemix_cloud_foundry.gemspec +0 -3
  98. data/dpl-boxfuse.gemspec +0 -3
  99. data/dpl-cargo.gemspec +0 -3
  100. data/dpl-catalyze.gemspec +0 -3
  101. data/dpl-chef_supermarket.gemspec +0 -20
  102. data/dpl-cloud66.gemspec +0 -3
  103. data/dpl-cloud_files.gemspec +0 -3
  104. data/dpl-cloud_foundry.gemspec +0 -3
  105. data/dpl-code_deploy.gemspec +0 -3
  106. data/dpl-deis.gemspec +0 -3
  107. data/dpl-elastic_beanstalk.gemspec +0 -3
  108. data/dpl-engine_yard.gemspec +0 -3
  109. data/dpl-firebase.gemspec +0 -3
  110. data/dpl-gae.gemspec +0 -3
  111. data/dpl-gcs.gemspec +0 -3
  112. data/dpl-hackage.gemspec +0 -3
  113. data/dpl-hephy.gemspec +0 -3
  114. data/dpl-heroku.gemspec +0 -3
  115. data/dpl-lambda.gemspec +0 -3
  116. data/dpl-launchpad.gemspec +0 -3
  117. data/dpl-npm.gemspec +0 -3
  118. data/dpl-openshift.gemspec +0 -3
  119. data/dpl-ops_works.gemspec +0 -3
  120. data/dpl-packagecloud.gemspec +0 -3
  121. data/dpl-pages.gemspec +0 -3
  122. data/dpl-puppet_forge.gemspec +0 -3
  123. data/dpl-pypi.gemspec +0 -3
  124. data/dpl-releases.gemspec +0 -8
  125. data/dpl-rubygems.gemspec +0 -3
  126. data/dpl-s3.gemspec +0 -3
  127. data/dpl-scalingo.gemspec +0 -3
  128. data/dpl-script.gemspec +0 -3
  129. data/dpl-snap.gemspec +0 -3
  130. data/dpl-surge.gemspec +0 -3
  131. data/dpl-testfairy.gemspec +0 -3
  132. data/dpl-transifex.gemspec +0 -3
  133. data/dpl.gemspec +0 -3
  134. data/gemspec_helper.rb +0 -51
  135. data/lib/dpl/error.rb +0 -3
  136. data/notes/engine_yard.md +0 -1
  137. data/notes/heroku.md +0 -3
  138. data/spec/cli_spec.rb +0 -36
  139. data/spec/provider_spec.rb +0 -191
  140. data/spec/spec_helper.rb +0 -20
@@ -0,0 +1,92 @@
1
+ module Dpl
2
+ module Providers
3
+ class Bluemixcloudfoundry < Provider
4
+ status :alpha
5
+
6
+ full_name 'Bluemix Cloud Foundry'
7
+
8
+ description sq(<<-str)
9
+ tbd
10
+ str
11
+
12
+ opt '--username USER', 'Bluemix username', required: true
13
+ opt '--password PASS', 'Bluemix password', required: true, secret: true
14
+ opt '--organization ORG', 'Bluemix target organization', required: true
15
+ opt '--space SPACE', 'Bluemix target space', required: true
16
+ opt '--region REGION', 'Bluemix region', default: 'ng', enum: %w(ng eu-gb eu-de au-syd)
17
+ opt '--api URL', 'Bluemix api URL'
18
+ opt '--app_name APP', 'Application name'
19
+ opt '--buildpack PACK', 'Custom buildpack name or Git URL'
20
+ opt '--manifest FILE', 'Path to the manifest'
21
+ opt '--skip_ssl_validation', 'Skip SSL validation'
22
+ opt '--logout', default: true, internal: true
23
+
24
+ API = {
25
+ 'ng': 'api.ng.bluemix.net',
26
+ 'eu-gb': 'api.eu-gb.bluemix.net',
27
+ 'eu-de': 'api.eu-de.bluemix.net',
28
+ 'au-syd': 'api.au-syd.bluemix.net'
29
+ }
30
+
31
+ cmds install: 'test $(uname) = "Linux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz',
32
+ api: './cf api %{api} %{skip_ssl_validation_opt}',
33
+ login: './cf login -u %{username} -p %{password}',
34
+ target: './cf target -o %{organization} -s %{space}',
35
+ push: './cf push %{push_args}',
36
+ logout: './cf logout'
37
+
38
+ errs install: 'Failed to install CLI tools',
39
+ api: 'Failed to set api %{api}',
40
+ login: 'Failed to login',
41
+ target: 'Failed to target organization %{organization}, space %{space}',
42
+ push: 'Failed to push app',
43
+ logout: 'Failed to logout'
44
+
45
+ msgs manifest_missing: 'Application must have a manifest.yml for unattended deployment'
46
+
47
+ def install
48
+ shell :install
49
+ end
50
+
51
+ def validate
52
+ error :manifest_missing if manifest? && manifest_missing?
53
+ end
54
+
55
+ def login
56
+ shell :api
57
+ shell :login
58
+ shell :target
59
+ end
60
+
61
+ def deploy
62
+ shell :push
63
+ end
64
+
65
+ def finish
66
+ shell :logout if logout?
67
+ end
68
+
69
+ private
70
+
71
+ def push_args
72
+ args = []
73
+ args << quote(app_name) if app_name?
74
+ args << "-f #{manifest}" if manifest?
75
+ args << "-b #{buildpack}" if buildpack?
76
+ args.join(' ')
77
+ end
78
+
79
+ def skip_ssl_validation_opt
80
+ '--skip-ssl-validation' if skip_ssl_validation?
81
+ end
82
+
83
+ def manifest_missing?
84
+ !File.exists?(manifest)
85
+ end
86
+
87
+ def api
88
+ super || API[region.to_sym]
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,48 @@
1
+ module Dpl
2
+ module Providers
3
+ class Boxfuse < Provider
4
+ status :alpha
5
+
6
+ description sq(<<-str)
7
+ tbd
8
+ str
9
+
10
+ env :boxfuse
11
+
12
+ opt '--user USER', required: true
13
+ opt '--secret SECRET', required: true, secret: true
14
+ opt '--config_file FILE', alias: :configfile, deprecated: :configfile
15
+ opt '--payload PAYLOAD'
16
+ opt '--app APP'
17
+ opt '--version VERSION'
18
+ opt '--env ENV'
19
+ opt '--extra_args ARGS'
20
+
21
+ URL = 'https://files.boxfuse.com/com/boxfuse/client/boxfuse-commandline/latest/boxfuse-commandline-latest-linux-x64.tar.gz'
22
+
23
+ cmds install: 'curl -L %{URL} | tar xz',
24
+ deploy: 'boxfuse/boxfuse run %{deploy_opts}'
25
+
26
+ def validate
27
+ # TODO check if the config file exists (it seems `boxfuse` doesn't)
28
+ end
29
+
30
+ def install
31
+ shell :install
32
+ end
33
+
34
+ def deploy
35
+ shell :deploy
36
+ end
37
+
38
+ private
39
+
40
+ def deploy_opts
41
+ opts = [*opts_for(%i(user secret payload app env version), prefix: '-')]
42
+ opts << "-configfile=#{config_file}" if config_file?
43
+ opts << extra_args if extra_args?
44
+ opts.join(' ')
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ module Dpl
2
+ module Providers
3
+ class Cargo < Provider
4
+ status :alpha
5
+
6
+ description sq(<<-str)
7
+ tbd
8
+ str
9
+
10
+ opt '--token TOKEN', 'Cargo registry API token', required: true, secret: true
11
+
12
+ cmds publish: 'cargo publish --token %{token}'
13
+
14
+ def deploy
15
+ shell :publish
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,128 @@
1
+ module Dpl
2
+ module Providers
3
+ class ChefSupermarket < Provider
4
+ register :'chef-supermarket'
5
+ register :chef_supermarket
6
+
7
+ status :alpha
8
+
9
+ full_name 'Chef Supermarket'
10
+
11
+ description sq(<<-str)
12
+ tbd
13
+ str
14
+
15
+ gem 'chef', '~> 12.0', require: %w(
16
+ chef/cookbook/cookbook_version_loader
17
+ chef/cookbook_site_streaming_uploader
18
+ chef/cookbook_uploader
19
+ )
20
+ gem 'json'
21
+ gem 'mime-types', '~> 3.2.2'
22
+ gem 'net-telnet', '~> 0.1.0' if ruby_pre?('2.3')
23
+ gem 'rack'
24
+
25
+ opt '--user_id ID', 'Chef Supermarket user name', required: true
26
+ opt '--client_key KEY', 'Client API key file name', required: true
27
+ opt '--name NAME', 'Cookbook name', note: 'defaults to the name given in metadata.json or metadata.rb', alias: :cookbook_name, deprecated: :cookbook_name
28
+ opt '--category CAT', 'Cookbook category in Supermarket', required: true, see: 'https://docs.getchef.com/knife_cookbook_site.html#id12', alias: :cookbook_category, deprecated: :cookbook_category
29
+ opt '--dir DIR', 'Directory containing the cookbook', default: '.'
30
+
31
+ URL = "https://supermarket.chef.io/api/v1/cookbooks"
32
+
33
+ msgs validate: 'Validating cookbook',
34
+ upload: 'Uploading cookbook %{name} to %{url}',
35
+ missing_file: 'Missing file: %s',
36
+ unknown_error: 'Unknown error while sharing cookbook: %s',
37
+ version_exists: 'The same version of this cookbook already exists on the Opscode Cookbook Site.'
38
+
39
+ def setup
40
+ Chef::Config[:client_key] = client_key
41
+ chdir dir
42
+ end
43
+
44
+ def validate
45
+ info :validate
46
+ validate_file client_key
47
+ uploader.validate_cookbooks
48
+ end
49
+
50
+ def deploy
51
+ info :upload
52
+ upload
53
+ end
54
+
55
+ private
56
+
57
+ def upload
58
+ res = Chef::CookbookSiteStreamingUploader.post(URL, user_id, client_key, params)
59
+ handle_error(res.body) if res.code.to_i != 201
60
+ end
61
+
62
+ def params
63
+ { cookbook: json(category: category), tarball: tarball }
64
+ end
65
+
66
+ def tarball
67
+ shell "tar -czf /tmp/#{name}.tgz -C #{build_dir} ."
68
+ shell "tar -tvf /tmp/#{name}.tgz"
69
+ open "/tmp/#{name}.tgz"
70
+ end
71
+
72
+ def name
73
+ @name ||= name_from_json || name_from_rb || error(:missing_file, 'metadata.json or metadata.rb')
74
+ end
75
+
76
+ def name_from_json
77
+ JSON.load(read('metadata.json'))['name'] if file?('metadata.json')
78
+ end
79
+
80
+ def name_from_rb
81
+ Chef::Cookbook::Metadata.new.from_file('metadata.rb') if file?('metadata.rb')
82
+ end
83
+
84
+ def cookbook
85
+ @cookbook ||= loader.cookbook_version
86
+ end
87
+
88
+ def loader
89
+ Chef::Cookbook::CookbookVersionLoader.new('.').tap(&:load!)
90
+ end
91
+
92
+ def uploader
93
+ Chef::CookbookUploader.new(cookbook)
94
+ end
95
+
96
+ def build_dir
97
+ @build_dir ||= Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
98
+ end
99
+
100
+ def validate_file(path)
101
+ error :missing_file, path unless file?(path)
102
+ end
103
+
104
+ def url
105
+ URL
106
+ end
107
+
108
+ def handle_error(res)
109
+ res = JSON.parse(res)
110
+ unknown_error(res) unless res['error_messages']
111
+ version_exists if res['error_messages'][0].include?('Version already exists')
112
+ error "#{res['error_messages'][0]}"
113
+ end
114
+
115
+ def unknown_error(msg)
116
+ error :unknown_error, msg
117
+ end
118
+
119
+ def version_exists
120
+ error :version_exists
121
+ end
122
+
123
+ def json(obj)
124
+ JSON.dump(obj)
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,40 @@
1
+ module Dpl
2
+ module Providers
3
+ class Cloud66 < Provider
4
+ status :alpha
5
+
6
+ description sq(<<-str)
7
+ tbd
8
+ str
9
+
10
+ opt '--redeployment_hook URL', 'The redeployment hook URL', required: true, secret: true
11
+
12
+ msgs failed: 'Redeployment failed (%s)'
13
+
14
+ def deploy
15
+ response = client.request(request)
16
+ error :failed, response.code if response.code != '200'
17
+ end
18
+
19
+ private
20
+
21
+ def client
22
+ Net::HTTP.new(uri.host, uri.port).tap do |client|
23
+ client.use_ssl = use_ssl?
24
+ end
25
+ end
26
+
27
+ def request
28
+ Net::HTTP::Post.new(uri.path)
29
+ end
30
+
31
+ def uri
32
+ @uri ||= URI.parse(redeployment_hook)
33
+ end
34
+
35
+ def use_ssl?
36
+ uri.scheme.downcase == 'https'
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,56 @@
1
+ module Dpl
2
+ module Providers
3
+ class Cloudfiles < Provider
4
+ status :alpha
5
+
6
+ full_name 'Cloud Files'
7
+
8
+ description sq(<<-str)
9
+ tbd
10
+ str
11
+
12
+ gem 'nokogiri', '< 1.10'
13
+ gem 'fog-core', '= 2.1.0', require: 'fog/core'
14
+ gem 'fog-rackspace', '~> 0.1.6', require: 'fog/rackspace'
15
+
16
+ opt '--username USER', 'Rackspace username', required: true
17
+ opt '--api_key KEY', 'Rackspace API key', required: true, secret: true
18
+ opt '--region REGION', 'Cloudfiles region', required: true, enum: %w(ord dfw syd iad hkg)
19
+ opt '--container NAME', 'Name of the container that files will be uploaded to', required: true
20
+ opt '--glob GLOB', 'Paths to upload', default: '**/*'
21
+ opt '--dot_match', 'Upload hidden files starting a dot'
22
+
23
+ msgs missing_container: 'The specified container does not exist.'
24
+
25
+ def deploy
26
+ paths.each do |path|
27
+ container.files.create(key: path, body: File.open(path))
28
+ end
29
+ end
30
+
31
+ def paths
32
+ paths = Dir.glob(*glob)
33
+ paths.reject { |path| File.directory?(path) }
34
+ end
35
+
36
+ def glob
37
+ glob = [super]
38
+ glob << File::FNM_DOTMATCH if dot_match?
39
+ glob
40
+ end
41
+
42
+ def container
43
+ @container ||= api.directories.get(super) || error(:missing_container)
44
+ end
45
+
46
+ def api
47
+ @api ||= Fog::Storage.new(
48
+ provider: 'Rackspace',
49
+ rackspace_username: username,
50
+ rackspace_api_key: api_key,
51
+ rackspace_region: region
52
+ )
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,81 @@
1
+ module Dpl
2
+ module Providers
3
+ class Cloudfoundry < Provider
4
+ status :alpha
5
+
6
+ full_name 'Cloud Foundry'
7
+
8
+ description sq(<<-str)
9
+ tbd
10
+ str
11
+
12
+ opt '--username USER', 'Cloud Foundry username', required: true
13
+ opt '--password PASS', 'Cloud Foundry password', required: true, secret: true
14
+ opt '--organization ORG', 'Cloud Foundry target organization', required: true
15
+ opt '--space SPACE', 'Cloud Foundry target space', required: true
16
+ opt '--api URL', 'Cloud Foundry api URL', required: true
17
+ opt '--app_name APP', 'Application name'
18
+ opt '--buildpack PACK', 'Custom buildpack name or Git URL'
19
+ opt '--manifest FILE', 'Path to the manifest'
20
+ opt '--skip_ssl_validation', 'Skip SSL validation'
21
+ opt '--v3', 'Use the v3 API version to push the application'
22
+ opt '--logout', default: true, internal: true
23
+
24
+ cmds install: 'test $(uname) = "Linux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz',
25
+ api: './cf api %{api} %{skip_ssl_validation_opt}',
26
+ login: './cf login -u %{username} -p %{password} -o %{organization} -s %{space}',
27
+ push: './cf %{push_cmd} %{push_args}',
28
+ logout: './cf logout'
29
+
30
+ errs install: 'Failed to install CLI tools',
31
+ api: 'Failed to set api %{api}',
32
+ login: 'Failed to login',
33
+ push: 'Failed to push app',
34
+ logout: 'Failed to logout'
35
+
36
+ msgs manifest_missing: 'Application must have a manifest.yml for unattended deployment'
37
+
38
+ def install
39
+ shell :install
40
+ end
41
+
42
+ def validate
43
+ error :manifest_missing if manifest? && manifest_missing?
44
+ end
45
+
46
+ def login
47
+ shell :api
48
+ shell :login
49
+ end
50
+
51
+ def deploy
52
+ shell :push
53
+ end
54
+
55
+ def finish
56
+ shell :logout if logout?
57
+ end
58
+
59
+ private
60
+
61
+ def push_cmd
62
+ v3? ? 'v3-push' : 'push'
63
+ end
64
+
65
+ def push_args
66
+ args = []
67
+ args << quote(app_name) if app_name?
68
+ args << "-f #{manifest}" if manifest?
69
+ args.join(' ')
70
+ end
71
+
72
+ def skip_ssl_validation_opt
73
+ '--skip-ssl-validation' if skip_ssl_validation?
74
+ end
75
+
76
+ def manifest_missing?
77
+ !File.exists?(manifest)
78
+ end
79
+ end
80
+ end
81
+ end