berkshelf 7.0.3 → 7.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e40b61641ae3c98575c4de9bf668625ff927b829075dab610fc4388439f16e7c
4
- data.tar.gz: 0d2128e0cb9b388125cc388c08bf75ad43a6f4152626ed92f056d8001e924c85
3
+ metadata.gz: 2a9aad824018ff76341d429a3f3d1a56a3a20baa0a47353b71214103dd0b82db
4
+ data.tar.gz: e99375d510d02668eeb7734aad0dacc173aadd0b8751f0bcea2d6f23821da4b0
5
5
  SHA512:
6
- metadata.gz: 9c8d3807ef828c33ae5eb2204af6f4936cea58399a641f2eef919a0beb88252ff4e55c0caf3c64928d4f0e67609d9794d6435ac9060dbfda23adf8a182c64edd
7
- data.tar.gz: 681703640274ec3b8bb49ab87c574c40e423aac69c6c2af060468b76704252e62647e1f7268df1d76677c846a4a02fe5ed66d43dac85e981fef034bf256bf655
6
+ metadata.gz: 86965767066caf25df3b87b33d17968d7dde55bf34613d5748fecebba7f00ac36bd0b0c1217f02342435f6c3e6106f9bd019bf687823aac9107ffc6c8e420e85
7
+ data.tar.gz: 65f4eb23956d447c36eb2fb90b8d96bd89ab39352f1478bed5ff4969479a4b6781a1943009439e5b41c5ea5631dc81fbb44a5ad1c2b10c0fdcd8d18bbc92fb69
@@ -44,7 +44,7 @@ GIT
44
44
  PATH
45
45
  remote: .
46
46
  specs:
47
- berkshelf (7.0.3)
47
+ berkshelf (7.0.4)
48
48
  chef (>= 13.6.52)
49
49
  chef-config
50
50
  cleanroom (~> 1.0)
@@ -104,18 +104,22 @@ module Berkshelf
104
104
  #
105
105
  # @return [Array<CachedCookbook>]
106
106
  #
107
- def lookup_dependencies(cookbook, dependencies = [], checked = {})
107
+ def lookup_dependencies(cookbook, checked = {})
108
108
  Berkshelf.log.debug " Looking up dependencies for #{cookbook}"
109
+
110
+ dependencies = []
111
+
109
112
  lockfile.graph.find(cookbook).dependencies.each do |name, _|
110
113
  next if checked[name]
111
114
 
112
- dependencies << name
113
-
115
+ # break cyclic graphs
114
116
  checked[name] = true
115
117
 
116
- lookup_dependencies(name, dependencies, checked) unless lockfile.graph.find(name).dependencies.empty?
118
+ # this is your standard depth-first tree traversal with the deps first...
119
+ dependencies += lookup_dependencies(name, checked)
120
+ # ..then the node itself
121
+ dependencies << name
117
122
  end
118
-
119
123
  dependencies
120
124
  end
121
125
 
@@ -134,11 +138,13 @@ module Berkshelf
134
138
  # that would be a bad idea...
135
139
  dependencies = berksfile.dependencies.map(&:name)
136
140
 
137
- cookbook_order = dependencies.each do |dependency|
138
- lookup_dependencies(dependency, dependencies)
139
- end
141
+ checked = {}
142
+ cookbook_order = dependencies.map do |dependency|
143
+ # for each dep add all its deps first, then the dep itself
144
+ lookup_dependencies(dependency, checked) + [ dependency ]
145
+ end.flatten
140
146
 
141
- cookbook_order.reverse.map { |dependency| lockfile.retrieve(dependency) }.uniq
147
+ cookbook_order.uniq.map { |dependency| lockfile.retrieve(dependency) }
142
148
  end
143
149
  end
144
150
  end
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "7.0.3"
2
+ VERSION = "7.0.4"
3
3
  end
@@ -231,7 +231,18 @@ module Berkshelf
231
231
  subject { described_class.new(berksfile).send(:filtered_cookbooks) }
232
232
 
233
233
  it "returns filtered list in correct order" do
234
- expect(subject.map(&:name)).to eq ["yum", "yum-epel", "build-essential", "runit", "apt", "jenkins", "jenkins-config"]
234
+ upload_order = subject.map(&:name)
235
+ # assert that dependent cookbooks are uploaded before the cookbooks that depend on them
236
+ expect(upload_order.index("apt")).to be < upload_order.index("jenkins")
237
+ expect(upload_order.index("runit")).to be < upload_order.index("jenkins")
238
+ expect(upload_order.index("yum")).to be < upload_order.index("jenkins")
239
+ expect(upload_order.index("jenkins")).to be < upload_order.index("jenkins-config")
240
+ expect(upload_order.index("yum")).to be < upload_order.index("jenkins-config")
241
+ expect(upload_order.index("build-essential")).to be < upload_order.index("runit")
242
+ expect(upload_order.index("yum")).to be < upload_order.index("runit")
243
+ expect(upload_order.index("yum-epel")).to be < upload_order.index("runit")
244
+ expect(upload_order.index("yum")).to be < upload_order.index("yum-epel")
245
+ expect(upload_order.uniq.length).to eql(upload_order.length)
235
246
  end
236
247
  end
237
248
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.3
4
+ version: 7.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-06-06 00:00:00.000000000 Z
15
+ date: 2018-06-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mixlib-shellout