berkshelf-shims 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +110 -1
- data/berkshelf-shims.gemspec +3 -0
- data/lib/berkshelf-shims.rb +46 -1
- data/lib/berkshelf-shims/version.rb +1 -1
- data/spec/berkshelf_shims_spec.rb +49 -20
- metadata +25 -3
data/Gemfile.lock
CHANGED
@@ -1,11 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
berkshelf-shims (0.
|
4
|
+
berkshelf-shims (0.2.0)
|
5
|
+
berkshelf (< 3.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
10
|
+
activesupport (3.2.13)
|
11
|
+
i18n (= 0.6.1)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
addressable (2.3.5)
|
14
|
+
akami (1.2.0)
|
15
|
+
gyoku (>= 0.4.0)
|
16
|
+
nokogiri (>= 1.4.0)
|
17
|
+
berkshelf (2.0.7)
|
18
|
+
activesupport (~> 3.2.0)
|
19
|
+
addressable (~> 2.3.4)
|
20
|
+
buff-shell_out (~> 0.1)
|
21
|
+
celluloid (>= 0.14.0)
|
22
|
+
chozo (>= 0.6.1)
|
23
|
+
faraday (>= 0.8.5)
|
24
|
+
hashie (>= 2.0.2)
|
25
|
+
minitar (~> 0.5.4)
|
26
|
+
rbzip2 (~> 0.2.0)
|
27
|
+
retryable (~> 1.3.3)
|
28
|
+
ridley (~> 1.2.1)
|
29
|
+
solve (>= 0.5.0)
|
30
|
+
thor (~> 0.18.0)
|
31
|
+
buff-extensions (0.5.0)
|
32
|
+
buff-ruby_engine (0.1.0)
|
33
|
+
buff-shell_out (0.1.0)
|
34
|
+
buff-ruby_engine (~> 0.1.0)
|
35
|
+
builder (3.2.2)
|
36
|
+
celluloid (0.14.1)
|
37
|
+
timers (>= 1.0.0)
|
38
|
+
celluloid-io (0.14.1)
|
39
|
+
celluloid (>= 0.14.1)
|
40
|
+
nio4r (>= 0.4.5)
|
41
|
+
chozo (0.6.1)
|
42
|
+
activesupport (>= 3.2.0)
|
43
|
+
hashie (>= 2.0.2)
|
44
|
+
multi_json (>= 1.3.0)
|
9
45
|
columnize (0.3.6)
|
10
46
|
debugger (1.5.0)
|
11
47
|
columnize (>= 0.3.1)
|
@@ -14,8 +50,55 @@ GEM
|
|
14
50
|
debugger-linecache (1.2.0)
|
15
51
|
debugger-ruby_core_source (1.2.0)
|
16
52
|
diff-lcs (1.1.3)
|
53
|
+
erubis (2.7.0)
|
54
|
+
faraday (0.8.7)
|
55
|
+
multipart-post (~> 1.1)
|
56
|
+
ffi (1.9.0)
|
57
|
+
gssapi (1.0.3)
|
58
|
+
ffi (>= 1.0.1)
|
59
|
+
gyoku (1.0.0)
|
60
|
+
builder (>= 2.1.2)
|
61
|
+
hashie (2.0.5)
|
62
|
+
httpclient (2.2.0.2)
|
63
|
+
httpi (0.9.7)
|
64
|
+
rack
|
65
|
+
i18n (0.6.1)
|
66
|
+
json (1.8.0)
|
67
|
+
little-plugger (1.1.3)
|
68
|
+
logging (1.6.2)
|
69
|
+
little-plugger (>= 1.1.3)
|
70
|
+
minitar (0.5.4)
|
71
|
+
mixlib-authentication (1.3.0)
|
72
|
+
mixlib-log
|
73
|
+
mixlib-log (1.6.0)
|
17
74
|
multi_json (1.6.1)
|
75
|
+
multipart-post (1.2.0)
|
76
|
+
net-http-persistent (2.8)
|
77
|
+
net-ssh (2.6.8)
|
78
|
+
nio4r (0.4.6)
|
79
|
+
nokogiri (1.5.10)
|
80
|
+
nori (1.1.5)
|
81
|
+
rack (1.5.2)
|
18
82
|
rake (10.0.3)
|
83
|
+
rbzip2 (0.2.0)
|
84
|
+
retryable (1.3.3)
|
85
|
+
ridley (1.2.4)
|
86
|
+
addressable
|
87
|
+
buff-extensions (~> 0.3)
|
88
|
+
buff-shell_out (~> 0.1)
|
89
|
+
celluloid (~> 0.14.0)
|
90
|
+
celluloid-io (~> 0.14.0)
|
91
|
+
erubis
|
92
|
+
faraday (>= 0.8.4)
|
93
|
+
hashie (>= 2.0.2)
|
94
|
+
json (>= 1.7.7)
|
95
|
+
mixlib-authentication (>= 1.3.0)
|
96
|
+
net-http-persistent (>= 2.8)
|
97
|
+
net-ssh
|
98
|
+
retryable
|
99
|
+
solve (>= 0.4.4)
|
100
|
+
varia_model (~> 0.1)
|
101
|
+
winrm (~> 1.1.0)
|
19
102
|
rspec (2.12.0)
|
20
103
|
rspec-core (~> 2.12.0)
|
21
104
|
rspec-expectations (~> 2.12.0)
|
@@ -24,10 +107,36 @@ GEM
|
|
24
107
|
rspec-expectations (2.12.1)
|
25
108
|
diff-lcs (~> 1.1.3)
|
26
109
|
rspec-mocks (2.12.1)
|
110
|
+
rubyntlm (0.1.1)
|
111
|
+
savon (0.9.5)
|
112
|
+
akami (~> 1.0)
|
113
|
+
builder (>= 2.1.2)
|
114
|
+
gyoku (>= 0.4.0)
|
115
|
+
httpi (~> 0.9)
|
116
|
+
nokogiri (>= 1.4.0)
|
117
|
+
nori (~> 1.0)
|
118
|
+
wasabi (~> 1.0)
|
27
119
|
simplecov (0.7.1)
|
28
120
|
multi_json (~> 1.0)
|
29
121
|
simplecov-html (~> 0.7.1)
|
30
122
|
simplecov-html (0.7.1)
|
123
|
+
solve (0.6.1)
|
124
|
+
thor (0.18.1)
|
125
|
+
timers (1.1.0)
|
126
|
+
uuidtools (2.1.4)
|
127
|
+
varia_model (0.1.1)
|
128
|
+
buff-extensions (~> 0.2)
|
129
|
+
hashie (>= 2.0.2)
|
130
|
+
wasabi (1.0.0)
|
131
|
+
nokogiri (>= 1.4.0)
|
132
|
+
winrm (1.1.2)
|
133
|
+
gssapi (~> 1.0.0)
|
134
|
+
httpclient (~> 2.2.0.2)
|
135
|
+
logging (~> 1.6.1)
|
136
|
+
nokogiri (~> 1.5.0)
|
137
|
+
rubyntlm (~> 0.1.1)
|
138
|
+
savon (= 0.9.5)
|
139
|
+
uuidtools (~> 2.1.2)
|
31
140
|
|
32
141
|
PLATFORMS
|
33
142
|
ruby
|
data/berkshelf-shims.gemspec
CHANGED
@@ -17,4 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
+
#berkshelf-shims works with berkshelf 1 and berkshelf 2 Gemfile.locks.
|
21
|
+
#we only use berkshelf code for reading the 2.0 file.
|
22
|
+
gem.add_runtime_dependency 'berkshelf', '< 3.0'
|
20
23
|
end
|
data/lib/berkshelf-shims.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module BerkshelfShims
|
2
4
|
|
3
5
|
class UnknownCookbookReferenceError < StandardError
|
@@ -18,6 +20,28 @@ module BerkshelfShims
|
|
18
20
|
object = new
|
19
21
|
object.load(content)
|
20
22
|
end
|
23
|
+
|
24
|
+
def from_lockfile(lockfile)
|
25
|
+
object = new
|
26
|
+
lockfile.load!
|
27
|
+
lockfile.sources.each do |source|
|
28
|
+
description = {}
|
29
|
+
description[:locked_version] = source.locked_version
|
30
|
+
if source.location
|
31
|
+
location = source.location
|
32
|
+
if location.class.location_key == :git
|
33
|
+
description[:git] = location.uri
|
34
|
+
description[:ref] = location.ref
|
35
|
+
elsif location.class.location_key == :path
|
36
|
+
description[:path] = location.path
|
37
|
+
else
|
38
|
+
raise "unknown location type #{location.class.location_key}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
object.cookbooks[source.name] = description
|
42
|
+
end
|
43
|
+
object
|
44
|
+
end
|
21
45
|
end
|
22
46
|
|
23
47
|
attr_reader :cookbooks
|
@@ -59,7 +83,28 @@ module BerkshelfShims
|
|
59
83
|
|
60
84
|
def self.create_shims(root, path=nil)
|
61
85
|
path ||= berkshelf_path
|
62
|
-
|
86
|
+
|
87
|
+
if running_berkshelf2? && b2_berksfile?(root)
|
88
|
+
berksfile = Berkshelf::Berksfile.new("#{root}/Berksfile")
|
89
|
+
berks_lockfile = Berkshelf::Lockfile.new(berksfile)
|
90
|
+
lockfile = BerksLockFile::from_lockfile(berks_lockfile)
|
91
|
+
else
|
92
|
+
lockfile = BerksLockFile::from_file("#{root}/Berksfile.lock")
|
93
|
+
end
|
94
|
+
lockfile.create_links("#{root}/cookbooks", path)
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.running_berkshelf2?
|
98
|
+
require 'berkshelf'
|
99
|
+
Berkshelf::VERSION.split('.').first > '1'
|
63
100
|
end
|
64
101
|
|
102
|
+
def self.b2_berksfile? path
|
103
|
+
begin
|
104
|
+
h = JSON.parse(File.read("#{path}/Berksfile.lock"))
|
105
|
+
true
|
106
|
+
rescue Exception => e
|
107
|
+
false
|
108
|
+
end
|
109
|
+
end
|
65
110
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
describe BerkshelfShims do
|
2
4
|
describe '#berkshelf_path' do
|
3
5
|
subject {BerkshelfShims.berkshelf_path}
|
@@ -18,32 +20,34 @@ describe BerkshelfShims do
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
let(:test_dir) {'tmp'}
|
23
|
+
shared_examples 'berkshelf examples' do
|
24
|
+
let(:test_dir) {File.expand_path(File.join(File.dirname(__FILE__), '../tmp'))}
|
23
25
|
let(:lock_file) {"#{test_dir}/Berksfile.lock"}
|
24
26
|
let(:cookbooks_dir) {"#{test_dir}/cookbooks"}
|
25
27
|
let(:relative_target_dir) {File.expand_path("#{test_dir}/relative")}
|
26
|
-
|
27
28
|
before do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
cookbook_entries.each do |line|
|
32
|
-
f.puts line
|
33
|
-
end
|
29
|
+
Dir.mkdir(relative_target_dir)
|
30
|
+
File.open(File.join(relative_target_dir, "metadata.rb"), 'w') do |f|
|
31
|
+
f.write('name "relative"')
|
34
32
|
end
|
35
33
|
end
|
34
|
+
|
36
35
|
context 'with a normal input' do
|
37
36
|
let(:cookbook_entries) {[
|
38
37
|
"cookbook 'relative', :path => '#{relative_target_dir}'",
|
39
38
|
"cookbook 'versioned', :locked_version => '0.0.1'",
|
40
39
|
"cookbook 'somegitrepo', :git => 'http://github.com/someuser/somegitrepo.git', :ref => '6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a'"
|
41
40
|
]}
|
41
|
+
let(:v2_cookbook_entries) {{
|
42
|
+
#Still converting these entries 2.0 format.
|
43
|
+
'relative' => {:path => "#{relative_target_dir}"},
|
44
|
+
'versioned' => {:locked_version => '0.0.1'},
|
45
|
+
'somegitrepo' => {:git => 'http://github.com/someuser/somegitrepo.git', :ref => '6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a'}
|
46
|
+
}}
|
42
47
|
|
43
48
|
context 'with the default berkshelf path' do
|
44
49
|
before do
|
45
|
-
|
46
|
-
BerkshelfShims::create_shims('tmp')
|
50
|
+
BerkshelfShims::create_shims(test_dir)
|
47
51
|
end
|
48
52
|
it 'creates the links' do
|
49
53
|
Dir.exists?(cookbooks_dir).should == true
|
@@ -51,11 +55,10 @@ describe BerkshelfShims do
|
|
51
55
|
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
52
56
|
File.readlink("#{cookbooks_dir}/versioned").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/versioned-0.0.1"
|
53
57
|
File.readlink("#{cookbooks_dir}/somegitrepo").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
54
|
-
Dir["#{relative_target_dir}/*"].should == []
|
55
58
|
end
|
56
59
|
context 'run a second time' do
|
57
60
|
before do
|
58
|
-
BerkshelfShims::create_shims(
|
61
|
+
BerkshelfShims::create_shims(test_dir)
|
59
62
|
end
|
60
63
|
it 'creates the links' do
|
61
64
|
Dir.exists?(cookbooks_dir).should == true
|
@@ -63,14 +66,13 @@ describe BerkshelfShims do
|
|
63
66
|
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
64
67
|
File.readlink("#{cookbooks_dir}/versioned").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/versioned-0.0.1"
|
65
68
|
File.readlink("#{cookbooks_dir}/somegitrepo").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
66
|
-
Dir["#{relative_target_dir}/*"].should == []
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
73
|
context 'with an explicit berkshelf path' do
|
72
74
|
before do
|
73
|
-
BerkshelfShims::create_shims(
|
75
|
+
BerkshelfShims::create_shims(test_dir, 'berkshelf')
|
74
76
|
end
|
75
77
|
it 'creates the links' do
|
76
78
|
Dir.exists?(cookbooks_dir).should == true
|
@@ -83,15 +85,15 @@ describe BerkshelfShims do
|
|
83
85
|
|
84
86
|
context 'with an environent variable' do
|
85
87
|
before do
|
86
|
-
ENV[BerkshelfShims::BERKSHELF_PATH_ENV] =
|
87
|
-
BerkshelfShims::create_shims(
|
88
|
+
ENV[BerkshelfShims::BERKSHELF_PATH_ENV] = "#{test_dir}/berkshelf_env"
|
89
|
+
BerkshelfShims::create_shims(test_dir)
|
88
90
|
end
|
89
91
|
it 'creates the links' do
|
90
92
|
Dir.exists?(cookbooks_dir).should == true
|
91
93
|
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
92
94
|
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
93
|
-
File.readlink("#{cookbooks_dir}/versioned").should == "/berkshelf_env/cookbooks/versioned-0.0.1"
|
94
|
-
File.readlink("#{cookbooks_dir}/somegitrepo").should == "/berkshelf_env/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
95
|
+
File.readlink("#{cookbooks_dir}/versioned").should == "#{test_dir}/berkshelf_env/cookbooks/versioned-0.0.1"
|
96
|
+
File.readlink("#{cookbooks_dir}/somegitrepo").should == "#{test_dir}/berkshelf_env/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
@@ -100,9 +102,36 @@ describe BerkshelfShims do
|
|
100
102
|
let(:cookbook_entries) {[
|
101
103
|
"cookbook 'relative'"
|
102
104
|
]}
|
105
|
+
let(:v2_cookbook_entries) {{
|
106
|
+
'relative' => {}
|
107
|
+
}}
|
103
108
|
it 'throws an error' do
|
104
|
-
expect {BerkshelfShims::create_shims(
|
109
|
+
expect {BerkshelfShims::create_shims(test_dir)}.to raise_error BerkshelfShims::UnknownCookbookReferenceError
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'Berkshelf 1.0 format' do
|
115
|
+
before do
|
116
|
+
FileUtils.rm_rf(test_dir)
|
117
|
+
FileUtils.mkdir(test_dir)
|
118
|
+
File.open(lock_file, 'w') do |f|
|
119
|
+
cookbook_entries.each do |line|
|
120
|
+
f.puts line
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
include_examples 'berkshelf examples'
|
125
|
+
end
|
126
|
+
|
127
|
+
describe 'Berkshelf 2.0 format' do
|
128
|
+
before do
|
129
|
+
FileUtils.rm_rf(test_dir)
|
130
|
+
FileUtils.mkdir(test_dir)
|
131
|
+
File.open(lock_file, 'w') do |f|
|
132
|
+
f.write(JSON.dump({:sources => v2_cookbook_entries}))
|
105
133
|
end
|
106
134
|
end
|
135
|
+
include_examples 'berkshelf examples'
|
107
136
|
end
|
108
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf-shims
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
-
dependencies:
|
12
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: berkshelf
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - <
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
14
30
|
description: Shim functionality for Berkshelf
|
15
31
|
email:
|
16
32
|
- bellegar@gmail.com
|
@@ -43,12 +59,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
59
|
- - ! '>='
|
44
60
|
- !ruby/object:Gem::Version
|
45
61
|
version: '0'
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
hash: 4266870366331531644
|
46
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
66
|
none: false
|
48
67
|
requirements:
|
49
68
|
- - ! '>='
|
50
69
|
- !ruby/object:Gem::Version
|
51
70
|
version: '0'
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
hash: 4266870366331531644
|
52
74
|
requirements: []
|
53
75
|
rubyforge_project:
|
54
76
|
rubygems_version: 1.8.23
|