knife-depsolver 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +13 -5
- data/lib/chef/knife/depsolver.rb +19 -16
- data/lib/knife-depsolver/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20ead315f5ba6d98327f23b83076eb7204362143
|
4
|
+
data.tar.gz: 8431be0109945a59cba7b7e6498a240ff611ec12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d292509903debe72d884dc499e202782a01bcf51c8251d55542bc4460ddc54e9a4bc51e0873c78272698ed7206cc9b033d9fb399edbe69480e6148e58befbccf
|
7
|
+
data.tar.gz: 7378fc8d7d0b78722f634b670affd99f918c478f964a1f0b4edb51501882168a3da4b7bbb40bc8aff74063c61efba237b4c8b6d056fce5795b7b107995cd694f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -103,7 +103,7 @@ Now use the "--env-constraints", "universe" and "expanded-run-list" options to p
|
|
103
103
|
For example:
|
104
104
|
|
105
105
|
```
|
106
|
-
knife depsolver --
|
106
|
+
knife depsolver --expanded-run-list expanded-run-list-2017-05-01-18.52.40-387d90499514747792a805213c30be13d830d31f.txt --universe my-org-universe-2017-05-01-18.52.40-1c8e59e23530b1e1a8e0b3b3cc5236a29c84e469.txt --env-constraints production-environment-2017-05-01-18.52.40-5f5843d819ecb0b174f308d76d4336bb7bbfacbf.txt
|
107
107
|
```
|
108
108
|
|
109
109
|
Now it is easy to modify the environment cookbook version constraints or the cookbook universe input files to see the impact on the depsolver.
|
@@ -113,21 +113,29 @@ Now it is easy to modify the environment cookbook version constraints or the coo
|
|
113
113
|
Sometimes it can help to give the depsolver more than the default five seconds to perform its calculations. This can be done by using the "--timeout <seconds>" option to change the depsolver timeout.
|
114
114
|
|
115
115
|
```
|
116
|
-
knife depsolver --
|
116
|
+
knife depsolver --expanded-run-list expanded-run-list-2017-05-01-18.52.40-387d90499514747792a805213c30be13d830d31f.txt --universe my-org-universe-2017-05-01-18.52.40-1c8e59e23530b1e1a8e0b3b3cc5236a29c84e469.txt --env-constraints production-environment-2017-05-01-18.52.40-5f5843d819ecb0b174f308d76d4336bb7bbfacbf.txt --timeout 120
|
117
117
|
```
|
118
118
|
|
119
|
-
#### --print-
|
119
|
+
#### --print-trimmed-universe
|
120
120
|
|
121
|
-
Sometimes you want to only see the list of cookbooks, and their cookbook dependency version constraints, that ultimately would be sent to the depsolver without actually triggering the depsolver calculation. This is especially helpful when the depsolver isn't returning any results because it can't calculate a solution in a reasonable amount of time. This can be done by using the `--print-
|
121
|
+
Sometimes you want to only see the list of cookbooks, and their cookbook dependency version constraints, that ultimately would be sent to the depsolver without actually triggering the depsolver calculation. This is especially helpful when the depsolver isn't returning any results because it can't calculate a solution in a reasonable amount of time. This can be done by using the `--print-trimmed-universe` option.
|
122
122
|
|
123
123
|
```
|
124
|
-
knife depsolver --
|
124
|
+
knife depsolver --expanded-run-list expanded-run-list-2017-05-01-18.52.40-387d90499514747792a805213c30be13d830d31f.txt --universe my-org-universe-2017-05-01-18.52.40-1c8e59e23530b1e1a8e0b3b3cc5236a29c84e469.txt --env-constraints production-environment-2017-05-01-18.52.40-5f5843d819ecb0b174f308d76d4336bb7bbfacbf.txt --print-trimmed-universe
|
125
125
|
```
|
126
126
|
|
127
127
|
Now you can review the output to see if you can find anything that could be causing problems for the depsolver. You can make changes to the input files to see the impact on the list of cookbooks that would be sent to the depsolver.
|
128
128
|
|
129
129
|
If necessary you could also use the list of cookbooks as a starting point for setting version constraints in the environment input file. Then you can modify that set of version constraints and run the depsolver in an effort to get a solution in a reasonable amount of time or to isolate the problem.
|
130
130
|
|
131
|
+
#### /tmp/DepSelectorDebugOn
|
132
|
+
|
133
|
+
If you really want to enable the dep_selector gem's debug level output then you can simply create the `touch /tmp/DepSelectorDebugOn` file on your workstation's disk.
|
134
|
+
|
135
|
+
```
|
136
|
+
touch /tmp/DepSelectorDebugOn
|
137
|
+
```
|
138
|
+
|
131
139
|
### Chef Server < 12.4.0
|
132
140
|
|
133
141
|
knife-depsolver requires cookbook universe data in order to use Chef DK's embedded depsolver. The "/universe" API endpoint was added in the Chef Server 12.4.0 release.
|
data/lib/chef/knife/depsolver.rb
CHANGED
@@ -3,10 +3,7 @@ require 'digest'
|
|
3
3
|
|
4
4
|
module DepSelector
|
5
5
|
class VersionConstraint
|
6
|
-
|
7
|
-
version = @missing_patch_level ? "#{@version.major}.#{@version.minor}" : @version.to_s
|
8
|
-
"#{@op} #{version}"
|
9
|
-
end
|
6
|
+
attr_reader :missing_patch_level
|
10
7
|
end
|
11
8
|
end
|
12
9
|
|
@@ -52,9 +49,9 @@ class Chef
|
|
52
49
|
long: '--env-constraints-filter-universe',
|
53
50
|
description: 'Filter the cookbook universe using the environment cookbook version constraints.'
|
54
51
|
|
55
|
-
option :
|
56
|
-
long: '--print-
|
57
|
-
description: '
|
52
|
+
option :print_trimmed_universe,
|
53
|
+
long: '--print-trimmed-universe',
|
54
|
+
description: 'Print the cookbooks and dependency data that would be sent to the depsolver.'
|
58
55
|
|
59
56
|
def run
|
60
57
|
begin
|
@@ -258,8 +255,8 @@ class Chef
|
|
258
255
|
|
259
256
|
data = {environment_constraints: env_ckbk_constraints, all_versions: all_versions, run_list: expanded_run_list_with_split_versions, timeout_ms: timeout}
|
260
257
|
|
261
|
-
if config[:
|
262
|
-
|
258
|
+
if config[:print_trimmed_universe]
|
259
|
+
puts JSON.pretty_generate(get_trimmed_universe(data))
|
263
260
|
exit!
|
264
261
|
end
|
265
262
|
|
@@ -341,8 +338,7 @@ class Chef
|
|
341
338
|
end
|
342
339
|
end
|
343
340
|
|
344
|
-
def
|
345
|
-
begin
|
341
|
+
def get_trimmed_universe(data)
|
346
342
|
# create dependency graph from cookbooks
|
347
343
|
graph = DepSelector::DependencyGraph.new
|
348
344
|
|
@@ -389,11 +385,18 @@ class Chef
|
|
389
385
|
selector = DepSelector::Selector.new(graph, (timeout_ms / 1000.0))
|
390
386
|
|
391
387
|
constrained_cookbook_set = selector.send(:trim_unreachable_packages, selector.dep_graph, run_list)
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
388
|
+
trimmed_universe = Hash.new { |h,k| h[k] = Hash.new { |h,k| h[k] = Hash.new { |h,k| h[k] = Hash.new } } }
|
389
|
+
constrained_cookbook_set.each do |ckbk|
|
390
|
+
ckbk.versions.each do |ckbk_version|
|
391
|
+
trimmed_universe[ckbk.name][ckbk_version.version]["dependencies"] = Hash.new
|
392
|
+
ckbk_version.dependencies.each do |ckbk_version_dep|
|
393
|
+
constraint = ckbk_version_dep.constraint
|
394
|
+
constraint_version = constraint.missing_patch_level ? "#{constraint.version.major}.#{constraint.version.minor}" : "#{constraint.version}"
|
395
|
+
trimmed_universe[ckbk.name][ckbk_version.version]["dependencies"][ckbk_version_dep.package.name] = "#{constraint.op} #{constraint_version}"
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
trimmed_universe
|
397
400
|
end
|
398
401
|
end
|
399
402
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-depsolver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremiah Snapp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Knife plugin that uses Chef Server to calculate cookbook dependencies
|
14
14
|
for a given run_list.
|