dpl-connect 1.8.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +8 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +36 -0
  6. data/Gemfile +100 -0
  7. data/LICENSE +22 -0
  8. data/README.md +934 -0
  9. data/Rakefile +1 -0
  10. data/TESTING.md +29 -0
  11. data/bin/dpl +5 -0
  12. data/dpl.gemspec +32 -0
  13. data/lib/dpl/cli.rb +66 -0
  14. data/lib/dpl/error.rb +3 -0
  15. data/lib/dpl/provider.rb +264 -0
  16. data/lib/dpl/provider/anynines.rb +13 -0
  17. data/lib/dpl/provider/appfog.rb +21 -0
  18. data/lib/dpl/provider/atlas.rb +108 -0
  19. data/lib/dpl/provider/azure_webapps.rb +48 -0
  20. data/lib/dpl/provider/bintray.rb +509 -0
  21. data/lib/dpl/provider/bitballoon.rb +22 -0
  22. data/lib/dpl/provider/bluemix_cloud_foundry.rb +23 -0
  23. data/lib/dpl/provider/boxfuse.rb +57 -0
  24. data/lib/dpl/provider/catalyze.rb +49 -0
  25. data/lib/dpl/provider/chef_supermarket.rb +85 -0
  26. data/lib/dpl/provider/cloud66.rb +38 -0
  27. data/lib/dpl/provider/cloud_files.rb +38 -0
  28. data/lib/dpl/provider/cloud_foundry.rb +43 -0
  29. data/lib/dpl/provider/code_deploy.rb +123 -0
  30. data/lib/dpl/provider/deis.rb +119 -0
  31. data/lib/dpl/provider/divshot.rb +23 -0
  32. data/lib/dpl/provider/elastic_beanstalk.rb +195 -0
  33. data/lib/dpl/provider/engine_yard.rb +90 -0
  34. data/lib/dpl/provider/firebase.rb +27 -0
  35. data/lib/dpl/provider/gae.rb +97 -0
  36. data/lib/dpl/provider/gcs.rb +59 -0
  37. data/lib/dpl/provider/hackage.rb +29 -0
  38. data/lib/dpl/provider/heroku.rb +18 -0
  39. data/lib/dpl/provider/heroku/api.rb +98 -0
  40. data/lib/dpl/provider/heroku/generic.rb +94 -0
  41. data/lib/dpl/provider/heroku/git.rb +28 -0
  42. data/lib/dpl/provider/lambda.rb +236 -0
  43. data/lib/dpl/provider/launchpad.rb +48 -0
  44. data/lib/dpl/provider/modulus.rb +23 -0
  45. data/lib/dpl/provider/npm.rb +64 -0
  46. data/lib/dpl/provider/openshift.rb +59 -0
  47. data/lib/dpl/provider/ops_works.rb +132 -0
  48. data/lib/dpl/provider/packagecloud.rb +144 -0
  49. data/lib/dpl/provider/pages.rb +79 -0
  50. data/lib/dpl/provider/puppet_forge.rb +43 -0
  51. data/lib/dpl/provider/pypi.rb +111 -0
  52. data/lib/dpl/provider/releases.rb +139 -0
  53. data/lib/dpl/provider/rubygems.rb +51 -0
  54. data/lib/dpl/provider/s3.rb +123 -0
  55. data/lib/dpl/provider/scalingo.rb +97 -0
  56. data/lib/dpl/provider/script.rb +29 -0
  57. data/lib/dpl/provider/surge.rb +33 -0
  58. data/lib/dpl/provider/testfairy.rb +190 -0
  59. data/lib/dpl/provider/transifex.rb +45 -0
  60. data/lib/dpl/version.rb +3 -0
  61. data/notes/engine_yard.md +1 -0
  62. data/notes/heroku.md +3 -0
  63. data/spec/cli_spec.rb +36 -0
  64. data/spec/provider/anynines_spec.rb +20 -0
  65. data/spec/provider/appfog_spec.rb +35 -0
  66. data/spec/provider/atlas_spec.rb +99 -0
  67. data/spec/provider/azure_webapps_spec.rb +95 -0
  68. data/spec/provider/bintray_spec.rb +259 -0
  69. data/spec/provider/bitballoon_spec.rb +32 -0
  70. data/spec/provider/bluemixcloudfoundry_spec.rb +23 -0
  71. data/spec/provider/boxfuse_spec.rb +16 -0
  72. data/spec/provider/catalyze_spec.rb +39 -0
  73. data/spec/provider/chef_supermarket_spec.rb +51 -0
  74. data/spec/provider/cloud66_spec.rb +44 -0
  75. data/spec/provider/cloud_files_spec.rb +88 -0
  76. data/spec/provider/cloudfoundry_spec.rb +71 -0
  77. data/spec/provider/code_deploy_spec.rb +360 -0
  78. data/spec/provider/deis_spec.rb +116 -0
  79. data/spec/provider/divshot_spec.rb +28 -0
  80. data/spec/provider/elastic_beanstalk_spec.rb +209 -0
  81. data/spec/provider/firebase_spec.rb +40 -0
  82. data/spec/provider/gae_spec.rb +26 -0
  83. data/spec/provider/gcs_spec.rb +115 -0
  84. data/spec/provider/hackage_spec.rb +47 -0
  85. data/spec/provider/heroku_spec.rb +357 -0
  86. data/spec/provider/lambda_spec.rb +432 -0
  87. data/spec/provider/launchpad_spec.rb +33 -0
  88. data/spec/provider/modulus_spec.rb +29 -0
  89. data/spec/provider/npm_spec.rb +95 -0
  90. data/spec/provider/openshift_spec.rb +91 -0
  91. data/spec/provider/ops_works_spec.rb +127 -0
  92. data/spec/provider/packagecloud_spec.rb +56 -0
  93. data/spec/provider/puppet_forge_spec.rb +60 -0
  94. data/spec/provider/pypi_spec.rb +103 -0
  95. data/spec/provider/releases_spec.rb +303 -0
  96. data/spec/provider/rubygems_spec.rb +106 -0
  97. data/spec/provider/s3_spec.rb +174 -0
  98. data/spec/provider/scalingo_spec.rb +64 -0
  99. data/spec/provider/script_spec.rb +26 -0
  100. data/spec/provider/surge_spec.rb +15 -0
  101. data/spec/provider/testfairy_spec.rb +86 -0
  102. data/spec/provider/transifex_spec.rb +110 -0
  103. data/spec/provider_spec.rb +210 -0
  104. data/spec/spec_helper.rb +20 -0
  105. metadata +279 -0
@@ -0,0 +1,22 @@
1
+ module DPL
2
+ class Provider
3
+ class BitBalloon < Provider
4
+ requires 'bitballoon'
5
+
6
+ def check_auth
7
+ end
8
+
9
+ def needs_key?
10
+ false
11
+ end
12
+
13
+ def push_app
14
+ command = 'bitballoon deploy'
15
+ command << " ./#{option(:local_dir)}" if options.fetch(:local_dir,false)
16
+ command << " --site-id=#{option(:site_id)}" if options[:site_id]
17
+ command << " --access-token=#{option(:access_token)}" if options[:access_token]
18
+ context.shell command
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ module DPL
2
+ class Provider
3
+ class BluemixCloudFoundry < CloudFoundry
4
+
5
+ REGIONS = Hash.new {"api.ng.bluemix.net"}.update(
6
+ "eu-gb" => "api.eu-gb.bluemix.net",
7
+ "eu-de" => "api.eu-de.bluemix.net",
8
+ "au-syd" => "api.au-syd.bluemix.net"
9
+ )
10
+
11
+ def set_api
12
+ region = options[:region] || "ng"
13
+ options[:api] = options[:api] || REGIONS[region]
14
+ end
15
+
16
+ def check_auth
17
+ set_api
18
+ super
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,57 @@
1
+ module DPL
2
+ class Provider
3
+ class Boxfuse < Provider
4
+
5
+ def deploy
6
+ @user = options[:user]
7
+ @secret = options[:secret]
8
+ @configfile = options[:configfile]
9
+ @payload = options[:payload]
10
+ @image = options[:image]
11
+ @env = options[:env]
12
+ @extra_args = options[:extra_args]
13
+
14
+ @param_user = ''
15
+ if @user.to_s != ''
16
+ @param_user = " -user=" + @user
17
+ end
18
+
19
+ @param_secret = ''
20
+ if @secret.to_s != ''
21
+ @param_secret = " -secret=" + @secret
22
+ end
23
+
24
+ @param_configfile = ''
25
+ if @configfile.to_s != ''
26
+ @param_configfile = ' "-configfile=' + @configfile + '"'
27
+ end
28
+
29
+ @param_payload = ''
30
+ if @payload.to_s != ''
31
+ @param_payload = ' "' + @payload + '"'
32
+ end
33
+
34
+ @param_image = ''
35
+ if @image.to_s != ''
36
+ @param_image = " -image=" + @image
37
+ end
38
+
39
+ @param_env = ' -env=test'
40
+ if @env.to_s != ''
41
+ @param_env = " -env=" + @env
42
+ end
43
+
44
+ @param_extra_args = ''
45
+ if @extra_args.to_s != ''
46
+ @param_extra_args = " " + @extra_args
47
+ end
48
+
49
+ context.shell "curl -L https://files.boxfuse.com/com/boxfuse/client/boxfuse-commandline/latest/boxfuse-commandline-latest-linux-x64.tar.gz | tar xz"
50
+
51
+ @command = "boxfuse/boxfuse run" + @param_user + @param_secret + @param_configfile + @param_payload + @param_image + @param_env + @param_extra_args
52
+ context.fold("Deploying application") { context.shell @command }
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,49 @@
1
+ module DPL
2
+ class Provider
3
+ class Catalyze < Provider
4
+ def config
5
+ {
6
+ # the git repository to deploy to
7
+ "target" => options[:target] || context.env['CATALYZE_TARGET'],
8
+ # the pathspec for files to add to git for deployment e.g. your build directory. defaults to all files.
9
+ "path" => options[:path] || context.env['CATALYZE_PATH'] || '.'
10
+ }
11
+ end
12
+
13
+ def needs_key?
14
+ false
15
+ end
16
+
17
+ def check_app
18
+ end
19
+
20
+ def check_auth
21
+ error "Missing Catalyze target" unless config['target']
22
+ end
23
+
24
+ def push_app
25
+ log "Deploying to Catalyze '#{config['target']}'"
26
+
27
+ if options[:skip_cleanup]
28
+ # create commit message
29
+ build_num = context.env["TRAVIS_BUILD_NUMBER"]
30
+ commit = context.env["TRAVIS_COMMIT"]
31
+ repo_slug = context.env["TRAVIS_REPO_SLUG"]
32
+ branch = context.env["TRAVIS_BRANCH"]
33
+ if build_num && commit && repo_slug && branch
34
+ commit_message = "Build ##{build_num} (#{commit}) of #{repo_slug}@#{branch}"
35
+ else
36
+ commit_message = "Local build"
37
+ end
38
+
39
+ log "Using build files for deployment"
40
+ context.shell "git checkout HEAD"
41
+ context.shell "git add #{config["path"]} --all --force"
42
+ context.shell "git commit -m \"#{commit_message}\" --quiet"
43
+ end
44
+
45
+ context.shell "git push --force #{config['target']} HEAD:master"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,85 @@
1
+ module DPL
2
+ class Provider
3
+ class ChefSupermarket < Provider
4
+
5
+ # Most of the code is inspired by:
6
+ # https://github.com/opscode/chef/blob/11.16.4/lib/chef/knife/cookbook_site_share.rb
7
+
8
+ # Compatibility with ruby 1.9
9
+ requires 'rack', version: '< 2.0'
10
+ requires 'mime-types', version: '~> 1.16'
11
+ requires 'chef', version: '< 12.0'
12
+ requires 'chef', load: 'chef/config'
13
+ requires 'chef', load: 'chef/cookbook_loader'
14
+ requires 'chef', load: 'chef/cookbook_uploader'
15
+ requires 'chef', load: 'chef/cookbook_site_streaming_uploader'
16
+
17
+ attr_reader :cookbook_name, :cookbook_category
18
+ attr_reader :cookbook
19
+
20
+ def needs_key?
21
+ false
22
+ end
23
+
24
+ def check_auth
25
+ error "Missing user_id option" unless options[:user_id]
26
+ error "Missing client_key option" unless options[:client_key]
27
+ ::Chef::Config[:client_key] = options[:client_key]
28
+ error "#{options[:client_key]} does not exist" unless ::File.exist?(options[:client_key])
29
+ end
30
+
31
+ def check_app
32
+ @cookbook_name = options[:cookbook_name] || options[:app]
33
+ @cookbook_category = options[:cookbook_category]
34
+ unless cookbook_category
35
+ error "Missing cookbook_category option\n" +
36
+ "see https://docs.getchef.com/knife_cookbook_site.html#id12"
37
+ end
38
+
39
+ log "Validating cookbook #{cookbook_name}"
40
+ # Check that cookbook exist and is valid
41
+ # So we assume cookbook path is '..'
42
+ cl = ::Chef::CookbookLoader.new '..'
43
+ @cookbook = cl[cookbook_name]
44
+ ::Chef::CookbookUploader.new(cookbook, '..').validate_cookbooks
45
+ end
46
+
47
+ def push_app
48
+ log "Creating cookbook build directory"
49
+ tmp_cookbook_dir = Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
50
+ log "Making tarball in #{tmp_cookbook_dir}"
51
+ system("tar -czf #{cookbook_name}.tgz #{cookbook_name}", :chdir => tmp_cookbook_dir)
52
+
53
+ uri = "https://supermarket.chef.io/api/v1/cookbooks"
54
+
55
+ log "Uploading to #{uri}"
56
+ category_string = { 'category'=>cookbook_category }.to_json
57
+ http_resp = ::Chef::CookbookSiteStreamingUploader.post(
58
+ uri,
59
+ options[:user_id],
60
+ options[:client_key],
61
+ {
62
+ :tarball => File.open("#{tmp_cookbook_dir}/#{cookbook_name}.tgz"),
63
+ :cookbook => category_string
64
+ }
65
+ )
66
+ res = ::Chef::JSONCompat.from_json(http_resp.body)
67
+ if http_resp.code.to_i != 201
68
+ if res['error_messages']
69
+ if res['error_messages'][0] =~ /Version already exists/
70
+ error "The same version of this cookbook already exists on the Opscode Cookbook Site."
71
+ else
72
+ error "#{res['error_messages'][0]}"
73
+ end
74
+ else
75
+ error "Unknown error while sharing cookbook\n" +
76
+ "Server response: #{http_resp.body}"
77
+ end
78
+ end
79
+
80
+ log "Upload complete."
81
+ ::FileUtils.rm_rf tmp_cookbook_dir
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,38 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+
4
+ module DPL
5
+ class Provider
6
+ class Cloud66 < Provider
7
+ def needs_key?
8
+ false
9
+ end
10
+
11
+ def push_app
12
+ uri = URI.parse(redeployment_hook)
13
+
14
+ response = webhook_call(uri.scheme, uri.host, uri.port, uri.path)
15
+
16
+ error("Redeployment failed [#{response.code}]") if response.code != '200'
17
+ end
18
+
19
+ def check_auth
20
+ end
21
+
22
+ private
23
+
24
+ def webhook_call(scheme, host, port, path)
25
+ http = Net::HTTP.new(host, port)
26
+ http.use_ssl = (scheme.downcase == 'https')
27
+
28
+ request = Net::HTTP::Post.new(path)
29
+
30
+ return http.request(request)
31
+ end
32
+
33
+ def redeployment_hook
34
+ option(:redeployment_hook)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require 'dpl/provider'
2
+
3
+ module DPL
4
+ class Provider
5
+ class CloudFiles < Provider
6
+ requires 'net-ssh', load: 'net/ssh', version: '~> 2.9.2' # Anything higher requires Ruby 2.x
7
+ requires 'mime-types', load: 'mime/types', version: '~> 2.6.2' # Anything higher requires Ruby 2.x
8
+ requires 'nokogiri', version: '~> 1.6.8.1' # 1.7.0 and up requires Ruby 2.1.0 (via fog-xml)
9
+ requires 'fog-rackspace', load: 'fog/rackspace'
10
+ experimental 'Rackspace Cloud Files'
11
+
12
+ def needs_key?
13
+ false
14
+ end
15
+
16
+ def api
17
+ @api ||= Fog::Storage.new(:provider => 'Rackspace', :rackspace_username => option(:username), :rackspace_api_key => option(:api_key), :rackspace_region => option(:region))
18
+ end
19
+
20
+ def check_auth
21
+ log "Authenticated as #{option(:username)}"
22
+ end
23
+
24
+ def push_app
25
+ container = api.directories.get(option(:container))
26
+
27
+ raise Error, 'The specified container does not exist.' if container.nil?
28
+
29
+ glob_args = ['**/*']
30
+ glob_args << File::FNM_DOTMATCH if options[:dot_match]
31
+
32
+ Dir.glob(*glob_args).each do |name|
33
+ container.files.create(:key => name, :body => File.open(name)) unless File.directory?(name)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,43 @@
1
+ module DPL
2
+ class Provider
3
+ class CloudFoundry < Provider
4
+
5
+ def initial_go_tools_install
6
+ context.shell 'test x$TRAVIS_OS_NAME = "xlinux" && 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'
7
+ end
8
+
9
+ def check_auth
10
+ initial_go_tools_install
11
+ context.shell "./cf api #{option(:api)} #{'--skip-ssl-validation' if options[:skip_ssl_validation]}"
12
+ context.shell "./cf login -u #{option(:username)} -p #{option(:password)} -o #{option(:organization)} -s #{option(:space)}"
13
+ end
14
+
15
+ def check_app
16
+ if options[:manifest]
17
+ error 'Application must have a manifest.yml for unattended deployment' unless File.exists? options[:manifest]
18
+ end
19
+ end
20
+
21
+ def needs_key?
22
+ false
23
+ end
24
+
25
+ def push_app
26
+ error 'Failed to push app' unless context.shell("./cf push#{manifest}")
27
+
28
+ ensure
29
+ context.shell "./cf logout"
30
+ end
31
+
32
+ def cleanup
33
+ end
34
+
35
+ def uncleanup
36
+ end
37
+
38
+ def manifest
39
+ options[:manifest].nil? ? "" : " -f #{options[:manifest]}"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,123 @@
1
+ require 'json'
2
+
3
+ module DPL
4
+ class Provider
5
+ class CodeDeploy < Provider
6
+ requires 'aws-sdk', pre: true, version: '~> 2.0'
7
+
8
+ def code_deploy
9
+ @code_deploy ||= Aws::CodeDeploy::Client.new(code_deploy_options)
10
+ end
11
+
12
+ def code_deploy_options
13
+ code_deploy_options = {
14
+ region: options[:region] || 'us-east-1',
15
+ credentials: Aws::Credentials.new(access_key_id, secret_access_key)
16
+ }
17
+ code_deploy_options[:endpoint] = options[:endpoint] if options[:endpoint]
18
+ code_deploy_options
19
+ end
20
+
21
+ def access_key_id
22
+ options[:access_key_id] || context.env['AWS_ACCESS_KEY_ID'] || raise(Error, "missing access_key_id")
23
+ end
24
+
25
+ def secret_access_key
26
+ options[:secret_access_key] || context.env['AWS_SECRET_ACCESS_KEY'] || raise(Error, "missing secret_access_key")
27
+ end
28
+
29
+ def needs_key?
30
+ false
31
+ end
32
+
33
+ def revision
34
+ case options[:revision_type].to_s.downcase
35
+ when "s3" then s3_revision
36
+ when "github" then github_revision
37
+ when "" then options[:bucket] ? s3_revision : github_revision
38
+ else error("unknown revision type %p" % options[:revision_type])
39
+ end
40
+ end
41
+
42
+ def s3_revision
43
+ {
44
+ revision_type: 'S3',
45
+ s3_location: {
46
+ bucket: option(:bucket),
47
+ bundle_type: bundle_type,
48
+ key: s3_key
49
+ }
50
+ }
51
+ end
52
+
53
+ def github_revision
54
+ {
55
+ revision_type: 'GitHub',
56
+ git_hub_location: {
57
+ commit_id: options[:commit_id] || context.env['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip,
58
+ repository: options[:repository] || context.env['TRAVIS_REPO_SLUG'] || option(:repository)
59
+ }
60
+ }
61
+ end
62
+
63
+ def push_app
64
+ data = code_deploy.create_deployment({
65
+ revision: revision,
66
+ application_name: options[:application] || option(:application_name),
67
+ deployment_group_name: options[:deployment_group] || option(:deployment_group_name),
68
+ description: options[:description] || default_description
69
+ })
70
+ log "Triggered deployment #{data.deployment_id.inspect}."
71
+ return unless options[:wait_until_deployed]
72
+ print "Deploying "
73
+ deployment = wait_until_deployed(data[:deployment_id])
74
+ print "\n"
75
+ if deployment[:status] == 'Succeeded'
76
+ log "Deployment successful."
77
+ else
78
+ error "Deployment failed."
79
+ end
80
+ rescue Aws::CodeDeploy::Errors::DeploymentLimitExceededException => exception
81
+ error(exception.message)
82
+ end
83
+
84
+ def wait_until_deployed(deployment_id)
85
+ deployment = {}
86
+ loop do
87
+ result = code_deploy.get_deployment(deployment_id: deployment_id)
88
+ deployment = result[:deployment_info]
89
+ break if deployment[:status] == "Succeeded" || deployment[:status] == "Failed" || deployment[:status] == "Stopped"
90
+ print "."
91
+ sleep 5
92
+ end
93
+ deployment
94
+ end
95
+
96
+ def bundle_type
97
+ if s3_key =~ /\.(tar|tgz|zip)$/
98
+ options[:bundle_type] || $1
99
+ else
100
+ option(:bundle_type)
101
+ end
102
+ end
103
+
104
+ def s3_key
105
+ options[:key] || option(:s3_key)
106
+ end
107
+
108
+ def default_description
109
+ "Deploy build #{context.env['TRAVIS_BUILD_NUMBER']} via Travis CI"
110
+ end
111
+
112
+ def check_auth
113
+ log "Logging in with Access Key: #{access_key_id[-4..-1].rjust(20, '*')}"
114
+ end
115
+
116
+ def cleanup
117
+ end
118
+
119
+ def uncleanup
120
+ end
121
+ end
122
+ end
123
+ end