dpl 1.8.48.travis.2486.5 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.travis.yml +42 -21
  4. data/Gemfile +3 -98
  5. data/README.md +5 -16
  6. data/Rakefile +160 -1
  7. data/dpl-anynines.gemspec +3 -0
  8. data/dpl-atlas.gemspec +3 -0
  9. data/dpl-azure_webapps.gemspec +3 -0
  10. data/dpl-bintray.gemspec +3 -0
  11. data/dpl-bitballoon.gemspec +3 -0
  12. data/dpl-bluemix_cloud_foundry.gemspec +3 -0
  13. data/dpl-boxfuse.gemspec +3 -0
  14. data/dpl-catalyze.gemspec +3 -0
  15. data/dpl-chef_supermarket.gemspec +8 -0
  16. data/dpl-cloud66.gemspec +3 -0
  17. data/dpl-cloud_files.gemspec +3 -0
  18. data/dpl-cloud_foundry.gemspec +3 -0
  19. data/dpl-code_deploy.gemspec +3 -0
  20. data/dpl-deis.gemspec +3 -0
  21. data/dpl-divshot.gemspec +3 -0
  22. data/dpl-elastic_beanstalk.gemspec +3 -0
  23. data/dpl-engine_yard.gemspec +3 -0
  24. data/dpl-firebase.gemspec +3 -0
  25. data/dpl-gae.gemspec +3 -0
  26. data/dpl-gcs.gemspec +3 -0
  27. data/dpl-hackage.gemspec +3 -0
  28. data/dpl-heroku.gemspec +3 -0
  29. data/dpl-lambda.gemspec +3 -0
  30. data/dpl-launchpad.gemspec +3 -0
  31. data/dpl-modulus.gemspec +3 -0
  32. data/dpl-npm.gemspec +3 -0
  33. data/dpl-openshift.gemspec +3 -0
  34. data/dpl-ops_works.gemspec +3 -0
  35. data/dpl-packagecloud.gemspec +3 -0
  36. data/dpl-pages.gemspec +3 -0
  37. data/dpl-puppet_forge.gemspec +3 -0
  38. data/dpl-pypi.gemspec +3 -0
  39. data/dpl-releases.gemspec +3 -0
  40. data/dpl-rubygems.gemspec +3 -0
  41. data/dpl-s3.gemspec +3 -0
  42. data/dpl-scalingo.gemspec +3 -0
  43. data/dpl-script.gemspec +3 -0
  44. data/dpl-surge.gemspec +3 -0
  45. data/dpl-testfairy.gemspec +3 -0
  46. data/dpl-transifex.gemspec +3 -0
  47. data/dpl.gemspec +2 -31
  48. data/gemspec_helper.rb +49 -0
  49. data/lib/dpl/provider.rb +101 -58
  50. data/lib/dpl/version.rb +1 -1
  51. data/spec/provider_spec.rb +15 -34
  52. metadata +76 -107
  53. data/lib/dpl/provider/anynines.rb +0 -13
  54. data/lib/dpl/provider/appfog.rb +0 -21
  55. data/lib/dpl/provider/atlas.rb +0 -108
  56. data/lib/dpl/provider/azure_webapps.rb +0 -48
  57. data/lib/dpl/provider/bintray.rb +0 -509
  58. data/lib/dpl/provider/bitballoon.rb +0 -22
  59. data/lib/dpl/provider/bluemix_cloud_foundry.rb +0 -23
  60. data/lib/dpl/provider/boxfuse.rb +0 -57
  61. data/lib/dpl/provider/catalyze.rb +0 -49
  62. data/lib/dpl/provider/chef_supermarket.rb +0 -85
  63. data/lib/dpl/provider/cloud66.rb +0 -38
  64. data/lib/dpl/provider/cloud_files.rb +0 -38
  65. data/lib/dpl/provider/cloud_foundry.rb +0 -43
  66. data/lib/dpl/provider/code_deploy.rb +0 -154
  67. data/lib/dpl/provider/deis.rb +0 -128
  68. data/lib/dpl/provider/divshot.rb +0 -23
  69. data/lib/dpl/provider/elastic_beanstalk.rb +0 -195
  70. data/lib/dpl/provider/engine_yard.rb +0 -90
  71. data/lib/dpl/provider/firebase.rb +0 -27
  72. data/lib/dpl/provider/gae.rb +0 -97
  73. data/lib/dpl/provider/gcs.rb +0 -59
  74. data/lib/dpl/provider/hackage.rb +0 -29
  75. data/lib/dpl/provider/heroku.rb +0 -18
  76. data/lib/dpl/provider/heroku/api.rb +0 -98
  77. data/lib/dpl/provider/heroku/generic.rb +0 -94
  78. data/lib/dpl/provider/heroku/git.rb +0 -28
  79. data/lib/dpl/provider/lambda.rb +0 -236
  80. data/lib/dpl/provider/launchpad.rb +0 -48
  81. data/lib/dpl/provider/modulus.rb +0 -23
  82. data/lib/dpl/provider/npm.rb +0 -64
  83. data/lib/dpl/provider/openshift.rb +0 -59
  84. data/lib/dpl/provider/ops_works.rb +0 -132
  85. data/lib/dpl/provider/packagecloud.rb +0 -144
  86. data/lib/dpl/provider/pages.rb +0 -212
  87. data/lib/dpl/provider/puppet_forge.rb +0 -43
  88. data/lib/dpl/provider/pypi.rb +0 -103
  89. data/lib/dpl/provider/releases.rb +0 -139
  90. data/lib/dpl/provider/rubygems.rb +0 -51
  91. data/lib/dpl/provider/s3.rb +0 -123
  92. data/lib/dpl/provider/scalingo.rb +0 -97
  93. data/lib/dpl/provider/script.rb +0 -29
  94. data/lib/dpl/provider/surge.rb +0 -33
  95. data/lib/dpl/provider/testfairy.rb +0 -111
  96. data/lib/dpl/provider/transifex.rb +0 -45
  97. data/spec/provider/anynines_spec.rb +0 -20
  98. data/spec/provider/appfog_spec.rb +0 -35
  99. data/spec/provider/atlas_spec.rb +0 -99
  100. data/spec/provider/azure_webapps_spec.rb +0 -95
  101. data/spec/provider/bintray_spec.rb +0 -259
  102. data/spec/provider/bitballoon_spec.rb +0 -32
  103. data/spec/provider/bluemixcloudfoundry_spec.rb +0 -23
  104. data/spec/provider/boxfuse_spec.rb +0 -16
  105. data/spec/provider/catalyze_spec.rb +0 -39
  106. data/spec/provider/chef_supermarket_spec.rb +0 -51
  107. data/spec/provider/cloud66_spec.rb +0 -44
  108. data/spec/provider/cloud_files_spec.rb +0 -88
  109. data/spec/provider/cloudfoundry_spec.rb +0 -71
  110. data/spec/provider/code_deploy_spec.rb +0 -366
  111. data/spec/provider/deis_spec.rb +0 -116
  112. data/spec/provider/divshot_spec.rb +0 -28
  113. data/spec/provider/elastic_beanstalk_spec.rb +0 -209
  114. data/spec/provider/firebase_spec.rb +0 -40
  115. data/spec/provider/gae_spec.rb +0 -26
  116. data/spec/provider/gcs_spec.rb +0 -115
  117. data/spec/provider/hackage_spec.rb +0 -47
  118. data/spec/provider/heroku_spec.rb +0 -357
  119. data/spec/provider/lambda_spec.rb +0 -432
  120. data/spec/provider/launchpad_spec.rb +0 -33
  121. data/spec/provider/modulus_spec.rb +0 -29
  122. data/spec/provider/npm_spec.rb +0 -95
  123. data/spec/provider/openshift_spec.rb +0 -91
  124. data/spec/provider/ops_works_spec.rb +0 -127
  125. data/spec/provider/packagecloud_spec.rb +0 -56
  126. data/spec/provider/puppet_forge_spec.rb +0 -60
  127. data/spec/provider/pypi_spec.rb +0 -105
  128. data/spec/provider/releases_spec.rb +0 -303
  129. data/spec/provider/rubygems_spec.rb +0 -106
  130. data/spec/provider/s3_spec.rb +0 -174
  131. data/spec/provider/scalingo_spec.rb +0 -64
  132. data/spec/provider/script_spec.rb +0 -26
  133. data/spec/provider/surge_spec.rb +0 -15
  134. data/spec/provider/testfairy_spec.rb +0 -65
  135. data/spec/provider/transifex_spec.rb +0 -110
@@ -1,128 +0,0 @@
1
- module DPL
2
- class Provider
3
- class Deis < Provider
4
-
5
- def install_deploy_dependencies
6
- install_url = determine_install_url
7
- context.shell "curl -sSL #{install_url} | bash -x -s #{option(:cli_version)}"
8
- end
9
-
10
- #Default to installing the default v1 client. Otherwise determine if this is a v2 client
11
- def determine_install_url
12
- if option(:cli_version).nil?
13
- return "http://deis.io/deis-cli/install.sh"
14
- else
15
- version_arg = Gem::Version.new(option(:cli_version).gsub(/^v?V?/,''))
16
- if version_arg >= Gem::Version.new('2.0.0')
17
- return "http://deis.io/deis-cli/install-v2.sh"
18
- else
19
- return "http://deis.io/deis-cli/install.sh"
20
- end
21
- end
22
- end
23
-
24
- def needs_key?
25
- true
26
- end
27
-
28
- def check_auth
29
- unless context.shell "./deis login #{option(:controller)}" \
30
- " --username=#{option(:username)}" \
31
- " --password=#{option(:password)}"
32
- error 'Login failed.'
33
- end
34
- end
35
-
36
- def check_app
37
- unless context.shell "./deis apps:info --app=#{option(:app)}"
38
- error 'Application could not be verified.'
39
- end
40
- end
41
-
42
- def setup_key(file)
43
- unless context.shell "./deis keys:add #{file}"
44
- error 'Adding keys failed.'
45
- end
46
- end
47
-
48
- def setup_git_ssh(path, key_path)
49
- key_path = File.expand_path(key_path)
50
- path = File.expand_path(path)
51
-
52
- File.open(path, 'w') do |file|
53
- file.write "#!/bin/sh\n"
54
- file.write "exec ssh #{verbose_flag} -o StrictHostKeychecking=no -o CheckHostIP=no -o UserKnownHostsFile=/dev/null -i #{key_path} \"$@\"\n"
55
- end
56
-
57
- chmod(0740, path)
58
- context.env['GIT_SSH'] = path
59
-
60
- wait_for_git_access
61
- end
62
-
63
- def wait_for_git_access()
64
- retry_count=0
65
- max_retries=30
66
-
67
- #Get the deis git remote host and port
68
- remote_uri=repository_url.split("ssh://")[1].split("/")[0]
69
- remote_host, remote_port = remote_uri.split(":")
70
- puts "Git remote is #{remote_host} at port #{remote_port}"
71
-
72
- #Try and connect to the github remote via ssh.
73
- while retry_count < max_retries
74
- puts "Waiting for ssh key to propagate..."
75
- if context.shell "#{context.env['GIT_SSH']} #{remote_host} -p #{remote_port} 2>&1 | grep -c 'PTY allocation request failed' > /dev/null"
76
- puts "SSH connection established."
77
- break
78
- end
79
- retry_count += 1
80
- sleep(1)
81
- end
82
- end
83
-
84
- def remove_key
85
- unless context.shell "./deis keys:remove #{option(:key_name)}"
86
- error 'Removing keys failed.'
87
- end
88
- end
89
-
90
- def repository_url
91
- "ssh://git@#{builder_hostname}:2222/#{option(:app)}.git"
92
- end
93
-
94
- def builder_hostname
95
- host_tokens = controller_host.split(".")
96
- host_tokens[0] = [host_tokens[0], "builder"].join("-")
97
- host_tokens.join(".")
98
- end
99
-
100
- def controller_host
101
- option(:controller).gsub(/https?:\/\//, "").split(":")[0]
102
- end
103
-
104
- def push_app
105
- unless context.shell "bash -c 'git push #{verbose_flag} #{repository_url} HEAD:refs/heads/master -f 2>&1 | tr -dc \"[:alnum:][:space:][:punct:]\" | sed -E \"s/remote: (\\[1G)+//\" | sed \"s/\\[K$//\"; exit ${PIPESTATUS[0]}'"
106
- error 'Deploying application failed.'
107
- end
108
- end
109
-
110
- def run(command)
111
- unless context.shell "./deis run -a #{option(:app)} -- #{command}"
112
- error 'Running command failed.'
113
- end
114
- end
115
-
116
- def cleanup
117
- return if options[:skip_cleanup]
118
- context.shell "mv deis ~/deis"
119
- super
120
- context.shell "mv ~/deis deis"
121
- end
122
-
123
- def verbose_flag
124
- '-v' if options[:verbose]
125
- end
126
- end
127
- end
128
- end
@@ -1,23 +0,0 @@
1
- module DPL
2
- class Provider
3
- class Divshot < Provider
4
- npm_g 'divshot-cli', 'divshot'
5
-
6
- def check_auth
7
- raise Error, "must supply an api key" unless option(:api_key)
8
- end
9
-
10
- def check_app
11
- error "missing divshot.json" unless File.exist? "divshot.json"
12
- end
13
-
14
- def needs_key?
15
- false
16
- end
17
-
18
- def push_app
19
- context.shell "divshot push #{options[:environment] || "production"} --token=#{option(:api_key)}"
20
- end
21
- end
22
- end
23
- end
@@ -1,195 +0,0 @@
1
- require 'time'
2
-
3
- module DPL
4
- class Provider
5
- class ElasticBeanstalk < Provider
6
- experimental 'AWS Elastic Beanstalk'
7
-
8
- requires 'aws-sdk', version: '~> 2.0'
9
- requires 'rubyzip', :load => 'zip'
10
-
11
- DEFAULT_REGION = 'us-east-1'
12
-
13
- def needs_key?
14
- false
15
- end
16
-
17
- def access_key_id
18
- options[:access_key_id] || context.env['AWS_ACCESS_KEY_ID'] || raise(Error, "missing access_key_id")
19
- end
20
-
21
- def secret_access_key
22
- options[:secret_access_key] || context.env['AWS_SECRET_ACCESS_KEY'] || raise(Error, "missing secret_access_key")
23
- end
24
-
25
- def check_auth
26
- options = {
27
- :region => region,
28
- :credentials => Aws::Credentials.new(access_key_id, secret_access_key)
29
- }
30
- Aws.config.update(options)
31
- end
32
-
33
- def check_app
34
- end
35
-
36
- def only_create_app_version
37
- options[:only_create_app_version]
38
- end
39
-
40
- def push_app
41
- @start_time = Time.now
42
- create_bucket unless bucket_exists?
43
-
44
- if options[:zip_file]
45
- zip_file = File.expand_path(options[:zip_file])
46
- else
47
- zip_file = create_zip
48
- end
49
-
50
- s3_object = upload(archive_name, zip_file)
51
- sleep 5 #s3 eventual consistency
52
- version = create_app_version(s3_object)
53
- if !only_create_app_version
54
- update_app(version)
55
- wait_until_deployed if options[:wait_until_deployed]
56
- end
57
- end
58
-
59
- private
60
-
61
- def app_name
62
- option(:app)
63
- end
64
-
65
- def env_name
66
- options[:env] || context.env['ELASTIC_BEANSTALK_ENV'] || raise(Error, "missing env")
67
- end
68
-
69
- def version_label
70
- context.env['ELASTIC_BEANSTALK_LABEL'] || "travis-#{sha}-#{Time.now.to_i}"
71
- end
72
-
73
- def version_description
74
- context.env['ELASTIC_BEANSTALK_DESCRIPTION'] || commit_msg
75
- end
76
-
77
- def archive_name
78
- "#{version_label}.zip"
79
- end
80
-
81
- def region
82
- options[:region] || DEFAULT_REGION
83
- end
84
-
85
- def bucket_name
86
- option(:bucket_name)
87
- end
88
-
89
- def bucket_path
90
- @bucket_path ||= options[:bucket_path] ? option(:bucket_path).gsub(/\/*$/,'/') : nil
91
- end
92
-
93
- def s3
94
- @s3 ||= Aws::S3::Resource.new
95
- end
96
-
97
- def eb
98
- @eb ||= Aws::ElasticBeanstalk::Client.new
99
- end
100
-
101
- def bucket_exists?
102
- s3.bucket(bucket_name).exists?
103
- end
104
-
105
- def create_bucket
106
- s3.bucket(bucket_name).create
107
- end
108
-
109
- def files_to_pack
110
- `git ls-files -z`.split("\x0")
111
- end
112
-
113
- def create_zip
114
- directory = Dir.pwd
115
- zipfile_name = File.join(directory, archive_name)
116
-
117
- Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
118
- files_to_pack.each do |file|
119
- relative_archive_path = File.join(directory, '/')
120
- zipfile.add(file.sub(relative_archive_path, ''), file)
121
- end
122
- end
123
- zipfile_name
124
- end
125
-
126
- def upload(key, file)
127
- options = {
128
- :body => Pathname.new(file).open
129
- }
130
- bucket = s3.bucket(bucket_name)
131
- obj = bucket_path ? bucket.object("#{bucket_path}#{key}") : bucket.object(key)
132
- obj.put(options)
133
- obj
134
- end
135
-
136
- def create_app_version(s3_object)
137
- # Elastic Beanstalk doesn't support descriptions longer than 200 characters
138
- description = version_description[0, 200]
139
- options = {
140
- :application_name => app_name,
141
- :version_label => version_label,
142
- :description => description,
143
- :source_bundle => {
144
- :s3_bucket => bucket_name,
145
- :s3_key => s3_object.key
146
- },
147
- :auto_create_application => false
148
- }
149
- eb.create_application_version(options)
150
- end
151
-
152
- # Wait until EB environment update finishes
153
- def wait_until_deployed
154
- errorEvents = 0 # errors counter, should remain 0 for successful deployment
155
- events = []
156
-
157
- loop do
158
- environment = eb.describe_environments({
159
- :application_name => app_name,
160
- :environment_names => [env_name]
161
- })[:environments].first
162
-
163
- eb.describe_events({
164
- :environment_name => env_name,
165
- :start_time => @start_time.utc.iso8601,
166
- })[:events].reverse.each do |event|
167
- message = "#{event[:event_date]} [#{event[:severity]}] #{event[:message]}"
168
- unless events.include?(message)
169
- events.push(message)
170
- if event[:severity] == "ERROR"
171
- errorEvents += 1
172
- warn(message)
173
- else
174
- log(message)
175
- end
176
- end
177
- end
178
-
179
- break if environment[:status] == "Ready"
180
- sleep 5
181
- end
182
-
183
- if errorEvents > 0 then error("Deployment failed.") end
184
- end
185
-
186
- def update_app(version)
187
- options = {
188
- :environment_name => env_name,
189
- :version_label => version[:application_version][:version_label]
190
- }
191
- eb.update_environment(options)
192
- end
193
- end
194
- end
195
- end
@@ -1,90 +0,0 @@
1
- require 'time'
2
-
3
- module DPL
4
- class Provider
5
- class EngineYard < Provider
6
- requires 'engineyard-cloud-client'
7
-
8
- def token
9
- options[:api_key] ||= if options[:email] and options[:password]
10
- EY::CloudClient.authenticate(options[:email], options[:password])
11
- else
12
- option(:api_key) # will raise
13
- end
14
- end
15
-
16
- def api
17
- @api ||= EY::CloudClient.new(:token => token)
18
- end
19
-
20
- def check_auth
21
- log "authenticated as %s" % api.current_user.email
22
- end
23
-
24
- def check_app
25
- remotes = `git remote -v`.scan(/\t[^\s]+\s/).map { |c| c.strip }.uniq
26
- @current_sha = `git rev-parse HEAD`.chomp
27
- resolver = api.resolve_app_environments(
28
- :app_name => options[:app],
29
- :account_name => options[:account],
30
- :environment_name => options[:environment],
31
- :remotes => remotes)
32
- resolver.one_match { @app_env = resolver.matches.first }
33
- resolver.no_matches { error resolver.errors.join("\n").inspect }
34
- resolver.many_matches do |matches|
35
- message = "Multiple matches possible, please be more specific:\n\n"
36
- matches.each do |appenv|
37
- message << "environment: '#{appenv.environment.name}' account: '#{appenv.environment.account.name}'\n"
38
- end
39
- error message
40
- end
41
- @app_env
42
- end
43
-
44
- def needs_key?
45
- false
46
- end
47
-
48
- def cleanup
49
- end
50
-
51
- def uncleanup
52
- end
53
-
54
- def push_app
55
- deploy_opts = {:ref => @current_sha}
56
- if command = options[:migrate]
57
- if command === true || command === "true"
58
- error("\"true\" doesn't look like a migration command, try --migrate=\"rake db:migrate\"")
59
- end
60
- deploy_opts[:migrate] = true
61
- deploy_opts[:migration_command] = command
62
- end
63
- print "deploying "
64
- deployment = EY::CloudClient::Deployment.deploy(api, @app_env, deploy_opts)
65
- result = poll_for_result(deployment)
66
- unless result.successful
67
- error "Deployment failed (see logs on Engine Yard)"
68
- end
69
- end
70
-
71
- def poll_for_result(deployment)
72
- until deployment.finished?
73
- sleep 5
74
- #TODO: configurable timeout?
75
- print "."
76
- deployment = EY::CloudClient::Deployment.get(api, deployment.app_environment, deployment.id)
77
- end
78
- puts "DONE: https://cloud.engineyard.com/apps/#{deployment.app.id}/environments/#{deployment.environment.id}/deployments/#{deployment.id}/pretty"
79
- deployment
80
- end
81
-
82
- def deploy
83
- super
84
- rescue EY::CloudClient::Error => e
85
- error(e.message)
86
- end
87
-
88
- end
89
- end
90
- end
@@ -1,27 +0,0 @@
1
- module DPL
2
- class Provider
3
- class Firebase < Provider
4
- npm_g 'firebase-tools@^3.0', 'firebase'
5
-
6
- def check_auth
7
- raise Error, "must supply token option or FIREBASE_TOKEN environment variable" if !options[:token] && !context.env['FIREBASE_TOKEN']
8
- end
9
-
10
- def check_app
11
- error "missing firebase.json" unless File.exist? "firebase.json"
12
- end
13
-
14
- def needs_key?
15
- false
16
- end
17
-
18
- def push_app
19
- command = "firebase deploy --non-interactive"
20
- command << " --project #{options[:project]}" if options[:project]
21
- command << " --message '#{options[:message]}'" if options[:message]
22
- command << " --token '#{options[:token]}'" if options[:token]
23
- context.shell command
24
- end
25
- end
26
- end
27
- end