dpl 1.7.17.travis.868.4 → 1.7.17.travis.869.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGIxZDVhM2Q0MmExZGMzMWIyOTdmN2QxMWFlYWNkMWUyOWU1ZGJkYw==
4
+ ZGMyYWFmM2JkMTU0MTBiM2MxZDJhOWQ5NDA3YjM0ZTRjMzQ1MjI5OA==
5
5
  data.tar.gz: !binary |-
6
- ZThhNGNlN2E3YjFmNjUwNDdmZTdkYjA0YzkyZTViNjI0OTI0ZmUxYg==
6
+ MGY2MjM1YzFiYjNmYTU4MDgyYjRmNzM0YjhjOTgwOTIxOTQxMzVjMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGZkMWE5MmFjYmEwYTFmYjNlM2FhYzM1MGU4YzljNTkzZDM2YTI0NGJhOGE4
10
- ZjAwZmMwZDgyNTZjNDlhMDhmMzcyOTBiYWU0YTg0MGY3ZGI4MDRlMTVkOTg5
11
- MWMxOTgxZjRhZGMyMmE2Mjc4M2Q5Y2FjN2QxZWVjODRlMWIxZTA=
9
+ N2JjMzljMjViMTI4NDUwYjQyOWE0ODljZmRiYmI0ODQ4ODA3M2RjNWM4NDM2
10
+ NWI1MzRiOTJjMTY4YTgwYzc0ODY0MGU0YzQ3MDEzZWViZTgyMjljNzhiYTE4
11
+ MTNmMzcyOTEyOGZiOGRmMjZkNmE1NjdmNTQ2OTg2MGM0M2RiMWQ=
12
12
  data.tar.gz: !binary |-
13
- YzAyZmZmNjg3ZDZlNWFmN2EyNGE0MjI3NGRkNTc1YzU5ZGRjNWIwMDVjOTYw
14
- NjFhODA3Mzc0NmJlYjEyMThjNmFkODU4MjY2OTg0MzMwNWYxMmFhZDY1YWQy
15
- NGIzMzYyZmZiNDhhN2I4NTU0NmVlYjNmZmU4ZTk4YTZiZjYyNWM=
13
+ ZTdlNWI3ZGQwYTVhYjAxOTJkMjI0MDlkOTYyYTE4MGVmZmIzMDcxOTIxNmE4
14
+ NmE2NGNmY2RjMTEzZTc2MmY1YTdmYjUzYjI1OTM2MWM0MjljNjIyYjQ0ZTc0
15
+ MDA2NjczNGQxZDFhODBiNjQ2NzdjMzVmMDVlMTk2MWU3NjQzODI=
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Dpl [![Build Status](https://travis-ci.org/travis-ci/dpl.svg?branch=master)](https://travis-ci.org/travis-ci/dpl) [![Code Climate](https://codeclimate.com/github/travis-ci/dpl.png)](https://codeclimate.com/github/travis-ci/dpl) [![Gem Version](https://badge.fury.io/rb/dpl.png)](http://badge.fury.io/rb/dpl) [![Coverage Status](https://coveralls.io/repos/travis-ci/dpl/badge.png)](https://coveralls.io/r/travis-ci/dpl)
1
+ # Dpl [![Build Status](https://travis-ci.org/travis-ci/dpl.svg?branch=master)](https://travis-ci.org/travis-ci/dpl) [![Code Climate](https://codeclimate.com/github/travis-ci/dpl.png)](https://codeclimate.com/github/travis-ci/dpl) [![Gem Version](https://badge.fury.io/rb/dpl.png)](http://badge.fury.io/rb/dpl) [![Coverage Status](https://coveralls.io/repos/travis-ci/dpl/badge.svg?branch=master&service=github)](https://coveralls.io/github/travis-ci/dpl?branch=master)
2
2
 
3
3
  ## Supported Providers:
4
4
  Dpl supports the following providers:
data/lib/dpl/provider.rb CHANGED
@@ -6,40 +6,42 @@ module DPL
6
6
  class Provider
7
7
  include FileUtils
8
8
 
9
- autoload :Heroku, 'dpl/provider/heroku'
10
9
  autoload :Appfog, 'dpl/provider/appfog'
11
- autoload :EngineYard, 'dpl/provider/engine_yard'
12
- autoload :DotCloud, 'dpl/provider/dot_cloud'
13
- autoload :Nodejitsu, 'dpl/provider/nodejitsu'
14
- autoload :Openshift, 'dpl/provider/openshift'
15
- autoload :RubyGems, 'dpl/provider/rubygems'
16
- autoload :NPM, 'dpl/provider/npm'
17
- autoload :S3, 'dpl/provider/s3'
10
+ autoload :Atlas, 'dpl/provider/atlas'
11
+ autoload :Biicode, 'dpl/provider/biicode'
12
+ autoload :Bintray, 'dpl/provider/bintray'
13
+ autoload :BitBalloon, 'dpl/provider/bitballoon'
14
+ autoload :ChefSupermarket, 'dpl/provider/chef_supermarket'
15
+ autoload :Cloud66, 'dpl/provider/cloud66'
18
16
  autoload :CloudControl, 'dpl/provider/cloudcontrol'
17
+ autoload :CloudFiles, 'dpl/provider/cloud_files'
19
18
  autoload :CloudFoundry, 'dpl/provider/cloud_foundry'
20
19
  autoload :CodeDeploy, 'dpl/provider/code_deploy'
21
- autoload :Lambda, 'dpl/provider/lambda'
22
- autoload :PyPI, 'dpl/provider/pypi'
23
- autoload :Divshot, 'dpl/provider/divshot'
24
- autoload :CloudFiles, 'dpl/provider/cloud_files'
25
- autoload :OpsWorks, 'dpl/provider/ops_works'
26
- autoload :Modulus, 'dpl/provider/modulus'
27
- autoload :Releases, 'dpl/provider/releases'
28
- autoload :Cloud66, 'dpl/provider/cloud66'
29
- autoload :Hackage, 'dpl/provider/hackage'
30
20
  autoload :Deis, 'dpl/provider/deis'
31
- autoload :GCS, 'dpl/provider/gcs'
32
- autoload :GAE, 'dpl/provider/gae'
33
- autoload :BitBalloon, 'dpl/provider/bitballoon'
34
- autoload :Biicode, 'dpl/provider/biicode'
21
+ autoload :Divshot, 'dpl/provider/divshot'
22
+ autoload :DotCloud, 'dpl/provider/dot_cloud'
35
23
  autoload :ElasticBeanstalk, 'dpl/provider/elastic_beanstalk'
36
- autoload :PuppetForge, 'dpl/provider/puppet_forge'
37
- autoload :Packagecloud, 'dpl/provider/packagecloud'
38
- autoload :ChefSupermarket, 'dpl/provider/chef_supermarket'
39
- autoload :TestFairy, 'dpl/provider/testfairy'
24
+ autoload :EngineYard, 'dpl/provider/engine_yard'
40
25
  autoload :ExoScale, 'dpl/provider/exoscale'
41
- autoload :Bintray, 'dpl/provider/bintray'
26
+ autoload :GAE, 'dpl/provider/gae'
27
+ autoload :GCS, 'dpl/provider/gcs'
28
+ autoload :Hackage, 'dpl/provider/hackage'
29
+ autoload :Heroku, 'dpl/provider/heroku'
30
+ autoload :Lambda, 'dpl/provider/lambda'
31
+ autoload :Modulus, 'dpl/provider/modulus'
32
+ autoload :Nodejitsu, 'dpl/provider/nodejitsu'
33
+ autoload :NPM, 'dpl/provider/npm'
34
+ autoload :Openshift, 'dpl/provider/openshift'
35
+ autoload :OpsWorks, 'dpl/provider/ops_works'
36
+ autoload :Packagecloud, 'dpl/provider/packagecloud'
37
+ autoload :PuppetForge, 'dpl/provider/puppet_forge'
38
+ autoload :PyPI, 'dpl/provider/pypi'
39
+ autoload :Releases, 'dpl/provider/releases'
40
+ autoload :RubyGems, 'dpl/provider/rubygems'
41
+ autoload :S3, 'dpl/provider/s3'
42
42
  autoload :Script, 'dpl/provider/script'
43
+ autoload :TestFairy, 'dpl/provider/testfairy'
44
+ autoload :Transifex, 'dpl/provider/transifex'
43
45
 
44
46
 
45
47
  def self.new(context, options)
@@ -0,0 +1,98 @@
1
+ module DPL
2
+ class Provider
3
+ class Atlas < Provider
4
+ GIMME_URL = 'https://raw.githubusercontent.com/meatballhat/gimme/master/gimme'
5
+ ATLAS_UPLOAD_CLI_GO_REMOTE = 'github.com/hashicorp/atlas-upload-cli'
6
+ ATLAS_UPLOAD_BOOL_ARGS = %w(vcs debug).map(&:to_sym).freeze
7
+ ATLAS_UPLOAD_KV_ARGS = %w(address).map(&:to_sym).freeze
8
+ ATLAS_UPLOAD_KV_MULTI_ARGS = %w(exclude include metadata).map(&:to_sym).freeze
9
+ ATLAS_UPLOAD_INSTALL_SCRIPT = <<-EOF.gsub(/^ {8}/, '').strip
10
+ if ! command -v atlas-upload &>/dev/null ; then
11
+ mkdir -p $HOME/bin $HOME/gopath/src
12
+ export PATH="$HOME/bin:$PATH"
13
+
14
+ if ! command -v gimme &>/dev/null ; then
15
+ curl -sL -o $HOME/bin/gimme #{GIMME_URL}
16
+ chmod +x $HOME/bin/gimme
17
+ fi
18
+
19
+ export GOPATH="$HOME/gopath:$GOPATH"
20
+ eval "$(gimme 1.4.2)" &>/dev/null
21
+
22
+ go get #{ATLAS_UPLOAD_CLI_GO_REMOTE}
23
+ pushd $HOME/gopath/src/#{ATLAS_UPLOAD_CLI_GO_REMOTE} &>/dev/null
24
+ make &>/dev/null
25
+ cp bin/atlas-upload $HOME/bin/atlas-upload
26
+ popd &>/dev/null
27
+ fi
28
+ EOF
29
+
30
+ experimental 'Atlas'
31
+
32
+ def deploy
33
+ assert_app_present!
34
+ install_atlas_upload
35
+ super
36
+ end
37
+
38
+ def check_auth
39
+ ENV['ATLAS_TOKEN'] = options[:token] if options[:token]
40
+ error 'Missing ATLAS_TOKEN' unless ENV['ATLAS_TOKEN']
41
+ end
42
+
43
+ def needs_key?
44
+ false
45
+ end
46
+
47
+ def push_app
48
+ unless options[:paths]
49
+ here = Dir.pwd
50
+ warn "No paths specified. Using #{here.inspect}."
51
+ options[:paths] = here
52
+ end
53
+
54
+ Array(options[:paths]).each do |path|
55
+ context.shell "atlas-upload #{atlas_upload_args} #{atlas_app} #{path}"
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def install_atlas_upload
62
+ context.shell ATLAS_UPLOAD_INSTALL_SCRIPT
63
+ end
64
+
65
+ def assert_app_present!
66
+ error 'Missing Atlas app name' unless options.key?(:app)
67
+ end
68
+
69
+ def atlas_upload_args
70
+ return options[:args] if options.key?(:args)
71
+ return @atlas_upload_args if @atlas_upload_args
72
+
73
+ args = []
74
+
75
+ ATLAS_UPLOAD_BOOL_ARGS.each do |arg|
76
+ args << "-#{arg}" if options.key?(arg)
77
+ end
78
+
79
+ ATLAS_UPLOAD_KV_ARGS.each do |arg|
80
+ args << ["-#{arg}", options[arg].inspect].join('=') if options.key?(arg)
81
+ end
82
+
83
+ ATLAS_UPLOAD_KV_MULTI_ARGS.each do |arg|
84
+ next unless options.key?(arg)
85
+ Array(options[arg]).each do |arg_entry|
86
+ args << ["-#{arg}", arg_entry.inspect].join('=')
87
+ end
88
+ end
89
+
90
+ @atlas_upload_args = args.join(' ')
91
+ end
92
+
93
+ def atlas_app
94
+ @atlas_app ||= options.fetch(:app).to_s
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,45 @@
1
+ module DPL
2
+ class Provider
3
+ class Transifex < Provider
4
+ experimental 'Transifex'
5
+
6
+ DEFAULT_CLIENT_VERSION = '>=0.11'
7
+ DEFAULT_HOSTNAME = 'https://www.transifex.com'
8
+
9
+ def install_deploy_dependencies
10
+ cli_version = options[:cli_version] || DEFAULT_CLIENT_VERSION
11
+ self.class.pip 'transifex', 'transifex', cli_version
12
+ end
13
+
14
+ def needs_key?
15
+ false
16
+ end
17
+
18
+ def check_auth
19
+ install_deploy_dependencies
20
+ write_transifexrc
21
+ context.shell 'tx status'
22
+ end
23
+
24
+ def push_app
25
+ source_push
26
+ end
27
+
28
+ def write_transifexrc
29
+ File.open(File.expand_path('~/.transifexrc'), 'w') do |f|
30
+ f.puts [
31
+ "[#{options[:hostname] || DEFAULT_HOSTNAME}]",
32
+ "hostname = #{options[:hostname] || DEFAULT_HOSTNAME}",
33
+ "username = #{options[:username]}",
34
+ "password = #{options[:password]}",
35
+ "token = #{options[:token]}",
36
+ ].join("\n")
37
+ end
38
+ end
39
+
40
+ def source_push
41
+ context.shell 'tx push --source --no-interactive', retry: true
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,97 @@
1
+ require 'securerandom'
2
+
3
+ require 'spec_helper'
4
+ require 'dpl/provider/atlas'
5
+
6
+ describe DPL::Provider::Atlas do
7
+ before :all do
8
+ @origwd = Dir.pwd
9
+ @tmpdir = Dir.mktmpdir
10
+ ENV['HOME'] = @tmpdir
11
+ Dir.chdir(@tmpdir)
12
+ end
13
+
14
+ after :all do
15
+ FileUtils.rm_rf(@tmpdir) if @tmpdir
16
+ Dir.chdir(@origwd) if @origwd
17
+ end
18
+
19
+ let(:context) { DummyContext.new }
20
+ let(:options) { { token: SecureRandom.hex(16), include: 'bin/*', exclude: 'tmp/*' } }
21
+
22
+ subject(:provider) { described_class.new(context, options) }
23
+
24
+ describe '#check_auth' do
25
+ specify 'without ATLAS_TOKEN' do
26
+ provider.options.delete(:token)
27
+ expect { provider.check_auth }.to raise_error(DPL::Error)
28
+ end
29
+
30
+ specify 'with ATLAS_TOKEN' do
31
+ provider.options.update(token: SecureRandom.hex(16))
32
+ expect { provider.check_auth }.to_not raise_error
33
+ end
34
+ end
35
+
36
+ describe '#needs_key?' do
37
+ it { expect(provider.needs_key?).to eq(false) }
38
+ end
39
+
40
+ describe '#deploy' do
41
+ specify 'without :app aborts' do
42
+ provider.options.delete(:app)
43
+ expect { provider.deploy }.to raise_error(DPL::Error)
44
+ end
45
+
46
+ specify 'with :app does not abort' do
47
+ provider.options.update(app: 'dpl/testapp')
48
+ expect { provider.deploy }.to_not raise_error
49
+ end
50
+ end
51
+
52
+ describe 'building atlas-upload args' do
53
+ context 'when full args are provided' do
54
+ let(:options) { { args: '-whatever' } }
55
+
56
+ it 'returns full args directly' do
57
+ expect(provider.send(:atlas_upload_args)).to eql('-whatever')
58
+ end
59
+ end
60
+
61
+ context 'when no arg keys are provided' do
62
+ let(:options) { {} }
63
+
64
+ it 'returns empty args' do
65
+ expect(provider.send(:atlas_upload_args)).to eql('')
66
+ end
67
+ end
68
+
69
+ [
70
+ {
71
+ options: { wat: true, debug: true },
72
+ args: '-debug'
73
+ },
74
+ {
75
+ options: { vcs: nil },
76
+ args: '-vcs'
77
+ },
78
+ {
79
+ options: { include: ['build/*', 'bin/*'], exclude: '*.log' },
80
+ args: '-exclude="*.log" -include="build/*" -include="bin/*"'
81
+ },
82
+ {
83
+ options: {
84
+ include: 'bin/*',
85
+ exclude: ['*.log', '*.out'],
86
+ metadata: ['foo=bar', 'whatever=else']
87
+ },
88
+ args: '-exclude="*.log" -exclude="*.out" -include="bin/*" -metadata="foo=bar" -metadata="whatever=else"'
89
+ }
90
+ ].each_with_index do |example, i|
91
+ context "with options #{example[:options].inspect}" do
92
+ let(:options) { example[:options] }
93
+ it { expect(provider.send(:atlas_upload_args)).to eql(example[:args]) }
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,110 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/transifex'
3
+
4
+ describe DPL::Provider::Transifex do
5
+ let(:options) do
6
+ {
7
+ hostname: 'https://www.nottransifex.example.com',
8
+ username: 'travis',
9
+ password: 'secret',
10
+ token: 'abcd1234'
11
+ }
12
+ end
13
+
14
+ subject :provider do
15
+ described_class.new(DummyContext.new, options)
16
+ end
17
+
18
+ describe '#install_deploy_dependencies' do
19
+ context 'without version specified' do
20
+ example "installs #{described_class::DEFAULT_CLIENT_VERSION}" do
21
+ expect(provider.class).to(
22
+ receive(:pip).with('transifex', 'transifex', described_class::DEFAULT_CLIENT_VERSION)
23
+ )
24
+ provider.install_deploy_dependencies
25
+ end
26
+ end
27
+
28
+ context 'with version specified' do
29
+ before do
30
+ options[:cli_version] = '==0.12'
31
+ end
32
+
33
+ example 'installs custom version' do
34
+ expect(provider.class).to(
35
+ receive(:pip).with('transifex', 'transifex', '==0.12')
36
+ )
37
+ provider.install_deploy_dependencies
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '#needs_key?' do
43
+ example do
44
+ expect(provider.needs_key?).to eq(false)
45
+ end
46
+ end
47
+
48
+ describe '#check_auth' do
49
+ before do
50
+ allow(provider).to receive(:install_deploy_dependencies)
51
+ allow(provider).to receive(:write_transifexrc)
52
+ end
53
+
54
+ example 'installs dependencies' do
55
+ expect(provider).to receive(:install_deploy_dependencies)
56
+ provider.check_auth
57
+ end
58
+
59
+ example 'writes ~/.transifexrc' do
60
+ expect(provider).to receive(:write_transifexrc)
61
+ provider.check_auth
62
+ end
63
+
64
+ example 'performs a tx status' do
65
+ expect(provider.context).to receive(:shell).with('tx status')
66
+ provider.check_auth
67
+ end
68
+ end
69
+
70
+ describe '#push_app' do
71
+ example 'delegates to the #source_push method' do
72
+ expect(provider).to receive(:source_push)
73
+ provider.push_app
74
+ end
75
+ end
76
+
77
+ describe '#source_push' do
78
+ example 'performs a tx push' do
79
+ expect(provider.context).to(
80
+ receive(:shell).with('tx push --source --no-interactive', retry: true)
81
+ )
82
+ provider.source_push
83
+ end
84
+ end
85
+
86
+ describe '#write_transifexrc' do
87
+ let(:fake_config) { StringIO.new }
88
+
89
+ before do
90
+ allow(File).to receive(:open).and_yield(fake_config)
91
+ end
92
+
93
+ example 'writes config with hostname header' do
94
+ expect(fake_config).to receive(:puts).with(/^\[#{options[:hostname]}\]/)
95
+ provider.write_transifexrc
96
+ end
97
+
98
+ %w(
99
+ hostname
100
+ username
101
+ password
102
+ token
103
+ ).map(&:to_sym).each do |key|
104
+ example "writes config with #{key} key" do
105
+ expect(fake_config).to receive(:puts).with(/^#{key} = #{options[key]}$/)
106
+ provider.write_transifexrc
107
+ end
108
+ end
109
+ end
110
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.17.travis.868.4
4
+ version: 1.7.17.travis.869.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -115,6 +115,7 @@ files:
115
115
  - lib/dpl/error.rb
116
116
  - lib/dpl/provider.rb
117
117
  - lib/dpl/provider/appfog.rb
118
+ - lib/dpl/provider/atlas.rb
118
119
  - lib/dpl/provider/biicode.rb
119
120
  - lib/dpl/provider/bintray.rb
120
121
  - lib/dpl/provider/bitballoon.rb
@@ -154,12 +155,14 @@ files:
154
155
  - lib/dpl/provider/s3.rb
155
156
  - lib/dpl/provider/script.rb
156
157
  - lib/dpl/provider/testfairy.rb
158
+ - lib/dpl/provider/transifex.rb
157
159
  - lib/dpl/version.rb
158
160
  - notes/dotcloud.md
159
161
  - notes/engine_yard.md
160
162
  - notes/heroku.md
161
163
  - spec/cli_spec.rb
162
164
  - spec/provider/appfog_spec.rb
165
+ - spec/provider/atlas_spec.rb
163
166
  - spec/provider/bintray_spec.rb
164
167
  - spec/provider/bitballoon_spec.rb
165
168
  - spec/provider/chef_supermarket_spec.rb
@@ -193,6 +196,7 @@ files:
193
196
  - spec/provider/s3_spec.rb
194
197
  - spec/provider/script_spec.rb
195
198
  - spec/provider/testfairy_spec.rb
199
+ - spec/provider/transifex_spec.rb
196
200
  - spec/provider_spec.rb
197
201
  - spec/spec_helper.rb
198
202
  homepage: https://github.com/travis-ci/dpl