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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2dd2e1ec1022caf3f4fc83c14292241b592240f
4
- data.tar.gz: c67dec4e629b5b7395e7b4336aad1d386f4e88ee
3
+ metadata.gz: 20ead315f5ba6d98327f23b83076eb7204362143
4
+ data.tar.gz: 8431be0109945a59cba7b7e6498a240ff611ec12
5
5
  SHA512:
6
- metadata.gz: 98bfafbc8cd1d017c7eae71f5662d1058181d388e27118d34518100ad7288249301a4778e51e271cab4f37d3c32934050aaba66728d69cfa52b1e04dc26b12d7
7
- data.tar.gz: c3659a8adf16243f9f5a12a314cf2429855a2ff29d0476053a53dc79c69d8ae9b8da86dcfe90cc39a0801baee7648a2d65e6f7c4e84086b1edb6a6850768ba8a
6
+ metadata.gz: d292509903debe72d884dc499e202782a01bcf51c8251d55542bc4460ddc54e9a4bc51e0873c78272698ed7206cc9b033d9fb399edbe69480e6148e58befbccf
7
+ data.tar.gz: 7378fc8d7d0b78722f634b670affd99f918c478f964a1f0b4edb51501882168a3da4b7bbb40bc8aff74063c61efba237b4c8b6d056fce5795b7b107995cd694f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.0 (2017-05-15)
4
+
5
+ * Replace --print-constrained-cookbook-set with --print-trimmed-universe
6
+
3
7
  ## 2.0.3 (2017-05-12)
4
8
 
5
9
  * Correctly print version if patch level was missing
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 --env-constraints production-environment-2017-05-01-18.52.40-5f5843d819ecb0b174f308d76d4336bb7bbfacbf.txt --universe my-org-universe-2017-05-01-18.52.40-1c8e59e23530b1e1a8e0b3b3cc5236a29c84e469.txt --expanded-run-list expanded-run-list-2017-05-01-18.52.40-387d90499514747792a805213c30be13d830d31f.txt
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 --env-constraints production-environment-2017-05-01-18.52.40-5f5843d819ecb0b174f308d76d4336bb7bbfacbf.txt --universe my-org-universe-2017-05-01-18.52.40-1c8e59e23530b1e1a8e0b3b3cc5236a29c84e469.txt --expanded-run-list expanded-run-list-2017-05-01-18.52.40-387d90499514747792a805213c30be13d830d31f.txt --timeout 120
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-constrained-cookbook-set
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-constrained-cookbook-set` option.
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 --env-constraints production-environment-2017-05-01-18.52.40-5f5843d819ecb0b174f308d76d4336bb7bbfacbf.txt --universe my-org-universe-2017-05-01-18.52.40-1c8e59e23530b1e1a8e0b3b3cc5236a29c84e469.txt --expanded-run-list expanded-run-list-2017-05-01-18.52.40-387d90499514747792a805213c30be13d830d31f.txt --print-constrained-cookbook-set
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.
@@ -3,10 +3,7 @@ require 'digest'
3
3
 
4
4
  module DepSelector
5
5
  class VersionConstraint
6
- def to_s
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 :print_constrained_cookbook_set,
56
- long: '--print-constrained-cookbook-set',
57
- description: 'Only print the constrained cookbook set that would be sent to the depsolver.'
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[:print_constrained_cookbook_set]
262
- print_constrained_cookbook_set(data)
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 print_constrained_cookbook_set(data)
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
- constrained_cookbook_set.sort {|x,y| x.name <=> y.name}.each {|c| puts c.to_s.gsub(/^Package/, 'Cookbook')}
393
-
394
- rescue => e
395
- puts = [:error, :exception, e.message, [e.backtrace]]
396
- end
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
@@ -1,3 +1,3 @@
1
1
  module KnifeDepsolver
2
- VERSION = "2.0.3"
2
+ VERSION = "2.1.0"
3
3
  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.3
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-12 00:00:00.000000000 Z
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.