octocatalog-diff 0.6.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/README.md +5 -2
- data/bin/octocatalog-diff +9 -49
- data/doc/CHANGELOG.md +14 -0
- data/doc/advanced-filter.md +59 -1
- data/doc/advanced-override-enc.md +54 -0
- data/doc/advanced-pe-enc.md +1 -1
- data/doc/advanced.md +2 -1
- data/doc/dev/api.md +5 -0
- data/doc/dev/api/v1.md +41 -0
- data/doc/dev/api/v1/calls/catalog-diff.md +209 -0
- data/doc/dev/api/v1/calls/catalog.md +115 -0
- data/doc/dev/api/v1/calls/config.md +37 -0
- data/doc/dev/api/v1/objects/catalog.md +127 -0
- data/doc/dev/api/v1/objects/diff.md +261 -0
- data/doc/dev/api/v1/objects/override.md +30 -0
- data/doc/dev/how-to-add-options.md +12 -12
- data/doc/optionsref.md +91 -74
- data/doc/versions/v1.md +22 -0
- data/lib/octocatalog-diff.rb +1 -8
- data/lib/octocatalog-diff/api/v1.rb +27 -0
- data/lib/octocatalog-diff/api/v1/catalog-compile.rb +40 -0
- data/lib/octocatalog-diff/api/v1/catalog-diff.rb +68 -0
- data/lib/octocatalog-diff/api/v1/catalog.rb +84 -0
- data/lib/octocatalog-diff/api/v1/common.rb +24 -0
- data/lib/octocatalog-diff/api/v1/config.rb +125 -0
- data/lib/octocatalog-diff/api/v1/diff.rb +194 -0
- data/lib/octocatalog-diff/api/v1/override.rb +103 -0
- data/lib/octocatalog-diff/catalog-diff/differ.rb +66 -47
- data/lib/octocatalog-diff/catalog-diff/display.rb +8 -2
- data/lib/octocatalog-diff/catalog-diff/display/json.rb +3 -2
- data/lib/octocatalog-diff/catalog-diff/display/legacy_json.rb +28 -0
- data/lib/octocatalog-diff/catalog-diff/display/text.rb +64 -9
- data/lib/octocatalog-diff/catalog-diff/filter.rb +45 -6
- data/lib/octocatalog-diff/catalog-diff/filter/absent_file.rb +65 -0
- data/lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb +78 -0
- data/lib/octocatalog-diff/catalog-diff/filter/yaml.rb +10 -7
- data/lib/octocatalog-diff/catalog-util/bootstrap.rb +13 -14
- data/lib/octocatalog-diff/catalog-util/builddir.rb +1 -0
- data/lib/octocatalog-diff/catalog-util/cached_master_directory.rb +2 -2
- data/lib/octocatalog-diff/catalog-util/enc.rb +49 -14
- data/lib/octocatalog-diff/catalog-util/enc/pe.rb +3 -5
- data/lib/octocatalog-diff/catalog-util/enc/pe/v1.rb +3 -1
- data/lib/octocatalog-diff/catalog-util/git.rb +36 -24
- data/lib/octocatalog-diff/catalog.rb +5 -9
- data/lib/octocatalog-diff/catalog/computed.rb +9 -1
- data/lib/octocatalog-diff/catalog/puppetdb.rb +4 -3
- data/lib/octocatalog-diff/cli.rb +195 -0
- data/lib/octocatalog-diff/cli/diffs.rb +40 -0
- data/lib/octocatalog-diff/cli/options.rb +183 -0
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/basedir.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_current.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_environment.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_script.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_then_exit.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrapped_dirs.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/cached_master_dir.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/catalog_only.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/color.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/command_line.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/compare_file_text.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/create_symlinks.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/debug.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/debug_bootstrap.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/display_datatype_changes.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/display_detail_add.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/display_source_file_line.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/enc.rb +1 -1
- data/lib/octocatalog-diff/cli/options/enc_override.rb +21 -0
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/environment.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/existing_catalogs.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/fact_file.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/fact_override.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/facts_terminus.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/filters.rb +5 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/from_puppetdb.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/header.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hiera_config.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hiera_path.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hiera_path_strip.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hostname.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/ignore.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/ignore_attr.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/ignore_tags.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/include_tags.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/master_cache_branch.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/output_file.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/output_format.rb +5 -3
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/parallel.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/parser.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pass_env_vars.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_ssl_ca.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_ssl_client_cert.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_ssl_client_key.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_token.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_token_file.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_url.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/preserve_environments.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_binary.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_api_version.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_ssl_ca.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_ssl_client_cert.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_ssl_client_key.rb +2 -2
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_api_version.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_ca.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_cert.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_key.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_password.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_password_file.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_url.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/quiet.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/retry_failed_catalog.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/safe_to_delete_cached_master_dir.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/storeconfigs.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/suppress_absent_file_details.rb +2 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/to_from_branch.rb +1 -1
- data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/validate_references.rb +1 -1
- data/lib/octocatalog-diff/cli/printer.rb +52 -0
- data/lib/octocatalog-diff/errors.rb +33 -0
- data/lib/octocatalog-diff/facts.rb +1 -4
- data/lib/octocatalog-diff/facts/puppetdb.rb +8 -7
- data/lib/octocatalog-diff/puppetdb.rb +5 -9
- data/lib/octocatalog-diff/util/catalogs.rb +242 -0
- metadata +97 -75
- data/lib/octocatalog-diff/catalog-diff/cli.rb +0 -211
- data/lib/octocatalog-diff/catalog-diff/cli/catalogs.rb +0 -246
- data/lib/octocatalog-diff/catalog-diff/cli/diffs.rb +0 -147
- data/lib/octocatalog-diff/catalog-diff/cli/helpers/fact_override.rb +0 -100
- data/lib/octocatalog-diff/catalog-diff/cli/options.rb +0 -185
- data/lib/octocatalog-diff/catalog-diff/cli/printer.rb +0 -54
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octocatalog-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: diffy
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- doc/advanced-ignores.md
|
237
237
|
- doc/advanced-output-formats.md
|
238
238
|
- doc/advanced-output-hacks.md
|
239
|
+
- doc/advanced-override-enc.md
|
239
240
|
- doc/advanced-override-facts.md
|
240
241
|
- doc/advanced-pe-enc.md
|
241
242
|
- doc/advanced-puppet-master.md
|
@@ -250,6 +251,14 @@ files:
|
|
250
251
|
- doc/configuration-puppetdb.md
|
251
252
|
- doc/configuration.md
|
252
253
|
- doc/dev/README.md
|
254
|
+
- doc/dev/api.md
|
255
|
+
- doc/dev/api/v1.md
|
256
|
+
- doc/dev/api/v1/calls/catalog-diff.md
|
257
|
+
- doc/dev/api/v1/calls/catalog.md
|
258
|
+
- doc/dev/api/v1/calls/config.md
|
259
|
+
- doc/dev/api/v1/objects/catalog.md
|
260
|
+
- doc/dev/api/v1/objects/diff.md
|
261
|
+
- doc/dev/api/v1/objects/override.md
|
253
262
|
- doc/dev/coverage.md
|
254
263
|
- doc/dev/how-to-add-options.md
|
255
264
|
- doc/dev/integration-tests.md
|
@@ -262,86 +271,25 @@ files:
|
|
262
271
|
- doc/roadmap.md
|
263
272
|
- doc/similar.md
|
264
273
|
- doc/troubleshooting.md
|
274
|
+
- doc/versions/v1.md
|
265
275
|
- lib/octocatalog-diff.rb
|
276
|
+
- lib/octocatalog-diff/api/v1.rb
|
277
|
+
- lib/octocatalog-diff/api/v1/catalog-compile.rb
|
278
|
+
- lib/octocatalog-diff/api/v1/catalog-diff.rb
|
279
|
+
- lib/octocatalog-diff/api/v1/catalog.rb
|
280
|
+
- lib/octocatalog-diff/api/v1/common.rb
|
281
|
+
- lib/octocatalog-diff/api/v1/config.rb
|
282
|
+
- lib/octocatalog-diff/api/v1/diff.rb
|
283
|
+
- lib/octocatalog-diff/api/v1/override.rb
|
266
284
|
- lib/octocatalog-diff/bootstrap.rb
|
267
|
-
- lib/octocatalog-diff/catalog-diff/cli.rb
|
268
|
-
- lib/octocatalog-diff/catalog-diff/cli/catalogs.rb
|
269
|
-
- lib/octocatalog-diff/catalog-diff/cli/diffs.rb
|
270
|
-
- lib/octocatalog-diff/catalog-diff/cli/helpers/fact_override.rb
|
271
|
-
- lib/octocatalog-diff/catalog-diff/cli/options.rb
|
272
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/basedir.rb
|
273
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_current.rb
|
274
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_environment.rb
|
275
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_script.rb
|
276
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_then_exit.rb
|
277
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb
|
278
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/cached_master_dir.rb
|
279
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/catalog_only.rb
|
280
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/color.rb
|
281
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/command_line.rb
|
282
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/compare_file_text.rb
|
283
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/create_symlinks.rb
|
284
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/debug.rb
|
285
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/debug_bootstrap.rb
|
286
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/display_datatype_changes.rb
|
287
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/display_detail_add.rb
|
288
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/display_source_file_line.rb
|
289
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/enc.rb
|
290
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/environment.rb
|
291
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/existing_catalogs.rb
|
292
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/fact_file.rb
|
293
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/fact_override.rb
|
294
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/facts_terminus.rb
|
295
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/filters.rb
|
296
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/from_puppetdb.rb
|
297
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/header.rb
|
298
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/hiera_config.rb
|
299
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/hiera_path.rb
|
300
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/hiera_path_strip.rb
|
301
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/hostname.rb
|
302
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/ignore.rb
|
303
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/ignore_attr.rb
|
304
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/ignore_tags.rb
|
305
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/include_tags.rb
|
306
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/master_cache_branch.rb
|
307
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/output_file.rb
|
308
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/output_format.rb
|
309
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/parallel.rb
|
310
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/parser.rb
|
311
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pass_env_vars.rb
|
312
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_ca.rb
|
313
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_cert.rb
|
314
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_key.rb
|
315
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token.rb
|
316
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token_file.rb
|
317
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_url.rb
|
318
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/preserve_environments.rb
|
319
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppet_binary.rb
|
320
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppet_master.rb
|
321
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_api_version.rb
|
322
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_ca.rb
|
323
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_cert.rb
|
324
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_key.rb
|
325
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_api_version.rb
|
326
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_ca.rb
|
327
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_cert.rb
|
328
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_key.rb
|
329
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password.rb
|
330
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password_file.rb
|
331
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_url.rb
|
332
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/quiet.rb
|
333
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/retry_failed_catalog.rb
|
334
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/safe_to_delete_cached_master_dir.rb
|
335
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/storeconfigs.rb
|
336
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/suppress_absent_file_details.rb
|
337
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/to_from_branch.rb
|
338
|
-
- lib/octocatalog-diff/catalog-diff/cli/options/validate_references.rb
|
339
|
-
- lib/octocatalog-diff/catalog-diff/cli/printer.rb
|
340
285
|
- lib/octocatalog-diff/catalog-diff/differ.rb
|
341
286
|
- lib/octocatalog-diff/catalog-diff/display.rb
|
342
287
|
- lib/octocatalog-diff/catalog-diff/display/json.rb
|
288
|
+
- lib/octocatalog-diff/catalog-diff/display/legacy_json.rb
|
343
289
|
- lib/octocatalog-diff/catalog-diff/display/text.rb
|
344
290
|
- lib/octocatalog-diff/catalog-diff/filter.rb
|
291
|
+
- lib/octocatalog-diff/catalog-diff/filter/absent_file.rb
|
292
|
+
- lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb
|
345
293
|
- lib/octocatalog-diff/catalog-diff/filter/yaml.rb
|
346
294
|
- lib/octocatalog-diff/catalog-util/bootstrap.rb
|
347
295
|
- lib/octocatalog-diff/catalog-util/builddir.rb
|
@@ -361,6 +309,79 @@ files:
|
|
361
309
|
- lib/octocatalog-diff/catalog/noop.rb
|
362
310
|
- lib/octocatalog-diff/catalog/puppetdb.rb
|
363
311
|
- lib/octocatalog-diff/catalog/puppetmaster.rb
|
312
|
+
- lib/octocatalog-diff/cli.rb
|
313
|
+
- lib/octocatalog-diff/cli/diffs.rb
|
314
|
+
- lib/octocatalog-diff/cli/options.rb
|
315
|
+
- lib/octocatalog-diff/cli/options/basedir.rb
|
316
|
+
- lib/octocatalog-diff/cli/options/bootstrap_current.rb
|
317
|
+
- lib/octocatalog-diff/cli/options/bootstrap_environment.rb
|
318
|
+
- lib/octocatalog-diff/cli/options/bootstrap_script.rb
|
319
|
+
- lib/octocatalog-diff/cli/options/bootstrap_then_exit.rb
|
320
|
+
- lib/octocatalog-diff/cli/options/bootstrapped_dirs.rb
|
321
|
+
- lib/octocatalog-diff/cli/options/cached_master_dir.rb
|
322
|
+
- lib/octocatalog-diff/cli/options/catalog_only.rb
|
323
|
+
- lib/octocatalog-diff/cli/options/color.rb
|
324
|
+
- lib/octocatalog-diff/cli/options/command_line.rb
|
325
|
+
- lib/octocatalog-diff/cli/options/compare_file_text.rb
|
326
|
+
- lib/octocatalog-diff/cli/options/create_symlinks.rb
|
327
|
+
- lib/octocatalog-diff/cli/options/debug.rb
|
328
|
+
- lib/octocatalog-diff/cli/options/debug_bootstrap.rb
|
329
|
+
- lib/octocatalog-diff/cli/options/display_datatype_changes.rb
|
330
|
+
- lib/octocatalog-diff/cli/options/display_detail_add.rb
|
331
|
+
- lib/octocatalog-diff/cli/options/display_source_file_line.rb
|
332
|
+
- lib/octocatalog-diff/cli/options/enc.rb
|
333
|
+
- lib/octocatalog-diff/cli/options/enc_override.rb
|
334
|
+
- lib/octocatalog-diff/cli/options/environment.rb
|
335
|
+
- lib/octocatalog-diff/cli/options/existing_catalogs.rb
|
336
|
+
- lib/octocatalog-diff/cli/options/fact_file.rb
|
337
|
+
- lib/octocatalog-diff/cli/options/fact_override.rb
|
338
|
+
- lib/octocatalog-diff/cli/options/facts_terminus.rb
|
339
|
+
- lib/octocatalog-diff/cli/options/filters.rb
|
340
|
+
- lib/octocatalog-diff/cli/options/from_puppetdb.rb
|
341
|
+
- lib/octocatalog-diff/cli/options/header.rb
|
342
|
+
- lib/octocatalog-diff/cli/options/hiera_config.rb
|
343
|
+
- lib/octocatalog-diff/cli/options/hiera_path.rb
|
344
|
+
- lib/octocatalog-diff/cli/options/hiera_path_strip.rb
|
345
|
+
- lib/octocatalog-diff/cli/options/hostname.rb
|
346
|
+
- lib/octocatalog-diff/cli/options/ignore.rb
|
347
|
+
- lib/octocatalog-diff/cli/options/ignore_attr.rb
|
348
|
+
- lib/octocatalog-diff/cli/options/ignore_tags.rb
|
349
|
+
- lib/octocatalog-diff/cli/options/include_tags.rb
|
350
|
+
- lib/octocatalog-diff/cli/options/master_cache_branch.rb
|
351
|
+
- lib/octocatalog-diff/cli/options/output_file.rb
|
352
|
+
- lib/octocatalog-diff/cli/options/output_format.rb
|
353
|
+
- lib/octocatalog-diff/cli/options/parallel.rb
|
354
|
+
- lib/octocatalog-diff/cli/options/parser.rb
|
355
|
+
- lib/octocatalog-diff/cli/options/pass_env_vars.rb
|
356
|
+
- lib/octocatalog-diff/cli/options/pe_enc_ssl_ca.rb
|
357
|
+
- lib/octocatalog-diff/cli/options/pe_enc_ssl_client_cert.rb
|
358
|
+
- lib/octocatalog-diff/cli/options/pe_enc_ssl_client_key.rb
|
359
|
+
- lib/octocatalog-diff/cli/options/pe_enc_token.rb
|
360
|
+
- lib/octocatalog-diff/cli/options/pe_enc_token_file.rb
|
361
|
+
- lib/octocatalog-diff/cli/options/pe_enc_url.rb
|
362
|
+
- lib/octocatalog-diff/cli/options/preserve_environments.rb
|
363
|
+
- lib/octocatalog-diff/cli/options/puppet_binary.rb
|
364
|
+
- lib/octocatalog-diff/cli/options/puppet_master.rb
|
365
|
+
- lib/octocatalog-diff/cli/options/puppet_master_api_version.rb
|
366
|
+
- lib/octocatalog-diff/cli/options/puppet_master_ssl_ca.rb
|
367
|
+
- lib/octocatalog-diff/cli/options/puppet_master_ssl_client_cert.rb
|
368
|
+
- lib/octocatalog-diff/cli/options/puppet_master_ssl_client_key.rb
|
369
|
+
- lib/octocatalog-diff/cli/options/puppetdb_api_version.rb
|
370
|
+
- lib/octocatalog-diff/cli/options/puppetdb_ssl_ca.rb
|
371
|
+
- lib/octocatalog-diff/cli/options/puppetdb_ssl_client_cert.rb
|
372
|
+
- lib/octocatalog-diff/cli/options/puppetdb_ssl_client_key.rb
|
373
|
+
- lib/octocatalog-diff/cli/options/puppetdb_ssl_client_password.rb
|
374
|
+
- lib/octocatalog-diff/cli/options/puppetdb_ssl_client_password_file.rb
|
375
|
+
- lib/octocatalog-diff/cli/options/puppetdb_url.rb
|
376
|
+
- lib/octocatalog-diff/cli/options/quiet.rb
|
377
|
+
- lib/octocatalog-diff/cli/options/retry_failed_catalog.rb
|
378
|
+
- lib/octocatalog-diff/cli/options/safe_to_delete_cached_master_dir.rb
|
379
|
+
- lib/octocatalog-diff/cli/options/storeconfigs.rb
|
380
|
+
- lib/octocatalog-diff/cli/options/suppress_absent_file_details.rb
|
381
|
+
- lib/octocatalog-diff/cli/options/to_from_branch.rb
|
382
|
+
- lib/octocatalog-diff/cli/options/validate_references.rb
|
383
|
+
- lib/octocatalog-diff/cli/printer.rb
|
384
|
+
- lib/octocatalog-diff/errors.rb
|
364
385
|
- lib/octocatalog-diff/external/pson/LICENSE
|
365
386
|
- lib/octocatalog-diff/external/pson/README.md
|
366
387
|
- lib/octocatalog-diff/external/pson/common.rb
|
@@ -373,6 +394,7 @@ files:
|
|
373
394
|
- lib/octocatalog-diff/facts/puppetdb.rb
|
374
395
|
- lib/octocatalog-diff/facts/yaml.rb
|
375
396
|
- lib/octocatalog-diff/puppetdb.rb
|
397
|
+
- lib/octocatalog-diff/util/catalogs.rb
|
376
398
|
- lib/octocatalog-diff/util/colored.rb
|
377
399
|
- lib/octocatalog-diff/util/httparty.rb
|
378
400
|
- lib/octocatalog-diff/util/parallel.rb
|
@@ -1,211 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'cli/catalogs'
|
4
|
-
require_relative 'cli/diffs'
|
5
|
-
require_relative 'cli/options'
|
6
|
-
require_relative 'cli/printer'
|
7
|
-
require_relative '../catalog-util/cached_master_directory'
|
8
|
-
require_relative 'cli/helpers/fact_override'
|
9
|
-
require_relative '../version'
|
10
|
-
|
11
|
-
require 'logger'
|
12
|
-
require 'socket'
|
13
|
-
|
14
|
-
module OctocatalogDiff
|
15
|
-
module CatalogDiff
|
16
|
-
# This is the CLI for catalog-diff. It's responsible for parsing the command line
|
17
|
-
# arguments and then handing off to appropriate methods to perform the catalog-diff.
|
18
|
-
class Cli
|
19
|
-
# Version number
|
20
|
-
VERSION = OctocatalogDiff::Version::VERSION
|
21
|
-
|
22
|
-
# Exit codes
|
23
|
-
EXITCODE_SUCCESS_NO_DIFFS = 0
|
24
|
-
EXITCODE_FAILURE = 1
|
25
|
-
EXITCODE_SUCCESS_WITH_DIFFS = 2
|
26
|
-
|
27
|
-
# The default type+title+attribute to ignore in catalog-diff.
|
28
|
-
DEFAULT_IGNORES = [
|
29
|
-
{ type: 'Class' } # Don't care about classes themselves, only what they actually do!
|
30
|
-
].freeze
|
31
|
-
|
32
|
-
# The default options.
|
33
|
-
DEFAULT_OPTIONS = {
|
34
|
-
from_env: 'origin/master',
|
35
|
-
to_env: '.',
|
36
|
-
colors: true,
|
37
|
-
debug: false,
|
38
|
-
quiet: false,
|
39
|
-
format: :color_text,
|
40
|
-
display_source_file_line: false,
|
41
|
-
compare_file_text: true,
|
42
|
-
display_datatype_changes: true,
|
43
|
-
parallel: true,
|
44
|
-
suppress_absent_file_details: true,
|
45
|
-
hiera_path: 'hieradata'
|
46
|
-
}.freeze
|
47
|
-
|
48
|
-
# This method is the one to call externally. It is possible to specify alternate
|
49
|
-
# command line arguments, for testing.
|
50
|
-
# @param argv [Array] Use specified arguments (defaults to ARGV)
|
51
|
-
# @param logger [Logger] Logger object
|
52
|
-
# @param opts [Hash] Additional options
|
53
|
-
# @return [Fixnum] Exit code: 0=no diffs, 1=something went wrong, 2=worked but there are diffs
|
54
|
-
def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {})
|
55
|
-
# Save a copy of argv to print out later in debugging
|
56
|
-
argv_save = argv.dup
|
57
|
-
|
58
|
-
# Are there additional ARGV to munge, e.g. that have been supplied in the options from a
|
59
|
-
# configuration file?
|
60
|
-
if opts.key?(:additional_argv)
|
61
|
-
raise ArgumentError, ':additional_argv must be array!' unless opts[:additional_argv].is_a?(Array)
|
62
|
-
argv.concat opts[:additional_argv]
|
63
|
-
end
|
64
|
-
|
65
|
-
# Parse command line
|
66
|
-
options = parse_opts(argv)
|
67
|
-
|
68
|
-
# Additional options from hard-coded specified options. These are only processed if
|
69
|
-
# there are not already values defined from command line options.
|
70
|
-
# Note: do NOT use 'options[k] ||= v' here because if the value of options[k] is boolean(false)
|
71
|
-
# it will then be overridden. Whereas the intent is to define values only for those keys that don't exist.
|
72
|
-
opts.each { |k, v| options[k] = v unless options.key?(k) }
|
73
|
-
veto_options = %w(enc header hiera_config include_tags)
|
74
|
-
veto_options.each { |x| options.delete(x.to_sym) if options["no_#{x}".to_sym] }
|
75
|
-
options[:ignore].concat opts.fetch(:additional_ignores, [])
|
76
|
-
|
77
|
-
# Incorporate default options where needed.
|
78
|
-
# Note: do NOT use 'options[k] ||= v' here because if the value of options[k] is boolean(false)
|
79
|
-
# it will then be overridden. Whereas the intent is to define values only for those keys that don't exist.
|
80
|
-
DEFAULT_OPTIONS.each { |k, v| options[k] = v unless options.key?(k) }
|
81
|
-
veto_with_none_options = %w(hiera_path hiera_path_strip)
|
82
|
-
veto_with_none_options.each { |x| options.delete(x.to_sym) if options[x.to_sym] == :none }
|
83
|
-
|
84
|
-
# Fact overrides come in here - 'options' is modified
|
85
|
-
setup_fact_overrides(options)
|
86
|
-
|
87
|
-
# Configure the logger and logger.debug initial information
|
88
|
-
# 'logger' is modified and used
|
89
|
-
setup_logger(logger, options, argv_save)
|
90
|
-
|
91
|
-
# --catalog-only is a special case that compiles the catalog for the "to" branch
|
92
|
-
# and then exits, without doing any 'diff' whatsoever. Support that option.
|
93
|
-
return catalog_only(logger, options) if options[:catalog_only]
|
94
|
-
|
95
|
-
# Set up the cached master directory - maintain it, adjust options if needed. However, if we
|
96
|
-
# are getting the 'from' catalog from PuppetDB, then don't do this.
|
97
|
-
unless options[:cached_master_dir].nil? || options[:from_puppetdb]
|
98
|
-
OctocatalogDiff::CatalogUtil::CachedMasterDirectory.run(options, logger)
|
99
|
-
end
|
100
|
-
|
101
|
-
# bootstrap_then_exit is a special case that only prepares directories and does not
|
102
|
-
# depend on facts. This happens within the 'catalogs' object, since bootstrapping and
|
103
|
-
# preparing catalogs are tightly coupled operations. However this does not actually
|
104
|
-
# build catalogs.
|
105
|
-
catalogs_obj = OctocatalogDiff::CatalogDiff::Cli::Catalogs.new(options, logger)
|
106
|
-
return bootstrap_then_exit(logger, catalogs_obj) if options[:bootstrap_then_exit]
|
107
|
-
|
108
|
-
# Compile catalogs
|
109
|
-
catalogs = catalogs_obj.catalogs
|
110
|
-
logger.info "Catalogs compiled for #{options[:node]}"
|
111
|
-
|
112
|
-
# Cache catalogs if master caching is enabled. If a catalog is being read from the cached master
|
113
|
-
# directory, set the compilation directory attribute, so that the "compilation directory dependent"
|
114
|
-
# suppressor will still work.
|
115
|
-
%w(from to).each do |x|
|
116
|
-
next unless options["#{x}_env".to_sym] == options.fetch(:master_cache_branch, 'origin/master')
|
117
|
-
next if options[:cached_master_dir].nil?
|
118
|
-
catalogs[x.to_sym].compilation_dir = options["#{x}_catalog_compilation_dir".to_sym] || options[:cached_master_dir]
|
119
|
-
rc = OctocatalogDiff::CatalogUtil::CachedMasterDirectory.save_catalog_in_cache_dir(
|
120
|
-
options[:node],
|
121
|
-
options[:cached_master_dir],
|
122
|
-
catalogs[x.to_sym]
|
123
|
-
)
|
124
|
-
logger.debug "Cached master catalog for #{options[:node]}" if rc
|
125
|
-
end
|
126
|
-
|
127
|
-
# Compute diffs
|
128
|
-
diffs_obj = OctocatalogDiff::CatalogDiff::Cli::Diffs.new(options, logger)
|
129
|
-
diffs = diffs_obj.diffs(catalogs)
|
130
|
-
logger.info "Diffs computed for #{options[:node]}"
|
131
|
-
|
132
|
-
# Display diffs
|
133
|
-
logger.info 'No differences' if diffs.empty?
|
134
|
-
printer_obj = OctocatalogDiff::CatalogDiff::Cli::Printer.new(options, logger)
|
135
|
-
printer_obj.printer(diffs, catalogs[:from].compilation_dir, catalogs[:to].compilation_dir)
|
136
|
-
|
137
|
-
# Return the diff object if requested (generally for testing) or otherwise return exit code
|
138
|
-
return diffs if opts[:RETURN_DIFFS]
|
139
|
-
diffs.any? ? EXITCODE_SUCCESS_WITH_DIFFS : EXITCODE_SUCCESS_NO_DIFFS
|
140
|
-
end
|
141
|
-
|
142
|
-
# Parse command line options with 'optparse'. Returns a hash with the parsed arguments.
|
143
|
-
# @param argv [Array] Command line arguments (MUST be specified)
|
144
|
-
# @return [Hash] Options
|
145
|
-
def self.parse_opts(argv)
|
146
|
-
options = { ignore: DEFAULT_IGNORES.dup }
|
147
|
-
Options.parse_options(argv, options)
|
148
|
-
end
|
149
|
-
|
150
|
-
# Fact overrides come in here
|
151
|
-
def self.setup_fact_overrides(options)
|
152
|
-
[:from_fact_override, :to_fact_override].each do |key|
|
153
|
-
o = options["#{key}_in".to_sym]
|
154
|
-
next unless o.is_a?(Array)
|
155
|
-
next unless o.any?
|
156
|
-
options[key] ||= []
|
157
|
-
options[key].concat o.map { |x| OctocatalogDiff::CatalogDiff::Cli::Helpers::FactOverride.new(x) }
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
# Helper method: Configure and setup logger
|
162
|
-
def self.setup_logger(logger, options, argv_save)
|
163
|
-
# Configure the logger
|
164
|
-
logger.level = Logger::INFO
|
165
|
-
logger.level = Logger::DEBUG if options[:debug]
|
166
|
-
logger.level = Logger::ERROR if options[:quiet]
|
167
|
-
|
168
|
-
# Some debugging information up front
|
169
|
-
version_display = ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION'] || VERSION
|
170
|
-
logger.debug "Running octocatalog-diff #{version_display} with ruby #{RUBY_VERSION}"
|
171
|
-
logger.debug "Command line arguments: #{argv_save.inspect}"
|
172
|
-
logger.debug "Running on host #{Socket.gethostname} (#{RUBY_PLATFORM})"
|
173
|
-
end
|
174
|
-
|
175
|
-
# Compile the catalog only
|
176
|
-
def self.catalog_only(logger, options)
|
177
|
-
# Indicate where we are
|
178
|
-
logger.debug "Compiling catalog --catalog-only for #{options[:node]}"
|
179
|
-
|
180
|
-
# Compile catalog
|
181
|
-
catalog_opts = options.merge(
|
182
|
-
from_catalog: '-', # Prevents a compile
|
183
|
-
to_catalog: nil, # Forces a compile
|
184
|
-
)
|
185
|
-
cat_obj = OctocatalogDiff::CatalogDiff::Cli::Catalogs.new(catalog_opts, logger)
|
186
|
-
catalogs = cat_obj.catalogs
|
187
|
-
|
188
|
-
# If the catalog compilation failed, an exception would have been thrown. So if
|
189
|
-
# we get here, the catalog succeeded. Dump the catalog to the appropriate place
|
190
|
-
# and exit successfully.
|
191
|
-
if options[:output_file]
|
192
|
-
File.open(options[:output_file], 'w') { |f| f.write(catalogs[:to].catalog_json) }
|
193
|
-
logger.info "Wrote catalog to #{options[:output_file]}"
|
194
|
-
else
|
195
|
-
puts catalogs[:to].catalog_json
|
196
|
-
end
|
197
|
-
return [catalogs[:from], catalogs[:to]] if options[:RETURN_DIFFS] # For integration testing
|
198
|
-
EXITCODE_SUCCESS_NO_DIFFS
|
199
|
-
end
|
200
|
-
|
201
|
-
# --bootstrap-then-exit command
|
202
|
-
def self.bootstrap_then_exit(logger, catalogs_obj)
|
203
|
-
catalogs_obj.bootstrap_then_exit
|
204
|
-
return EXITCODE_SUCCESS_NO_DIFFS
|
205
|
-
rescue OctocatalogDiff::CatalogDiff::Cli::Catalogs::BootstrapError => exc
|
206
|
-
logger.fatal("--bootstrap-then-exit error: bootstrap failed (#{exc})")
|
207
|
-
return EXITCODE_FAILURE
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
@@ -1,246 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require 'open3'
|
5
|
-
require 'yaml'
|
6
|
-
require_relative '../../catalog-util/bootstrap' # For BootstrapError
|
7
|
-
require_relative '../../catalog'
|
8
|
-
require_relative '../../util/parallel'
|
9
|
-
|
10
|
-
module OctocatalogDiff
|
11
|
-
module CatalogDiff
|
12
|
-
class Cli
|
13
|
-
# Helper class to construct catalogs, performing all necessary steps such as
|
14
|
-
# bootstrapping directories, installing facts, and running puppet.
|
15
|
-
class Catalogs
|
16
|
-
# Exceptions that are anticipated can be caught in the calling class and tested for explicitly in spec tests.
|
17
|
-
class BootstrapError < RuntimeError; end
|
18
|
-
class CatalogError < RuntimeError; end
|
19
|
-
|
20
|
-
# Constructor
|
21
|
-
# @param options [Hash] Options
|
22
|
-
# @param logger [Logger] Logger object
|
23
|
-
def initialize(options, logger)
|
24
|
-
@options = options
|
25
|
-
@logger = logger
|
26
|
-
@catalogs = nil
|
27
|
-
raise '@logger must not be nil' if @logger.nil?
|
28
|
-
end
|
29
|
-
|
30
|
-
# Compile catalogs. This handles building both the old and new catalog (in parallel) and returns
|
31
|
-
# only when both catalogs have been built.
|
32
|
-
# @return [Hash] { :from => [OctocatalogDiff::Catalog], :to => [OctocatalogDiff::Catalog] }
|
33
|
-
def catalogs
|
34
|
-
@catalogs ||= build_catalog_parallelizer
|
35
|
-
end
|
36
|
-
|
37
|
-
# Handles the "bootstrap then exit" option, which bootstraps directories but
|
38
|
-
# exits without compiling catalogs.
|
39
|
-
def bootstrap_then_exit
|
40
|
-
@logger.debug('Begin bootstrap_then_exit')
|
41
|
-
OctocatalogDiff::CatalogUtil::Bootstrap.bootstrap_directory_parallelizer(@options, @logger)
|
42
|
-
@logger.debug('Success bootstrap_then_exit')
|
43
|
-
@logger.info('Successfully completed --bootstrap-then-exit action')
|
44
|
-
rescue OctocatalogDiff::CatalogUtil::Bootstrap::BootstrapError => exc
|
45
|
-
@logger.error("Bootstrap exception: #{exc}")
|
46
|
-
raise BootstrapError, "Bootstrap exception: #{exc}"
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
# Parallelizes bootstrapping of directories and building catalogs.
|
52
|
-
# @return [Hash] { :from => OctocatalogDiff::Catalog, :to => OctocatalogDiff::Catalog }
|
53
|
-
def build_catalog_parallelizer
|
54
|
-
# Construct parallel tasks. The array supplied to OctocatalogDiff::Util::Parallel is the task portion
|
55
|
-
# of each of the tuples in catalog_tasks.
|
56
|
-
catalog_tasks = build_catalog_tasks
|
57
|
-
|
58
|
-
# Update any tasks for catalogs that do not need to be compiled. This is the case when --catalog-only
|
59
|
-
# is specified and only one catalog is to be built. This will change matching catalog tasks to the 'noop' type.
|
60
|
-
catalog_tasks.map! do |x|
|
61
|
-
if @options["#{x[0]}_catalog".to_sym] == '-'
|
62
|
-
x[1].args[:backend] = :noop
|
63
|
-
elsif @options["#{x[0]}_catalog".to_sym].is_a?(String)
|
64
|
-
x[1].args[:json] = File.read(@options["#{x[0]}_catalog".to_sym])
|
65
|
-
x[1].args[:backend] = :json
|
66
|
-
end
|
67
|
-
x
|
68
|
-
end
|
69
|
-
|
70
|
-
# Initialize the objects for each parallel task. Initializing the object is very fast and does not actually
|
71
|
-
# build the catalog.
|
72
|
-
result = {}
|
73
|
-
catalog_tasks.each do |x|
|
74
|
-
result[x[0]] = OctocatalogDiff::Catalog.new(x[1].args)
|
75
|
-
@logger.debug "Initialized #{result[x[0]].builder} for #{x[0]}-catalog"
|
76
|
-
end
|
77
|
-
|
78
|
-
# Disable --compare-file-text if either (or both) of the chosen backends do not support it
|
79
|
-
if @options.fetch(:compare_file_text, false)
|
80
|
-
result.each do |_key, val|
|
81
|
-
next unless val.convert_file_resources == false
|
82
|
-
@logger.debug "Disabling --compare-file-text; not supported by #{val.builder}"
|
83
|
-
@options[:compare_file_text] = false
|
84
|
-
catalog_tasks.map! do |x|
|
85
|
-
x[1].args[:compare_file_text] = false
|
86
|
-
x
|
87
|
-
end
|
88
|
-
break
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# Inject the starting object into the catalog tasks
|
93
|
-
catalog_tasks.map! do |x|
|
94
|
-
x[1].args[:object] = result[x[0]]
|
95
|
-
x
|
96
|
-
end
|
97
|
-
|
98
|
-
# Execute the parallelized catalog builds
|
99
|
-
passed_catalog_tasks = catalog_tasks.map { |x| x[1] }
|
100
|
-
parallel_catalogs = OctocatalogDiff::Util::Parallel.run_tasks(passed_catalog_tasks, @logger, @options[:parallel])
|
101
|
-
|
102
|
-
# If the catalogs array is empty at this point, there is an unexpected size mismatch. This should
|
103
|
-
# never happen, but test for it anyway.
|
104
|
-
unless parallel_catalogs.size == catalog_tasks.size
|
105
|
-
# :nocov:
|
106
|
-
raise "BUG: mismatch catalog_result (#{parallel_catalogs.size} vs #{catalog_tasks.size})"
|
107
|
-
# :nocov:
|
108
|
-
end
|
109
|
-
|
110
|
-
# Construct result hash. Will eventually be in the format
|
111
|
-
# { :from => OctocatalogDiff::Catalog, :to => OctocatalogDiff::Catalog }
|
112
|
-
|
113
|
-
# Analyze the results from parallel run.
|
114
|
-
catalog_tasks.each do |x|
|
115
|
-
# The `parallel_catalog_obj` is a OctocatalogDiff::Util::Parallel::Result. Get the first element from
|
116
|
-
# the parallel_catalogs output.
|
117
|
-
parallel_catalog_obj = parallel_catalogs.shift
|
118
|
-
|
119
|
-
# Add the result to the 'result' hash
|
120
|
-
add_parallel_result(result, parallel_catalog_obj, x)
|
121
|
-
end
|
122
|
-
|
123
|
-
# Things have succeeded if the :to and :from catalogs exist at this point. If not, things have
|
124
|
-
# failed, and an exception should be thrown.
|
125
|
-
raise CatalogError, 'One or more catalogs failed to compile.' unless result.key?(:to) && result.key?(:from)
|
126
|
-
result
|
127
|
-
end
|
128
|
-
|
129
|
-
# Get catalog compilation tasks.
|
130
|
-
# @return [Array<[key, task]>] Catalog tasks
|
131
|
-
def build_catalog_tasks
|
132
|
-
[:from, :to].map do |key|
|
133
|
-
# These are arguments to OctocatalogDiff::Util::Parallel::Task. In most cases the arguments
|
134
|
-
# of OctocatalogDiff::Util::Parallel::Task are taken directly from options, but there are
|
135
|
-
# some defaults or otherwise-named options that must be set here.
|
136
|
-
args = @options.merge(
|
137
|
-
tag: key.to_s,
|
138
|
-
branch: @options["#{key}_env".to_sym],
|
139
|
-
bootstrapped_dir: @options["bootstrapped_#{key}_dir".to_sym],
|
140
|
-
basedir: @options[:basedir],
|
141
|
-
compare_file_text: @options.fetch(:compare_file_text, true),
|
142
|
-
retry_failed_catalog: @options.fetch(:retry_failed_catalog, 0),
|
143
|
-
parser: @options["parser_#{key}".to_sym]
|
144
|
-
)
|
145
|
-
|
146
|
-
# If any options are in the form of 'to_SOMETHING' or 'from_SOMETHING', this sets the option to
|
147
|
-
# 'SOMETHING' for the catalog if it matches this key. For example, when compiling the 'to' catalog
|
148
|
-
# when an option of :to_some_arg => 'foo', this sets :some_arg => foo, and deletes :to_some_arg and
|
149
|
-
# :from_some_arg.
|
150
|
-
@options.keys.select { |x| x.to_s =~ /^(to|from)_/ }.each do |opt_key|
|
151
|
-
args[opt_key.to_s.sub(/^(to|from)_/, '').to_sym] = @options[opt_key] if opt_key.to_s.start_with?(key.to_s)
|
152
|
-
args.delete(opt_key)
|
153
|
-
end
|
154
|
-
|
155
|
-
# The task is a OctocatalogDiff::Util::Parallel::Task object that contains the method to execute,
|
156
|
-
# validator method, text description, and arguments to provide when calling the method.
|
157
|
-
task = OctocatalogDiff::Util::Parallel::Task.new(
|
158
|
-
method: method(:build_catalog),
|
159
|
-
validator: method(:catalog_validator),
|
160
|
-
validator_args: { task: key },
|
161
|
-
description: "build_catalog for #{@options["#{key}_env".to_sym]}",
|
162
|
-
args: args
|
163
|
-
)
|
164
|
-
|
165
|
-
# The format of `catalog_tasks` will be a tuple, where the first element is the key
|
166
|
-
# (e.g. :to or :from) and the second element is the OctocatalogDiff::Util::Parallel::Task object.
|
167
|
-
[key, task]
|
168
|
-
end.compact
|
169
|
-
end
|
170
|
-
|
171
|
-
# Given a result from the 'parallel' run and a corresponding (key,task) tuple, add valid
|
172
|
-
# catalogs to the 'result' hash and throw errors for invalid catalogs.
|
173
|
-
# @param result [Hash] Result hash for build_catalog_parallelizer (may be modified)
|
174
|
-
# @param parallel_catalog_obj [OctocatalogDiff::Util::Parallel::Result] Parallel catalog result
|
175
|
-
# @param key_task_tuple [Array<key, task>] Key, task tuple
|
176
|
-
def add_parallel_result(result, parallel_catalog_obj, key_task_tuple)
|
177
|
-
# Expand the tuple into variables
|
178
|
-
key, task = key_task_tuple
|
179
|
-
|
180
|
-
# For reporting purposes, get the branch name.
|
181
|
-
branch = task.args[:branch]
|
182
|
-
|
183
|
-
# Check the result of the parallel run on this object.
|
184
|
-
if parallel_catalog_obj.status.nil?
|
185
|
-
# The compile was killed because another task failed.
|
186
|
-
@logger.warn "Catalog compile for #{branch} was aborted due to another failure"
|
187
|
-
|
188
|
-
elsif parallel_catalog_obj.output.is_a?(OctocatalogDiff::Catalog)
|
189
|
-
# The result is a catalog, but we do not know if it was successfully compiled
|
190
|
-
# until we test the validity.
|
191
|
-
catalog = parallel_catalog_obj.output
|
192
|
-
if catalog.valid?
|
193
|
-
# The catalog was successfully compiled.
|
194
|
-
result[key] = parallel_catalog_obj.output
|
195
|
-
else
|
196
|
-
# The catalog failed, but a catalog object was returned so that better error reporting
|
197
|
-
# can take place. In this error reporting, we will replace 'Error:' with '[Puppet Error]'
|
198
|
-
# and remove the compilation directory (which is a tmpdir) to reveal only the relative
|
199
|
-
# path to the files involved.
|
200
|
-
dir = catalog.compilation_dir || ''
|
201
|
-
dir_regex = Regexp.new(Regexp.escape(dir) + '/environments/[^/]+/')
|
202
|
-
error_display = catalog.error_message.split("\n").map do |line|
|
203
|
-
line.sub(/^Error:/, '[Puppet Error]').gsub(dir_regex, '')
|
204
|
-
end.join("\n")
|
205
|
-
raise CatalogError, "Catalog for #{branch} failed to compile due to errors:\n#{error_display}"
|
206
|
-
end
|
207
|
-
else
|
208
|
-
# Something unhandled went wrong, and an exception was thrown. Reveal a generic message.
|
209
|
-
msg = parallel_catalog_obj.exception.message
|
210
|
-
message = "Catalog for '#{key}' (#{branch}) failed to compile with #{parallel_catalog_obj.exception.class}: #{msg}"
|
211
|
-
message += "\n" + parallel_catalog_obj.exception.backtrace.map { |x| " #{x}" }.join("\n") if @options[:debug]
|
212
|
-
raise CatalogError, message
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# Performs the steps necessary to build a catalog.
|
217
|
-
# @param opts [Hash] Options hash
|
218
|
-
# @return [Hash] { :rc => exit code, :catalog => Catalog as JSON string }
|
219
|
-
def build_catalog(opts, logger = @logger)
|
220
|
-
logger.debug("Setting up Puppet catalog build for #{opts[:branch]}")
|
221
|
-
catalog = opts[:object]
|
222
|
-
logger.debug("Catalog for #{opts[:branch]} will be built with #{catalog.builder}")
|
223
|
-
time_start = Time.now
|
224
|
-
catalog.build(logger)
|
225
|
-
time_it_took = Time.now - time_start
|
226
|
-
retries_str = " retries = #{catalog.retries}" if catalog.retries.is_a?(Fixnum)
|
227
|
-
time_str = "in #{time_it_took} seconds#{retries_str}"
|
228
|
-
status_str = catalog.valid? ? 'successfully built' : 'failed'
|
229
|
-
logger.debug "Catalog for #{opts[:branch]} #{status_str} with #{catalog.builder} #{time_str}"
|
230
|
-
catalog
|
231
|
-
end
|
232
|
-
|
233
|
-
# Validate a catalog in the parallel execution
|
234
|
-
# @param catalog [OctocatalogDiff::Catalog] Catalog object
|
235
|
-
# @param logger [Logger] Logger object (presently unused)
|
236
|
-
# @param args [Hash] Additional arguments set specifically for validator
|
237
|
-
# @return [Boolean] true if catalog is valid, false otherwise
|
238
|
-
def catalog_validator(catalog = nil, _logger = @logger, args = {})
|
239
|
-
return false unless catalog.is_a?(OctocatalogDiff::Catalog)
|
240
|
-
catalog.validate_references if args[:task] == :to
|
241
|
-
catalog.valid?
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|