dpl 1.7.10.travis.668.1 → 1.7.10.travis.673.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 +8 -1
- data/README.md +14 -0
- data/lib/dpl/provider.rb +1 -0
- data/lib/dpl/provider/chef_supermarket.rb +81 -0
- data/spec/provider/chef_supermarket_spec.rb +51 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTkyMWJmOTAzNjg0NGJmYzBjYmU0Nzc2YjA0MjUzNzRjY2E4ZjQ0Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTIxNTUyZmFlMzUwNzhlNTk5MDMxOTkzZDQ3NmZlM2EwZjE0ODU5Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGU4MWY3YTlkMGExOWQ5YjE0NDE2NmIzYjM3NTVhYTE5NWUwYzA5MDY4YzRk
|
10
|
+
NmQyZDUxMTEyODgwZjVjOTg2NzFhMDNhMDUzMTM5ZjU1NjZhZjI4ZGVkNjUx
|
11
|
+
YTIwOGQ4MDkyMTRlOTI4ODhkMzhhMjFhODI5MDIwMDhlZmU2OTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjdlMWJiY2MyODQxZjA1NTMxNDAxODY1NzZmODIzY2QzMTcwZmEzYjU2NGM1
|
14
|
+
NThkYjljN2ZmZWQwZDdkMDE4ZTFlYzVlZWE1NmQ4YWJhZDk0Njc5YzY3MjM1
|
15
|
+
NTUzNGRkNGJkNmE1ZTliNjE3MDg2NmFmYzZlMDdhYjJhZDM2ZDg=
|
data/Gemfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
|
4
|
+
platforms :mri_19 do
|
5
|
+
gem 'slop', '~> 3.6.0'
|
6
|
+
gem 'ohai', '~> 7.4.0'
|
7
|
+
end
|
5
8
|
|
6
9
|
group :heroku do
|
7
10
|
gem 'rendezvous', '~> 0.0.2'
|
@@ -69,3 +72,7 @@ end
|
|
69
72
|
group :packagecloud do
|
70
73
|
gem 'packagecloud-ruby', '= 0.2.17'
|
71
74
|
end
|
75
|
+
|
76
|
+
group :chef_supermarket do
|
77
|
+
gem 'chef'
|
78
|
+
end
|
data/README.md
CHANGED
@@ -31,6 +31,7 @@ Dpl supports the following providers:
|
|
31
31
|
* [Elastic Beanstalk](#elastic-beanstalk)
|
32
32
|
* [Puppet Forge](#puppet-forge)
|
33
33
|
* [packagecloud](#packagecloud)
|
34
|
+
* [Chef Supermarket](#chef-supermarket)
|
34
35
|
|
35
36
|
## Installation:
|
36
37
|
|
@@ -442,3 +443,16 @@ For accounts using two factor authentication, you have to use an oauth token as
|
|
442
443
|
dpl --provider=packagecloud --username=packageuser --token=t0k3n --repository=myrepo
|
443
444
|
dpl --provider=packagecloud --username=packageuser --token=t0k3n --repository=myrepo --dist=ubuntu/precise
|
444
445
|
dpl --provider=packagecloud --username=packageuser --token=t0k3n --repository=myrepo --local-dir="${TRAVIS_BUILD_DIR}/pkgs" --dist=ubuntu/precise
|
446
|
+
|
447
|
+
### Chef Supermarket:
|
448
|
+
|
449
|
+
#### Options:
|
450
|
+
|
451
|
+
* **user_id**: Required. The user name at Chef Supermarket.
|
452
|
+
* **client_key**: Required. The client API key file name.
|
453
|
+
* **cookbook_category**: Required. The cookbook category in Supermarket (see: https://docs.getchef.com/knife_cookbook_site.html#id12 )
|
454
|
+
|
455
|
+
#### Examples:
|
456
|
+
|
457
|
+
dpl --provider=chef-supermarket --user-id=chef --client-key=.travis/client.pem --cookbook-category=Others
|
458
|
+
|
data/lib/dpl/provider.rb
CHANGED
@@ -35,6 +35,7 @@ module DPL
|
|
35
35
|
autoload :ElasticBeanstalk, 'dpl/provider/elastic_beanstalk'
|
36
36
|
autoload :PuppetForge, 'dpl/provider/puppet_forge'
|
37
37
|
autoload :Packagecloud, 'dpl/provider/packagecloud'
|
38
|
+
autoload :ChefSupermarket, 'dpl/provider/chef_supermarket'
|
38
39
|
|
39
40
|
|
40
41
|
def self.new(context, options)
|
@@ -0,0 +1,81 @@
|
|
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
|
+
requires 'chef', load: 'chef/config'
|
9
|
+
requires 'chef', load: 'chef/cookbook_loader'
|
10
|
+
requires 'chef', load: 'chef/cookbook_uploader'
|
11
|
+
requires 'chef', load: 'chef/cookbook_site_streaming_uploader'
|
12
|
+
|
13
|
+
attr_reader :cookbook_name, :cookbook_category
|
14
|
+
attr_reader :cookbook
|
15
|
+
|
16
|
+
def needs_key?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_auth
|
21
|
+
error "Missing user_id option" unless options[:user_id]
|
22
|
+
error "Missing client_key option" unless options[:client_key]
|
23
|
+
::Chef::Config[:client_key] = options[:client_key]
|
24
|
+
error "#{options[:client_key]} does not exist" unless ::File.exist?(options[:client_key])
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_app
|
28
|
+
@cookbook_name = options[:cookbook_name] || options[:app]
|
29
|
+
@cookbook_category = options[:cookbook_category]
|
30
|
+
unless cookbook_category
|
31
|
+
error "Missing cookbook_category option\n" +
|
32
|
+
"see https://docs.getchef.com/knife_cookbook_site.html#id12"
|
33
|
+
end
|
34
|
+
|
35
|
+
log "Validating cookbook #{cookbook_name}"
|
36
|
+
# Check that cookbook exist and is valid
|
37
|
+
# So we assume cookbook path is '..'
|
38
|
+
cl = ::Chef::CookbookLoader.new '..'
|
39
|
+
@cookbook = cl[cookbook_name]
|
40
|
+
::Chef::CookbookUploader.new(cookbook, '..').validate_cookbooks
|
41
|
+
end
|
42
|
+
|
43
|
+
def push_app
|
44
|
+
log "Creating cookbook build directory"
|
45
|
+
tmp_cookbook_dir = Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
|
46
|
+
log "Making tarball in #{tmp_cookbook_dir}"
|
47
|
+
system("tar -czf #{cookbook_name}.tgz #{cookbook_name}", :chdir => tmp_cookbook_dir)
|
48
|
+
|
49
|
+
uri = "http://cookbooks.opscode.com/api/v1/cookbooks"
|
50
|
+
|
51
|
+
log "Uploading to #{uri}"
|
52
|
+
category_string = { 'category'=>cookbook_category }.to_json
|
53
|
+
http_resp = ::Chef::CookbookSiteStreamingUploader.post(
|
54
|
+
uri,
|
55
|
+
options[:user_id],
|
56
|
+
options[:client_key],
|
57
|
+
{
|
58
|
+
:tarball => File.open("#{tmp_cookbook_dir}/#{cookbook_name}.tgz"),
|
59
|
+
:cookbook => category_string
|
60
|
+
}
|
61
|
+
)
|
62
|
+
res = ::Chef::JSONCompat.from_json(http_resp.body)
|
63
|
+
if http_resp.code.to_i != 201
|
64
|
+
if res['error_messages']
|
65
|
+
if res['error_messages'][0] =~ /Version already exists/
|
66
|
+
error "The same version of this cookbook already exists on the Opscode Cookbook Site."
|
67
|
+
else
|
68
|
+
error "#{res['error_messages'][0]}"
|
69
|
+
end
|
70
|
+
else
|
71
|
+
error "Unknown error while sharing cookbook\n" +
|
72
|
+
"Server response: #{http_resp.body}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
log "Upload complete."
|
77
|
+
::FileUtils.rm_rf tmp_cookbook_dir
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'chef/cookbook_loader'
|
3
|
+
require 'chef/cookbook_uploader'
|
4
|
+
require 'dpl/provider/chef_supermarket'
|
5
|
+
|
6
|
+
describe DPL::Provider::ChefSupermarket do
|
7
|
+
subject :provider do
|
8
|
+
described_class.new(
|
9
|
+
DummyContext.new,
|
10
|
+
app: 'example',
|
11
|
+
cookbook_category: 'Others',
|
12
|
+
user_id: 'user',
|
13
|
+
client_key: '/tmp/example.pem'
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:cookbook_uploader) do
|
18
|
+
double('cookbook_uploader', validate_cookbooks: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:http_resp) do
|
22
|
+
double('http_resp', body: '{}', code: '201')
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#check_auth" do
|
26
|
+
example do
|
27
|
+
::File.stub(:exist?).and_return(true)
|
28
|
+
expect(File).to receive(:exist?)
|
29
|
+
provider.check_auth
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#check_app" do
|
34
|
+
example do
|
35
|
+
::Chef::CookbookLoader.any_instance.stub(:[]).and_return nil
|
36
|
+
expect(::Chef::CookbookUploader).to receive(:new).and_return(cookbook_uploader)
|
37
|
+
provider.check_app
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#push_app" do
|
42
|
+
example do
|
43
|
+
expect(::Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return('/tmp/build_dir')
|
44
|
+
expect(provider).to receive(:system).and_return(true)
|
45
|
+
expect(::File).to receive(:open)
|
46
|
+
expect(::Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(http_resp)
|
47
|
+
expect(::FileUtils).to receive(:rm_rf).with('/tmp/build_dir')
|
48
|
+
provider.push_app
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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.10.travis.
|
4
|
+
version: 1.7.10.travis.673.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/dpl/provider/appfog.rb
|
104
104
|
- lib/dpl/provider/biicode.rb
|
105
105
|
- lib/dpl/provider/bitballoon.rb
|
106
|
+
- lib/dpl/provider/chef_supermarket.rb
|
106
107
|
- lib/dpl/provider/cloud66.rb
|
107
108
|
- lib/dpl/provider/cloud_files.rb
|
108
109
|
- lib/dpl/provider/cloud_foundry.rb
|
@@ -142,6 +143,7 @@ files:
|
|
142
143
|
- spec/cli_spec.rb
|
143
144
|
- spec/provider/appfog_spec.rb
|
144
145
|
- spec/provider/bitballoon_spec.rb
|
146
|
+
- spec/provider/chef_supermarket_spec.rb
|
145
147
|
- spec/provider/cloud66_spec.rb
|
146
148
|
- spec/provider/cloud_files_spec.rb
|
147
149
|
- spec/provider/cloudcontrol_spec.rb
|