dpl 1.7.9.travis.662.1 → 1.7.9.travis.664.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/Gemfile +5 -1
- data/README.md +17 -0
- data/lib/dpl/provider.rb +1 -2
- data/lib/dpl/provider/packagecloud.rb +125 -0
- data/spec/provider/packagecloud_spec.rb +35 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjlmN2JiMTlkY2ZkOGI1YjAxYjM4YTgxNzZmNmFiZTAzYTc1MWRiOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDRkMmFkMDI0MTFiNzVhOWJmMjg4MTA1YmNjODZiMTUzODM4NWYxOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2QzMzlhY2MwMzZlN2Q3YTM1MTc4MzE4ZjNlNjNkZjQ5NTgxMmQzYmJhYTMw
|
10
|
+
YTJmOWRkNTdhZTIyNjY3YzA3ZTZmZmIxYzEyNGU5MmIxZGJkZGU1MzA0MzI0
|
11
|
+
OWNlMWM0YjgzNjI0YmZhZDJkODRjNjgxNjQxNDY1YzgyZTNkNmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDUxODRkMDlhYWM2Yjk4ZTg3YmI1NTA1NmJhMDg2OWQ5OTVjNjVmOWU0ZDNh
|
14
|
+
MzU1NjVlNDk1YmNjMjMxMmI4OTc4OGY3OTA2MTlkNjNkNjBkYWNhM2JmM2Fi
|
15
|
+
ODI4MTYwZjgyZDI4NDFmNjYxNWEzZTRjY2ViOGM4NjRhNWU1ZTg=
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem 'slop', '~> 3.6.0'
|
4
|
+
gem 'slop', '~> 3.6.0' # can drop this once Ruby 1.9.x is dropped
|
5
5
|
|
6
6
|
group :heroku do
|
7
7
|
gem 'rendezvous', '~> 0.0.2'
|
@@ -65,3 +65,7 @@ group :puppet_forge do
|
|
65
65
|
gem 'puppet'
|
66
66
|
gem 'puppet-blacksmith'
|
67
67
|
end
|
68
|
+
|
69
|
+
group :packagecloud do
|
70
|
+
gem 'packagecloud-ruby', '= 0.2.17'
|
71
|
+
end
|
data/README.md
CHANGED
@@ -30,6 +30,7 @@ Dpl supports the following providers:
|
|
30
30
|
* [Google Cloud Storage](#google-cloud-storage)
|
31
31
|
* [Elastic Beanstalk](#elastic-beanstalk)
|
32
32
|
* [Puppet Forge](#puppet-forge)
|
33
|
+
* [packagecloud](#packagecloud)
|
33
34
|
|
34
35
|
## Installation:
|
35
36
|
|
@@ -425,3 +426,19 @@ For accounts using two factor authentication, you have to use an oauth token as
|
|
425
426
|
#### Examples:
|
426
427
|
|
427
428
|
dpl --provider=puppetforge --user=puppetlabs --password=s3cr3t
|
429
|
+
|
430
|
+
### packagecloud:
|
431
|
+
|
432
|
+
#### Options:
|
433
|
+
|
434
|
+
* **username**: Required. The packagecloud.io username.
|
435
|
+
* **token**: Required. The [packagecloud.io api token](https://packagecloud.io/docs/api#api_tokens).
|
436
|
+
* **repository**: Required. The repository to push to.
|
437
|
+
* **local_dir**: Optional. The sub-directory of the built assets for deployment. Default to current path.
|
438
|
+
* **dist**: Required for deb and rpm. The complete list of supported strings can be found on the [packagecloud.io docs](https://packagecloud.io/docs#os_distro_version)
|
439
|
+
|
440
|
+
#### Examples:
|
441
|
+
|
442
|
+
dpl --provider=packagecloud --username=packageuser --token=t0k3n --repository=myrepo
|
443
|
+
dpl --provider=packagecloud --username=packageuser --token=t0k3n --repository=myrepo --dist=ubuntu/precise
|
444
|
+
dpl --provider=packagecloud --username=packageuser --token=t0k3n --repository=myrepo --local-dir="${TRAVIS_BUILD_DIR}/pkgs" --dist=ubuntu/precise
|
data/lib/dpl/provider.rb
CHANGED
@@ -34,6 +34,7 @@ module DPL
|
|
34
34
|
autoload :Biicode, 'dpl/provider/biicode'
|
35
35
|
autoload :ElasticBeanstalk, 'dpl/provider/elastic_beanstalk'
|
36
36
|
autoload :PuppetForge, 'dpl/provider/puppet_forge'
|
37
|
+
autoload :Packagecloud, 'dpl/provider/packagecloud'
|
37
38
|
|
38
39
|
|
39
40
|
def self.new(context, options)
|
@@ -154,7 +155,6 @@ module DPL
|
|
154
155
|
|
155
156
|
def cleanup
|
156
157
|
return if options[:skip_cleanup]
|
157
|
-
puts "Performing #{__method__}"
|
158
158
|
context.shell "mv .dpl ~/dpl"
|
159
159
|
context.shell "git stash --all"
|
160
160
|
context.shell "mv ~/dpl .dpl"
|
@@ -162,7 +162,6 @@ module DPL
|
|
162
162
|
|
163
163
|
def uncleanup
|
164
164
|
return if options[:skip_cleanup]
|
165
|
-
puts "Performing #{__method__}"
|
166
165
|
context.shell "git stash pop"
|
167
166
|
end
|
168
167
|
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module DPL
|
2
|
+
class Provider
|
3
|
+
class Packagecloud < Provider
|
4
|
+
requires 'packagecloud-ruby', :version => "0.2.17", :load => 'packagecloud'
|
5
|
+
|
6
|
+
def check_auth
|
7
|
+
setup_auth
|
8
|
+
begin
|
9
|
+
@client = ::Packagecloud::Client.new(@creds, "travis-ci")
|
10
|
+
rescue ::Packagecloud::UnauthenticatedException
|
11
|
+
error "Could not authenticate to https://packagecloud.io, please check credentials"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def needs_key?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_auth
|
20
|
+
@username = option(:username)
|
21
|
+
@token = option(:token)
|
22
|
+
@repo = option(:repository)
|
23
|
+
@dist = option(:dist) if options[:dist]
|
24
|
+
@creds = ::Packagecloud::Credentials.new(@username, @token)
|
25
|
+
log "Logging into https://packagecloud.io with #{@username}:#{@token}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_distro(query)
|
29
|
+
distro = nil
|
30
|
+
begin
|
31
|
+
distro = @client.find_distribution_id(query)
|
32
|
+
rescue ArgumentError => exception
|
33
|
+
error "Error: #{exception.message}"
|
34
|
+
end
|
35
|
+
if distro.nil?
|
36
|
+
error "Could not find distribution named #{query}"
|
37
|
+
end
|
38
|
+
distro
|
39
|
+
end
|
40
|
+
|
41
|
+
def is_supported_package?(filename)
|
42
|
+
ext = File.extname(filename).gsub!('.','')
|
43
|
+
::Packagecloud::SUPPORTED_EXTENSIONS.include?(ext)
|
44
|
+
end
|
45
|
+
|
46
|
+
def dist_required?(filename)
|
47
|
+
ext = File.extname(filename).gsub!('.','')
|
48
|
+
["rpm", "deb", "dsc"].include?(ext)
|
49
|
+
end
|
50
|
+
|
51
|
+
def error_if_dist_required(filename)
|
52
|
+
ext = File.extname(filename).gsub!('.','')
|
53
|
+
if dist_required?(ext) && @dist.nil?
|
54
|
+
error "Distribution needed for rpm, deb, and dsc packages, example --dist='ubuntu/breezy'"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def is_source_package?(filename)
|
59
|
+
ext = File.extname(filename).gsub!('.','')
|
60
|
+
ext == 'dsc'
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_source_files_for(orig_filename)
|
64
|
+
source_files = {}
|
65
|
+
glob_args = ["**/*"]
|
66
|
+
package = ::Packagecloud::Package.new(open(orig_filename))
|
67
|
+
result = @client.package_contents(@repo, package)
|
68
|
+
if result.succeeded
|
69
|
+
package_contents_files = result.response["files"].map { |x| x["filename"] }
|
70
|
+
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
|
71
|
+
Dir.glob(*glob_args) do |filename|
|
72
|
+
unless File.directory?(filename)
|
73
|
+
basename = File.basename(filename)
|
74
|
+
if package_contents_files.include?(basename)
|
75
|
+
log "Found source fragment: #{basename} for #{orig_filename}"
|
76
|
+
source_files = source_files.merge({basename => open(filename)})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
else
|
82
|
+
error "Error: #{result.response}"
|
83
|
+
end
|
84
|
+
source_files
|
85
|
+
end
|
86
|
+
|
87
|
+
def push_app
|
88
|
+
packages = []
|
89
|
+
glob_args = ["**/*"]
|
90
|
+
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
|
91
|
+
Dir.glob(*glob_args) do |filename|
|
92
|
+
unless File.directory?(filename)
|
93
|
+
if is_supported_package?(filename)
|
94
|
+
error_if_dist_required(filename)
|
95
|
+
log "Detected supported package: #{filename}"
|
96
|
+
if dist_required?(filename)
|
97
|
+
if is_source_package?(filename)
|
98
|
+
log "Processing source package: #{filename}"
|
99
|
+
source_files = get_source_files_for(filename)
|
100
|
+
packages << ::Packagecloud::Package.new(open(filename), get_distro(@dist), source_files, filename)
|
101
|
+
else
|
102
|
+
packages << ::Packagecloud::Package.new(open(filename), get_distro(@dist), {}, filename)
|
103
|
+
end
|
104
|
+
else
|
105
|
+
packages << ::Packagecloud::Package.new(open(filename), nil, {}, filename)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
packages.each do |package|
|
113
|
+
result = @client.put_package(@repo, package)
|
114
|
+
if result.succeeded
|
115
|
+
log "Successfully pushed #{package.filename} to #{@username}/#{@repo}"
|
116
|
+
else
|
117
|
+
error "Error #{result.response}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'gems'
|
4
|
+
require 'dpl/provider/packagecloud'
|
5
|
+
|
6
|
+
describe DPL::Provider::Packagecloud do
|
7
|
+
|
8
|
+
subject :provider do
|
9
|
+
described_class.new(DummyContext.new, :username => 'joedamato', :repository => 'test_repo', :token => 'test_token')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#setup_auth" do
|
13
|
+
it 'should get username and token' do
|
14
|
+
expect(provider).to receive(:log).with("Logging into https://packagecloud.io with joedamato:test_token")
|
15
|
+
provider.setup_auth
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should require username' do
|
19
|
+
new_provider = described_class.new(DummyContext.new, {:token => 'test_token'})
|
20
|
+
expect{ new_provider.setup_auth }.to raise_error("missing username")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should require token' do
|
24
|
+
new_provider = described_class.new(DummyContext.new, {:username => 'test_token'})
|
25
|
+
expect{ new_provider.setup_auth }.to raise_error("missing token")
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should require repository' do
|
29
|
+
new_provider = described_class.new(DummyContext.new, {:username => 'joedamato', :token => 'test_token'})
|
30
|
+
expect{ new_provider.setup_auth }.to raise_error("missing repository")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.9.travis.
|
4
|
+
version: 1.7.9.travis.664.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/dpl/provider/npm.rb
|
130
130
|
- lib/dpl/provider/openshift.rb
|
131
131
|
- lib/dpl/provider/ops_works.rb
|
132
|
+
- lib/dpl/provider/packagecloud.rb
|
132
133
|
- lib/dpl/provider/puppet_forge.rb
|
133
134
|
- lib/dpl/provider/pypi.rb
|
134
135
|
- lib/dpl/provider/releases.rb
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- spec/provider/npm.rb
|
163
164
|
- spec/provider/openshift_spec.rb
|
164
165
|
- spec/provider/ops_works_spec.rb
|
166
|
+
- spec/provider/packagecloud_spec.rb
|
165
167
|
- spec/provider/puppet_forge_spec.rb
|
166
168
|
- spec/provider/pypi_spec.rb
|
167
169
|
- spec/provider/releases_spec.rb
|