octocatalog-diff 1.2.0 → 1.3.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/doc/CHANGELOG.md +12 -0
- data/doc/optionsref.md +539 -3
- data/lib/octocatalog-diff/catalog-diff/differ.rb +3 -1
- data/lib/octocatalog-diff/catalog-diff/display/text.rb +4 -13
- data/lib/octocatalog-diff/catalog-util/fileresources.rb +1 -0
- data/lib/octocatalog-diff/cli/options.rb +30 -8
- data/lib/octocatalog-diff/cli/options/fact_file.rb +30 -13
- data/lib/octocatalog-diff/cli/options/save_catalog.rb +34 -0
- data/lib/octocatalog-diff/facts.rb +12 -4
- data/lib/octocatalog-diff/facts/yaml.rb +12 -2
- data/lib/octocatalog-diff/util/catalogs.rb +5 -0
- data/lib/octocatalog-diff/util/util.rb +48 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67cc184b1ece4c4982d29bd714a674cc118f649d
|
4
|
+
data.tar.gz: b2f18b550db7705f998cc2facab1525ded036399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a22fdaab74c77e8e195bb7de464330f441444da4abe76729d98ea74a2c2958cc299ec030644f7804e99972ae162272b191062857d19fe47409877a05222ce2f3
|
7
|
+
data.tar.gz: 08f100f0cec01c5821154341ee4bf4c3abe2d2b1350a41391716a605b966cf11948179a3f0b5452ddfd8782a937841bc6e9d53962e6178f3559027ed2239ce4d
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/doc/CHANGELOG.md
CHANGED
@@ -8,6 +8,18 @@
|
|
8
8
|
</tr>
|
9
9
|
</thead><tbody>
|
10
10
|
<tr valign=top>
|
11
|
+
<td>1.3.0</td>
|
12
|
+
<td>2017-06-09</td>
|
13
|
+
<td>
|
14
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/121">#121</a>: (Enhancement) Allow different fact files for the "from" and "to" catalogs</li>
|
15
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/129">#129</a>: (Enhancement) Allow YAML facts in "facter -y" format</li>
|
16
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/126">#126</a>: (Enhancement) Allow saving of catalogs when catalog diffing</li>
|
17
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/122">#122</a>: (Bug) Handle File resources with no parameters</li>
|
18
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/125">#125</a>: (Bug) Fix error when parameters with integer values are added</li>
|
19
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/131">#131</a>: (Bug) Do not use override fact file for both catalogs when only `--to-fact-file` is specified</li>
|
20
|
+
</td>
|
21
|
+
</tr>
|
22
|
+
<tr valign=top>
|
11
23
|
<td>1.2.0</td>
|
12
24
|
<td>2017-05-18</td>
|
13
25
|
<td>
|
data/doc/optionsref.md
CHANGED
@@ -33,7 +33,12 @@ Usage: octocatalog-diff [command line options]
|
|
33
33
|
--ignore "Type1[Title1],Type2[Title2],..."
|
34
34
|
More resources to ignore in format type[title]
|
35
35
|
--[no-]include-tags Include changes to tags in the diff output
|
36
|
-
--fact-file
|
36
|
+
--fact-file STRING Override fact globally
|
37
|
+
--to-fact-file STRING Override fact for the to branch
|
38
|
+
--from-fact-file STRING Override fact for the from branch
|
39
|
+
--save-catalog STRING Save intermediate catalogs into files globally
|
40
|
+
--to-save-catalog STRING Save intermediate catalogs into files for the to branch
|
41
|
+
--from-save-catalog STRING Save intermediate catalogs into files for the from branch
|
37
42
|
--cached-master-dir PATH Cache bootstrapped origin/master at this path
|
38
43
|
--master-cache-branch BRANCH Branch to cache
|
39
44
|
--safe-to-delete-cached-master-dir PATH
|
@@ -305,6 +310,18 @@ diffing activity. The catalog will be printed to STDOUT or written to the output
|
|
305
310
|
</td>
|
306
311
|
</tr>
|
307
312
|
|
313
|
+
<tr>
|
314
|
+
<td valign=top>
|
315
|
+
<pre><code>--command-line STRING1[,STRING2[,...]]</code></pre>
|
316
|
+
</td>
|
317
|
+
<td valign=top>
|
318
|
+
Command line arguments globally
|
319
|
+
</td>
|
320
|
+
<td valign=top>
|
321
|
+
Provide additional command line flags to set when running Puppet to compile catalogs. (<a href="../lib/octocatalog-diff/cli/options/command_line.rb">command_line.rb</a>)
|
322
|
+
</td>
|
323
|
+
</tr>
|
324
|
+
|
308
325
|
<tr>
|
309
326
|
<td valign=top>
|
310
327
|
<pre><code>--compare-file-text
|
@@ -321,6 +338,19 @@ what is most often desired. (<a href="../lib/octocatalog-diff/cli/options/compar
|
|
321
338
|
</td>
|
322
339
|
</tr>
|
323
340
|
|
341
|
+
<tr>
|
342
|
+
<td valign=top>
|
343
|
+
<pre><code>--create-symlinks STRING1[,STRING2[,...]]</code></pre>
|
344
|
+
</td>
|
345
|
+
<td valign=top>
|
346
|
+
Symlinks to create globally
|
347
|
+
</td>
|
348
|
+
<td valign=top>
|
349
|
+
Specify which directories from the base should be symlinked into the temporary compilation
|
350
|
+
environment. This is useful only in conjunction with `--preserve-environments`. (<a href="../lib/octocatalog-diff/cli/options/create_symlinks.rb">create_symlinks.rb</a>)
|
351
|
+
</td>
|
352
|
+
</tr>
|
353
|
+
|
324
354
|
<tr>
|
325
355
|
<td valign=top>
|
326
356
|
<pre><code>-d
|
@@ -417,16 +447,57 @@ difference. (<a href="../lib/octocatalog-diff/cli/options/display_datatype_chang
|
|
417
447
|
|
418
448
|
<tr>
|
419
449
|
<td valign=top>
|
420
|
-
<pre><code>--
|
450
|
+
<pre><code>--enc-override STRING1[,STRING2[,...]]</code></pre>
|
421
451
|
</td>
|
422
452
|
<td valign=top>
|
423
|
-
|
453
|
+
Override parameter from ENC globally
|
454
|
+
</td>
|
455
|
+
<td valign=top>
|
456
|
+
Allow override of ENC parameters on the command line. ENC parameter overrides can be supplied for the 'to' or 'from' catalog,
|
457
|
+
or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
458
|
+
by permitting a data type specification as well. For parameters nested in hashes, use `::` as the delimiter. (<a href="../lib/octocatalog-diff/cli/options/enc_override.rb">enc_override.rb</a>)
|
459
|
+
</td>
|
460
|
+
</tr>
|
461
|
+
|
462
|
+
<tr>
|
463
|
+
<td valign=top>
|
464
|
+
<pre><code>--environment STRING</code></pre>
|
465
|
+
</td>
|
466
|
+
<td valign=top>
|
467
|
+
Environment for catalog compilation globally
|
468
|
+
</td>
|
469
|
+
<td valign=top>
|
470
|
+
Specify the environment to use when compiling the catalog. This is useful only in conjunction
|
471
|
+
with `--preserve-environments`. (<a href="../lib/octocatalog-diff/cli/options/environment.rb">environment.rb</a>)
|
472
|
+
</td>
|
473
|
+
</tr>
|
474
|
+
|
475
|
+
<tr>
|
476
|
+
<td valign=top>
|
477
|
+
<pre><code>--fact-file STRING</code></pre>
|
478
|
+
</td>
|
479
|
+
<td valign=top>
|
480
|
+
Override fact globally
|
424
481
|
</td>
|
425
482
|
<td valign=top>
|
426
483
|
Allow an existing fact file to be provided, to avoid pulling facts from PuppetDB. (<a href="../lib/octocatalog-diff/cli/options/fact_file.rb">fact_file.rb</a>)
|
427
484
|
</td>
|
428
485
|
</tr>
|
429
486
|
|
487
|
+
<tr>
|
488
|
+
<td valign=top>
|
489
|
+
<pre><code>--fact-override STRING1[,STRING2[,...]]</code></pre>
|
490
|
+
</td>
|
491
|
+
<td valign=top>
|
492
|
+
Override fact globally
|
493
|
+
</td>
|
494
|
+
<td valign=top>
|
495
|
+
Allow override of facts on the command line. Fact overrides can be supplied for the 'to' or 'from' catalog,
|
496
|
+
or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
497
|
+
by permitting a data type specification as well. (<a href="../lib/octocatalog-diff/cli/options/fact_override.rb">fact_override.rb</a>)
|
498
|
+
</td>
|
499
|
+
</tr>
|
500
|
+
|
430
501
|
<tr>
|
431
502
|
<td valign=top>
|
432
503
|
<pre><code>--facts-terminus STRING</code></pre>
|
@@ -482,6 +553,31 @@ These files must exist and be in Puppet catalog format. (<a href="../lib/octocat
|
|
482
553
|
</td>
|
483
554
|
</tr>
|
484
555
|
|
556
|
+
<tr>
|
557
|
+
<td valign=top>
|
558
|
+
<pre><code>--from-command-line STRING1[,STRING2[,...]]</code></pre>
|
559
|
+
</td>
|
560
|
+
<td valign=top>
|
561
|
+
Command line arguments for the from branch
|
562
|
+
</td>
|
563
|
+
<td valign=top>
|
564
|
+
Provide additional command line flags to set when running Puppet to compile catalogs. (<a href="../lib/octocatalog-diff/cli/options/command_line.rb">command_line.rb</a>)
|
565
|
+
</td>
|
566
|
+
</tr>
|
567
|
+
|
568
|
+
<tr>
|
569
|
+
<td valign=top>
|
570
|
+
<pre><code>--from-create-symlinks STRING1[,STRING2[,...]]</code></pre>
|
571
|
+
</td>
|
572
|
+
<td valign=top>
|
573
|
+
Symlinks to create for the from branch
|
574
|
+
</td>
|
575
|
+
<td valign=top>
|
576
|
+
Specify which directories from the base should be symlinked into the temporary compilation
|
577
|
+
environment. This is useful only in conjunction with `--preserve-environments`. (<a href="../lib/octocatalog-diff/cli/options/create_symlinks.rb">create_symlinks.rb</a>)
|
578
|
+
</td>
|
579
|
+
</tr>
|
580
|
+
|
485
581
|
<tr>
|
486
582
|
<td valign=top>
|
487
583
|
<pre><code>--from-enc PATH</code></pre>
|
@@ -494,6 +590,150 @@ These files must exist and be in Puppet catalog format. (<a href="../lib/octocat
|
|
494
590
|
</td>
|
495
591
|
</tr>
|
496
592
|
|
593
|
+
<tr>
|
594
|
+
<td valign=top>
|
595
|
+
<pre><code>--from-enc-override STRING1[,STRING2[,...]]</code></pre>
|
596
|
+
</td>
|
597
|
+
<td valign=top>
|
598
|
+
Override parameter from ENC for the from branch
|
599
|
+
</td>
|
600
|
+
<td valign=top>
|
601
|
+
Allow override of ENC parameters on the command line. ENC parameter overrides can be supplied for the 'to' or 'from' catalog,
|
602
|
+
or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
603
|
+
by permitting a data type specification as well. For parameters nested in hashes, use `::` as the delimiter. (<a href="../lib/octocatalog-diff/cli/options/enc_override.rb">enc_override.rb</a>)
|
604
|
+
</td>
|
605
|
+
</tr>
|
606
|
+
|
607
|
+
<tr>
|
608
|
+
<td valign=top>
|
609
|
+
<pre><code>--from-environment STRING</code></pre>
|
610
|
+
</td>
|
611
|
+
<td valign=top>
|
612
|
+
Environment for catalog compilation for the from branch
|
613
|
+
</td>
|
614
|
+
<td valign=top>
|
615
|
+
Specify the environment to use when compiling the catalog. This is useful only in conjunction
|
616
|
+
with `--preserve-environments`. (<a href="../lib/octocatalog-diff/cli/options/environment.rb">environment.rb</a>)
|
617
|
+
</td>
|
618
|
+
</tr>
|
619
|
+
|
620
|
+
<tr>
|
621
|
+
<td valign=top>
|
622
|
+
<pre><code>--from-fact-file STRING</code></pre>
|
623
|
+
</td>
|
624
|
+
<td valign=top>
|
625
|
+
Override fact for the from branch
|
626
|
+
</td>
|
627
|
+
<td valign=top>
|
628
|
+
Allow an existing fact file to be provided, to avoid pulling facts from PuppetDB. (<a href="../lib/octocatalog-diff/cli/options/fact_file.rb">fact_file.rb</a>)
|
629
|
+
</td>
|
630
|
+
</tr>
|
631
|
+
|
632
|
+
<tr>
|
633
|
+
<td valign=top>
|
634
|
+
<pre><code>--from-fact-override STRING1[,STRING2[,...]]</code></pre>
|
635
|
+
</td>
|
636
|
+
<td valign=top>
|
637
|
+
Override fact for the from branch
|
638
|
+
</td>
|
639
|
+
<td valign=top>
|
640
|
+
Allow override of facts on the command line. Fact overrides can be supplied for the 'to' or 'from' catalog,
|
641
|
+
or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
642
|
+
by permitting a data type specification as well. (<a href="../lib/octocatalog-diff/cli/options/fact_override.rb">fact_override.rb</a>)
|
643
|
+
</td>
|
644
|
+
</tr>
|
645
|
+
|
646
|
+
<tr>
|
647
|
+
<td valign=top>
|
648
|
+
<pre><code>--from-puppet-binary STRING</code></pre>
|
649
|
+
</td>
|
650
|
+
<td valign=top>
|
651
|
+
Full path to puppet binary for the from branch
|
652
|
+
</td>
|
653
|
+
<td valign=top>
|
654
|
+
Set --puppet-binary, --to-puppet-binary, --from-puppet-binary (<a href="../lib/octocatalog-diff/cli/options/puppet_binary.rb">puppet_binary.rb</a>)
|
655
|
+
</td>
|
656
|
+
</tr>
|
657
|
+
|
658
|
+
<tr>
|
659
|
+
<td valign=top>
|
660
|
+
<pre><code>--from-puppet-master STRING</code></pre>
|
661
|
+
</td>
|
662
|
+
<td valign=top>
|
663
|
+
Hostname or Hostname:PortNumber for Puppet Master for the from branch
|
664
|
+
</td>
|
665
|
+
<td valign=top>
|
666
|
+
Specify the hostname, or hostname:port, for the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master.rb">puppet_master.rb</a>)
|
667
|
+
</td>
|
668
|
+
</tr>
|
669
|
+
|
670
|
+
<tr>
|
671
|
+
<td valign=top>
|
672
|
+
<pre><code>--from-puppet-master-api-version STRING</code></pre>
|
673
|
+
</td>
|
674
|
+
<td valign=top>
|
675
|
+
Puppet Master API version (2 for Puppet 3.x, 3 for Puppet 4.x) for the from branch
|
676
|
+
</td>
|
677
|
+
<td valign=top>
|
678
|
+
Specify the API version to use for the Puppet Master. This makes it possible to authenticate to a
|
679
|
+
version 3.x PuppetMaster by specifying the API version as 2, or for a version 4.x PuppetMaster by
|
680
|
+
specifying API version as 3. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_api_version.rb">puppet_master_api_version.rb</a>)
|
681
|
+
</td>
|
682
|
+
</tr>
|
683
|
+
|
684
|
+
<tr>
|
685
|
+
<td valign=top>
|
686
|
+
<pre><code>--from-puppet-master-ssl-ca STRING</code></pre>
|
687
|
+
</td>
|
688
|
+
<td valign=top>
|
689
|
+
Full path to CA certificate that signed the Puppet Master certificate for the from branch
|
690
|
+
</td>
|
691
|
+
<td valign=top>
|
692
|
+
Specify the CA certificate for Puppet Master. If specified, this will enable SSL verification
|
693
|
+
that the certificate being presented has been signed by this CA, and that the common name
|
694
|
+
matches the name you are using to connecting. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_ca.rb">puppet_master_ssl_ca.rb</a>)
|
695
|
+
</td>
|
696
|
+
</tr>
|
697
|
+
|
698
|
+
<tr>
|
699
|
+
<td valign=top>
|
700
|
+
<pre><code>--from-puppet-master-ssl-client-cert STRING</code></pre>
|
701
|
+
</td>
|
702
|
+
<td valign=top>
|
703
|
+
Full path to certificate file for SSL client auth to Puppet Master for the from branch
|
704
|
+
</td>
|
705
|
+
<td valign=top>
|
706
|
+
Specify the SSL client certificate for Puppet Master. This makes it possible to authenticate with a
|
707
|
+
client certificate keypair to the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_client_cert.rb">puppet_master_ssl_client_cert.rb</a>)
|
708
|
+
</td>
|
709
|
+
</tr>
|
710
|
+
|
711
|
+
<tr>
|
712
|
+
<td valign=top>
|
713
|
+
<pre><code>--from-puppet-master-ssl-client-key STRING</code></pre>
|
714
|
+
</td>
|
715
|
+
<td valign=top>
|
716
|
+
Full path to key file for SSL client auth to Puppet Master for the from branch
|
717
|
+
</td>
|
718
|
+
<td valign=top>
|
719
|
+
Specify the SSL client key for Puppet Master. This makes it possible to authenticate with a
|
720
|
+
client certificate keypair to the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_client_key.rb">puppet_master_ssl_client_key.rb</a>)
|
721
|
+
</td>
|
722
|
+
</tr>
|
723
|
+
|
724
|
+
<tr>
|
725
|
+
<td valign=top>
|
726
|
+
<pre><code>--from-puppet-master-timeout STRING</code></pre>
|
727
|
+
</td>
|
728
|
+
<td valign=top>
|
729
|
+
Puppet Master catalog retrieval timeout in seconds for the from branch
|
730
|
+
</td>
|
731
|
+
<td valign=top>
|
732
|
+
Specify a timeout for retrieving a catalog from a Puppet master / Puppet server.
|
733
|
+
This timeout is specified in seconds. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_timeout.rb">puppet_master_timeout.rb</a>)
|
734
|
+
</td>
|
735
|
+
</tr>
|
736
|
+
|
497
737
|
<tr>
|
498
738
|
<td valign=top>
|
499
739
|
<pre><code>--from-puppetdb
|
@@ -507,6 +747,18 @@ These files must exist and be in Puppet catalog format. (<a href="../lib/octocat
|
|
507
747
|
</td>
|
508
748
|
</tr>
|
509
749
|
|
750
|
+
<tr>
|
751
|
+
<td valign=top>
|
752
|
+
<pre><code>--from-save-catalog STRING</code></pre>
|
753
|
+
</td>
|
754
|
+
<td valign=top>
|
755
|
+
Save intermediate catalogs into files for the from branch
|
756
|
+
</td>
|
757
|
+
<td valign=top>
|
758
|
+
Allow catalogs to be saved to a file before they are diff'd. (<a href="../lib/octocatalog-diff/cli/options/save_catalog.rb">save_catalog.rb</a>)
|
759
|
+
</td>
|
760
|
+
</tr>
|
761
|
+
|
510
762
|
<tr>
|
511
763
|
<td valign=top>
|
512
764
|
<pre><code>--header STRING</code></pre>
|
@@ -908,6 +1160,97 @@ to work correctly. (<a href="../lib/octocatalog-diff/cli/options/preserve_enviro
|
|
908
1160
|
</td>
|
909
1161
|
</tr>
|
910
1162
|
|
1163
|
+
<tr>
|
1164
|
+
<td valign=top>
|
1165
|
+
<pre><code>--puppet-binary STRING</code></pre>
|
1166
|
+
</td>
|
1167
|
+
<td valign=top>
|
1168
|
+
Full path to puppet binary globally
|
1169
|
+
</td>
|
1170
|
+
<td valign=top>
|
1171
|
+
Set --puppet-binary, --to-puppet-binary, --from-puppet-binary (<a href="../lib/octocatalog-diff/cli/options/puppet_binary.rb">puppet_binary.rb</a>)
|
1172
|
+
</td>
|
1173
|
+
</tr>
|
1174
|
+
|
1175
|
+
<tr>
|
1176
|
+
<td valign=top>
|
1177
|
+
<pre><code>--puppet-master STRING</code></pre>
|
1178
|
+
</td>
|
1179
|
+
<td valign=top>
|
1180
|
+
Hostname or Hostname:PortNumber for Puppet Master globally
|
1181
|
+
</td>
|
1182
|
+
<td valign=top>
|
1183
|
+
Specify the hostname, or hostname:port, for the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master.rb">puppet_master.rb</a>)
|
1184
|
+
</td>
|
1185
|
+
</tr>
|
1186
|
+
|
1187
|
+
<tr>
|
1188
|
+
<td valign=top>
|
1189
|
+
<pre><code>--puppet-master-api-version STRING</code></pre>
|
1190
|
+
</td>
|
1191
|
+
<td valign=top>
|
1192
|
+
Puppet Master API version (2 for Puppet 3.x, 3 for Puppet 4.x) globally
|
1193
|
+
</td>
|
1194
|
+
<td valign=top>
|
1195
|
+
Specify the API version to use for the Puppet Master. This makes it possible to authenticate to a
|
1196
|
+
version 3.x PuppetMaster by specifying the API version as 2, or for a version 4.x PuppetMaster by
|
1197
|
+
specifying API version as 3. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_api_version.rb">puppet_master_api_version.rb</a>)
|
1198
|
+
</td>
|
1199
|
+
</tr>
|
1200
|
+
|
1201
|
+
<tr>
|
1202
|
+
<td valign=top>
|
1203
|
+
<pre><code>--puppet-master-ssl-ca STRING</code></pre>
|
1204
|
+
</td>
|
1205
|
+
<td valign=top>
|
1206
|
+
Full path to CA certificate that signed the Puppet Master certificate globally
|
1207
|
+
</td>
|
1208
|
+
<td valign=top>
|
1209
|
+
Specify the CA certificate for Puppet Master. If specified, this will enable SSL verification
|
1210
|
+
that the certificate being presented has been signed by this CA, and that the common name
|
1211
|
+
matches the name you are using to connecting. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_ca.rb">puppet_master_ssl_ca.rb</a>)
|
1212
|
+
</td>
|
1213
|
+
</tr>
|
1214
|
+
|
1215
|
+
<tr>
|
1216
|
+
<td valign=top>
|
1217
|
+
<pre><code>--puppet-master-ssl-client-cert STRING</code></pre>
|
1218
|
+
</td>
|
1219
|
+
<td valign=top>
|
1220
|
+
Full path to certificate file for SSL client auth to Puppet Master globally
|
1221
|
+
</td>
|
1222
|
+
<td valign=top>
|
1223
|
+
Specify the SSL client certificate for Puppet Master. This makes it possible to authenticate with a
|
1224
|
+
client certificate keypair to the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_client_cert.rb">puppet_master_ssl_client_cert.rb</a>)
|
1225
|
+
</td>
|
1226
|
+
</tr>
|
1227
|
+
|
1228
|
+
<tr>
|
1229
|
+
<td valign=top>
|
1230
|
+
<pre><code>--puppet-master-ssl-client-key STRING</code></pre>
|
1231
|
+
</td>
|
1232
|
+
<td valign=top>
|
1233
|
+
Full path to key file for SSL client auth to Puppet Master globally
|
1234
|
+
</td>
|
1235
|
+
<td valign=top>
|
1236
|
+
Specify the SSL client key for Puppet Master. This makes it possible to authenticate with a
|
1237
|
+
client certificate keypair to the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_client_key.rb">puppet_master_ssl_client_key.rb</a>)
|
1238
|
+
</td>
|
1239
|
+
</tr>
|
1240
|
+
|
1241
|
+
<tr>
|
1242
|
+
<td valign=top>
|
1243
|
+
<pre><code>--puppet-master-timeout STRING</code></pre>
|
1244
|
+
</td>
|
1245
|
+
<td valign=top>
|
1246
|
+
Puppet Master catalog retrieval timeout in seconds globally
|
1247
|
+
</td>
|
1248
|
+
<td valign=top>
|
1249
|
+
Specify a timeout for retrieving a catalog from a Puppet master / Puppet server.
|
1250
|
+
This timeout is specified in seconds. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_timeout.rb">puppet_master_timeout.rb</a>)
|
1251
|
+
</td>
|
1252
|
+
</tr>
|
1253
|
+
|
911
1254
|
<tr>
|
912
1255
|
<td valign=top>
|
913
1256
|
<pre><code>--puppetdb-api-version N</code></pre>
|
@@ -1040,6 +1383,18 @@ cached directory). (<a href="../lib/octocatalog-diff/cli/options/safe_to_delete_
|
|
1040
1383
|
</td>
|
1041
1384
|
</tr>
|
1042
1385
|
|
1386
|
+
<tr>
|
1387
|
+
<td valign=top>
|
1388
|
+
<pre><code>--save-catalog STRING</code></pre>
|
1389
|
+
</td>
|
1390
|
+
<td valign=top>
|
1391
|
+
Save intermediate catalogs into files globally
|
1392
|
+
</td>
|
1393
|
+
<td valign=top>
|
1394
|
+
Allow catalogs to be saved to a file before they are diff'd. (<a href="../lib/octocatalog-diff/cli/options/save_catalog.rb">save_catalog.rb</a>)
|
1395
|
+
</td>
|
1396
|
+
</tr>
|
1397
|
+
|
1043
1398
|
<tr>
|
1044
1399
|
<td valign=top>
|
1045
1400
|
<pre><code>--storeconfigs
|
@@ -1096,6 +1451,31 @@ These files must exist and be in Puppet catalog format. (<a href="../lib/octocat
|
|
1096
1451
|
</td>
|
1097
1452
|
</tr>
|
1098
1453
|
|
1454
|
+
<tr>
|
1455
|
+
<td valign=top>
|
1456
|
+
<pre><code>--to-command-line STRING1[,STRING2[,...]]</code></pre>
|
1457
|
+
</td>
|
1458
|
+
<td valign=top>
|
1459
|
+
Command line arguments for the to branch
|
1460
|
+
</td>
|
1461
|
+
<td valign=top>
|
1462
|
+
Provide additional command line flags to set when running Puppet to compile catalogs. (<a href="../lib/octocatalog-diff/cli/options/command_line.rb">command_line.rb</a>)
|
1463
|
+
</td>
|
1464
|
+
</tr>
|
1465
|
+
|
1466
|
+
<tr>
|
1467
|
+
<td valign=top>
|
1468
|
+
<pre><code>--to-create-symlinks STRING1[,STRING2[,...]]</code></pre>
|
1469
|
+
</td>
|
1470
|
+
<td valign=top>
|
1471
|
+
Symlinks to create for the to branch
|
1472
|
+
</td>
|
1473
|
+
<td valign=top>
|
1474
|
+
Specify which directories from the base should be symlinked into the temporary compilation
|
1475
|
+
environment. This is useful only in conjunction with `--preserve-environments`. (<a href="../lib/octocatalog-diff/cli/options/create_symlinks.rb">create_symlinks.rb</a>)
|
1476
|
+
</td>
|
1477
|
+
</tr>
|
1478
|
+
|
1099
1479
|
<tr>
|
1100
1480
|
<td valign=top>
|
1101
1481
|
<pre><code>--to-enc PATH</code></pre>
|
@@ -1108,6 +1488,162 @@ These files must exist and be in Puppet catalog format. (<a href="../lib/octocat
|
|
1108
1488
|
</td>
|
1109
1489
|
</tr>
|
1110
1490
|
|
1491
|
+
<tr>
|
1492
|
+
<td valign=top>
|
1493
|
+
<pre><code>--to-enc-override STRING1[,STRING2[,...]]</code></pre>
|
1494
|
+
</td>
|
1495
|
+
<td valign=top>
|
1496
|
+
Override parameter from ENC for the to branch
|
1497
|
+
</td>
|
1498
|
+
<td valign=top>
|
1499
|
+
Allow override of ENC parameters on the command line. ENC parameter overrides can be supplied for the 'to' or 'from' catalog,
|
1500
|
+
or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
1501
|
+
by permitting a data type specification as well. For parameters nested in hashes, use `::` as the delimiter. (<a href="../lib/octocatalog-diff/cli/options/enc_override.rb">enc_override.rb</a>)
|
1502
|
+
</td>
|
1503
|
+
</tr>
|
1504
|
+
|
1505
|
+
<tr>
|
1506
|
+
<td valign=top>
|
1507
|
+
<pre><code>--to-environment STRING</code></pre>
|
1508
|
+
</td>
|
1509
|
+
<td valign=top>
|
1510
|
+
Environment for catalog compilation for the to branch
|
1511
|
+
</td>
|
1512
|
+
<td valign=top>
|
1513
|
+
Specify the environment to use when compiling the catalog. This is useful only in conjunction
|
1514
|
+
with `--preserve-environments`. (<a href="../lib/octocatalog-diff/cli/options/environment.rb">environment.rb</a>)
|
1515
|
+
</td>
|
1516
|
+
</tr>
|
1517
|
+
|
1518
|
+
<tr>
|
1519
|
+
<td valign=top>
|
1520
|
+
<pre><code>--to-fact-file STRING</code></pre>
|
1521
|
+
</td>
|
1522
|
+
<td valign=top>
|
1523
|
+
Override fact for the to branch
|
1524
|
+
</td>
|
1525
|
+
<td valign=top>
|
1526
|
+
Allow an existing fact file to be provided, to avoid pulling facts from PuppetDB. (<a href="../lib/octocatalog-diff/cli/options/fact_file.rb">fact_file.rb</a>)
|
1527
|
+
</td>
|
1528
|
+
</tr>
|
1529
|
+
|
1530
|
+
<tr>
|
1531
|
+
<td valign=top>
|
1532
|
+
<pre><code>--to-fact-override STRING1[,STRING2[,...]]</code></pre>
|
1533
|
+
</td>
|
1534
|
+
<td valign=top>
|
1535
|
+
Override fact for the to branch
|
1536
|
+
</td>
|
1537
|
+
<td valign=top>
|
1538
|
+
Allow override of facts on the command line. Fact overrides can be supplied for the 'to' or 'from' catalog,
|
1539
|
+
or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
1540
|
+
by permitting a data type specification as well. (<a href="../lib/octocatalog-diff/cli/options/fact_override.rb">fact_override.rb</a>)
|
1541
|
+
</td>
|
1542
|
+
</tr>
|
1543
|
+
|
1544
|
+
<tr>
|
1545
|
+
<td valign=top>
|
1546
|
+
<pre><code>--to-puppet-binary STRING</code></pre>
|
1547
|
+
</td>
|
1548
|
+
<td valign=top>
|
1549
|
+
Full path to puppet binary for the to branch
|
1550
|
+
</td>
|
1551
|
+
<td valign=top>
|
1552
|
+
Set --puppet-binary, --to-puppet-binary, --from-puppet-binary (<a href="../lib/octocatalog-diff/cli/options/puppet_binary.rb">puppet_binary.rb</a>)
|
1553
|
+
</td>
|
1554
|
+
</tr>
|
1555
|
+
|
1556
|
+
<tr>
|
1557
|
+
<td valign=top>
|
1558
|
+
<pre><code>--to-puppet-master STRING</code></pre>
|
1559
|
+
</td>
|
1560
|
+
<td valign=top>
|
1561
|
+
Hostname or Hostname:PortNumber for Puppet Master for the to branch
|
1562
|
+
</td>
|
1563
|
+
<td valign=top>
|
1564
|
+
Specify the hostname, or hostname:port, for the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master.rb">puppet_master.rb</a>)
|
1565
|
+
</td>
|
1566
|
+
</tr>
|
1567
|
+
|
1568
|
+
<tr>
|
1569
|
+
<td valign=top>
|
1570
|
+
<pre><code>--to-puppet-master-api-version STRING</code></pre>
|
1571
|
+
</td>
|
1572
|
+
<td valign=top>
|
1573
|
+
Puppet Master API version (2 for Puppet 3.x, 3 for Puppet 4.x) for the to branch
|
1574
|
+
</td>
|
1575
|
+
<td valign=top>
|
1576
|
+
Specify the API version to use for the Puppet Master. This makes it possible to authenticate to a
|
1577
|
+
version 3.x PuppetMaster by specifying the API version as 2, or for a version 4.x PuppetMaster by
|
1578
|
+
specifying API version as 3. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_api_version.rb">puppet_master_api_version.rb</a>)
|
1579
|
+
</td>
|
1580
|
+
</tr>
|
1581
|
+
|
1582
|
+
<tr>
|
1583
|
+
<td valign=top>
|
1584
|
+
<pre><code>--to-puppet-master-ssl-ca STRING</code></pre>
|
1585
|
+
</td>
|
1586
|
+
<td valign=top>
|
1587
|
+
Full path to CA certificate that signed the Puppet Master certificate for the to branch
|
1588
|
+
</td>
|
1589
|
+
<td valign=top>
|
1590
|
+
Specify the CA certificate for Puppet Master. If specified, this will enable SSL verification
|
1591
|
+
that the certificate being presented has been signed by this CA, and that the common name
|
1592
|
+
matches the name you are using to connecting. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_ca.rb">puppet_master_ssl_ca.rb</a>)
|
1593
|
+
</td>
|
1594
|
+
</tr>
|
1595
|
+
|
1596
|
+
<tr>
|
1597
|
+
<td valign=top>
|
1598
|
+
<pre><code>--to-puppet-master-ssl-client-cert STRING</code></pre>
|
1599
|
+
</td>
|
1600
|
+
<td valign=top>
|
1601
|
+
Full path to certificate file for SSL client auth to Puppet Master for the to branch
|
1602
|
+
</td>
|
1603
|
+
<td valign=top>
|
1604
|
+
Specify the SSL client certificate for Puppet Master. This makes it possible to authenticate with a
|
1605
|
+
client certificate keypair to the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_client_cert.rb">puppet_master_ssl_client_cert.rb</a>)
|
1606
|
+
</td>
|
1607
|
+
</tr>
|
1608
|
+
|
1609
|
+
<tr>
|
1610
|
+
<td valign=top>
|
1611
|
+
<pre><code>--to-puppet-master-ssl-client-key STRING</code></pre>
|
1612
|
+
</td>
|
1613
|
+
<td valign=top>
|
1614
|
+
Full path to key file for SSL client auth to Puppet Master for the to branch
|
1615
|
+
</td>
|
1616
|
+
<td valign=top>
|
1617
|
+
Specify the SSL client key for Puppet Master. This makes it possible to authenticate with a
|
1618
|
+
client certificate keypair to the Puppet Master. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_ssl_client_key.rb">puppet_master_ssl_client_key.rb</a>)
|
1619
|
+
</td>
|
1620
|
+
</tr>
|
1621
|
+
|
1622
|
+
<tr>
|
1623
|
+
<td valign=top>
|
1624
|
+
<pre><code>--to-puppet-master-timeout STRING</code></pre>
|
1625
|
+
</td>
|
1626
|
+
<td valign=top>
|
1627
|
+
Puppet Master catalog retrieval timeout in seconds for the to branch
|
1628
|
+
</td>
|
1629
|
+
<td valign=top>
|
1630
|
+
Specify a timeout for retrieving a catalog from a Puppet master / Puppet server.
|
1631
|
+
This timeout is specified in seconds. (<a href="../lib/octocatalog-diff/cli/options/puppet_master_timeout.rb">puppet_master_timeout.rb</a>)
|
1632
|
+
</td>
|
1633
|
+
</tr>
|
1634
|
+
|
1635
|
+
<tr>
|
1636
|
+
<td valign=top>
|
1637
|
+
<pre><code>--to-save-catalog STRING</code></pre>
|
1638
|
+
</td>
|
1639
|
+
<td valign=top>
|
1640
|
+
Save intermediate catalogs into files for the to branch
|
1641
|
+
</td>
|
1642
|
+
<td valign=top>
|
1643
|
+
Allow catalogs to be saved to a file before they are diff'd. (<a href="../lib/octocatalog-diff/cli/options/save_catalog.rb">save_catalog.rb</a>)
|
1644
|
+
</td>
|
1645
|
+
</tr>
|
1646
|
+
|
1111
1647
|
<tr>
|
1112
1648
|
<td valign=top>
|
1113
1649
|
<pre><code>--truncate-details
|
@@ -8,6 +8,7 @@ require 'stringio'
|
|
8
8
|
|
9
9
|
require_relative '../catalog'
|
10
10
|
require_relative '../errors'
|
11
|
+
require_relative '../util/util'
|
11
12
|
require_relative 'filter'
|
12
13
|
|
13
14
|
module OctocatalogDiff
|
@@ -530,7 +531,8 @@ module OctocatalogDiff
|
|
530
531
|
|
531
532
|
# Added a new key that points to some kind of data structure that we know how
|
532
533
|
# to handle.
|
533
|
-
|
534
|
+
classes = [String, Integer, Float, TrueClass, FalseClass, Array, Hash]
|
535
|
+
if obj[1] =~ /^(.+)\f([^\f]+)$/ && OctocatalogDiff::Util::Util.object_is_any_of?(obj[2], classes)
|
534
536
|
hashdiff_add_remove.add(obj[1])
|
535
537
|
next
|
536
538
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../display'
|
4
|
-
require_relative '../../util/colored
|
4
|
+
require_relative '../../util/colored'
|
5
|
+
require_relative '../../util/util'
|
5
6
|
|
6
7
|
require 'diffy'
|
7
8
|
require 'json'
|
@@ -447,16 +448,6 @@ module OctocatalogDiff
|
|
447
448
|
class_name
|
448
449
|
end
|
449
450
|
|
450
|
-
# Utility Method!
|
451
|
-
# `is_a?(class)` only allows one method, but this uses an array
|
452
|
-
# @param object [?] Object to consider
|
453
|
-
# @param classes [Array] Classes to determine if object is a member of
|
454
|
-
# @return [Boolean] True if object is_a any of the classes, false otherwise
|
455
|
-
def self.object_is_any_of?(object, classes)
|
456
|
-
classes.each { |clazz| return true if object.is_a? clazz }
|
457
|
-
false
|
458
|
-
end
|
459
|
-
|
460
451
|
# Utility Method!
|
461
452
|
# Given an arbitrary object, convert it into a string for use by 'diffy'.
|
462
453
|
# This basically exists so we can do something prettier than just calling .inspect or .to_s
|
@@ -464,9 +455,9 @@ module OctocatalogDiff
|
|
464
455
|
# @param obj [?] Object to be stringified
|
465
456
|
# @return [String] String representation of object for diffy
|
466
457
|
def self.stringify_for_diffy(obj)
|
467
|
-
return JSON.pretty_generate(obj) if object_is_any_of?(obj, [Hash, Array])
|
458
|
+
return JSON.pretty_generate(obj) if OctocatalogDiff::Util::Util.object_is_any_of?(obj, [Hash, Array])
|
468
459
|
return '""' if obj.is_a?(String) && obj == ''
|
469
|
-
return obj if object_is_any_of?(obj, [String, Fixnum, Integer, Float])
|
460
|
+
return obj if OctocatalogDiff::Util::Util.object_is_any_of?(obj, [String, Fixnum, Integer, Float])
|
470
461
|
"#{class_name_for_diffy(obj.class)}: #{obj.inspect}"
|
471
462
|
end
|
472
463
|
|
@@ -122,6 +122,7 @@ module OctocatalogDiff
|
|
122
122
|
# @return [Boolean] True of resource is convertible, false if not
|
123
123
|
def self.resource_convertible?(resource)
|
124
124
|
return true if resource['type'] == 'File' && \
|
125
|
+
!resource['parameters'].nil? && \
|
125
126
|
resource['parameters'].key?('source') && \
|
126
127
|
!resource['parameters'].key?('content') && \
|
127
128
|
resource['parameters']['source'] =~ %r{^puppet:///modules/([^/]+)/(.+)}
|
@@ -13,6 +13,9 @@ module OctocatalogDiff
|
|
13
13
|
# The usage banner.
|
14
14
|
BANNER = 'Usage: catalog-diff -n <hostname> [-f <from environment>] [-t <to environment>]'.freeze
|
15
15
|
|
16
|
+
# An error class specifically for passing information to the document build task.
|
17
|
+
class DocBuildError < RuntimeError; end
|
18
|
+
|
16
19
|
# List of classes
|
17
20
|
def self.classes
|
18
21
|
@classes ||= []
|
@@ -85,6 +88,7 @@ module OctocatalogDiff
|
|
85
88
|
# option will populate any of the 'to' and 'from' variants that are missing.
|
86
89
|
# @param :datatype [?] Expected data type
|
87
90
|
def self.option_globally_or_per_branch(opts = {})
|
91
|
+
opts[:filename] = caller[0].split(':').first
|
88
92
|
datatype = opts.fetch(:datatype, '')
|
89
93
|
return option_globally_or_per_branch_string(opts) if datatype.is_a?(String)
|
90
94
|
return option_globally_or_per_branch_array(opts) if datatype.is_a?(Array)
|
@@ -108,18 +112,21 @@ module OctocatalogDiff
|
|
108
112
|
from_option = "from_#{option_name}".to_sym
|
109
113
|
to_option = "to_#{option_name}".to_sym
|
110
114
|
parser.on("--#{flag}", "#{desc} globally") do |x|
|
111
|
-
validate_option(opts
|
115
|
+
validate_option(opts, x)
|
112
116
|
translated = translate_option(opts[:translator], x)
|
113
117
|
options[to_option] ||= translated
|
114
118
|
options[from_option] ||= translated
|
119
|
+
post_process(opts[:post_process], options)
|
115
120
|
end
|
116
121
|
parser.on("--to-#{flag}", "#{desc} for the to branch") do |x|
|
117
|
-
validate_option(opts
|
122
|
+
validate_option(opts, x)
|
118
123
|
options[to_option] = translate_option(opts[:translator], x)
|
124
|
+
post_process(opts[:post_process], options)
|
119
125
|
end
|
120
126
|
parser.on("--from-#{flag}", "#{desc} for the from branch") do |x|
|
121
|
-
validate_option(opts
|
127
|
+
validate_option(opts, x)
|
122
128
|
options[from_option] = translate_option(opts[:translator], x)
|
129
|
+
post_process(opts[:post_process], options)
|
123
130
|
end
|
124
131
|
end
|
125
132
|
|
@@ -140,7 +147,7 @@ module OctocatalogDiff
|
|
140
147
|
from_option = "from_#{option_name}".to_sym
|
141
148
|
to_option = "to_#{option_name}".to_sym
|
142
149
|
parser.on("--#{flag}", Array, "#{desc} globally") do |x|
|
143
|
-
validate_option(opts
|
150
|
+
validate_option(opts, x)
|
144
151
|
translated = translate_option(opts[:translator], x)
|
145
152
|
options[to_option] ||= []
|
146
153
|
options[to_option].concat translated
|
@@ -148,12 +155,12 @@ module OctocatalogDiff
|
|
148
155
|
options[from_option].concat translated
|
149
156
|
end
|
150
157
|
parser.on("--to-#{flag}", Array, "#{desc} for the to branch") do |x|
|
151
|
-
validate_option(opts
|
158
|
+
validate_option(opts, x)
|
152
159
|
options[to_option] ||= []
|
153
160
|
options[to_option].concat translate_option(opts[:translator], x)
|
154
161
|
end
|
155
162
|
parser.on("--from-#{flag}", Array, "#{desc} for the from branch") do |x|
|
156
|
-
validate_option(opts
|
163
|
+
validate_option(opts, x)
|
157
164
|
options[from_option] ||= []
|
158
165
|
options[from_option].concat translate_option(opts[:translator], x)
|
159
166
|
end
|
@@ -162,9 +169,15 @@ module OctocatalogDiff
|
|
162
169
|
# If a validator was provided, run the validator on the supplied value. The validator is expected to
|
163
170
|
# throw an error if there is a problem. Note that the validator runs *before* the translator if both
|
164
171
|
# a validator and translator are supplied.
|
165
|
-
# @param
|
172
|
+
# @param opts [Hash] Options hash
|
166
173
|
# @param value [?] Value to validate (typically a String but can really be anything)
|
167
|
-
def self.validate_option(
|
174
|
+
def self.validate_option(opts, value)
|
175
|
+
# Special value to help build documentation automatically, since the source file location
|
176
|
+
# for `option_globally_or_per_branch` is always this file.
|
177
|
+
raise DocBuildError, opts[:filename] if value == :DOC_BUILD_FILENAME
|
178
|
+
|
179
|
+
validator = opts[:validator]
|
180
|
+
return true unless validator
|
168
181
|
validator.call(value)
|
169
182
|
end
|
170
183
|
|
@@ -178,6 +191,15 @@ module OctocatalogDiff
|
|
178
191
|
return value if translator.nil?
|
179
192
|
translator.call(value)
|
180
193
|
end
|
194
|
+
|
195
|
+
# Code that can run after a translation and operate upon all options. This returns nothing but may
|
196
|
+
# modify options that were input.
|
197
|
+
# @param processor [Code] Processor function
|
198
|
+
# @param options [Hash] Options hash
|
199
|
+
def self.post_process(processor, options)
|
200
|
+
return if processor.nil?
|
201
|
+
processor.call(options)
|
202
|
+
end
|
181
203
|
end
|
182
204
|
end
|
183
205
|
end
|
@@ -7,19 +7,36 @@ OctocatalogDiff::Cli::Options::Option.newoption(:fact_file) do
|
|
7
7
|
has_weight 150
|
8
8
|
|
9
9
|
def parse(parser, options)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
|
11
|
+
parser: parser,
|
12
|
+
options: options,
|
13
|
+
cli_name: 'fact-file',
|
14
|
+
option_name: 'facts',
|
15
|
+
desc: 'Override fact',
|
16
|
+
datatype: '',
|
17
|
+
validator: ->(fact_file) { File.file?(fact_file) && (fact_file =~ /\.ya?ml$/ || fact_file =~ /\.json$/) },
|
18
|
+
translator: lambda do |fact_file|
|
19
|
+
local_opts = { fact_file_string: File.read(fact_file) }
|
20
|
+
if fact_file =~ /\.ya?ml$/
|
21
|
+
OctocatalogDiff::Facts.new(local_opts.merge(backend: :yaml))
|
22
|
+
elsif fact_file =~ /\.json$/
|
23
|
+
OctocatalogDiff::Facts.new(local_opts.merge(backend: :json))
|
24
|
+
else
|
25
|
+
# :nocov:
|
26
|
+
# Believed to be a bug condition since the validator should kick this out before it ever gets here.
|
27
|
+
raise ArgumentError, 'I do not know how to parse the provided fact file. Needs .yaml or .json extension.'
|
28
|
+
# :nocov:
|
29
|
+
end
|
30
|
+
end,
|
31
|
+
post_process: lambda do |opts|
|
32
|
+
unless options[:node]
|
33
|
+
%w[to_facts from_facts facts].each do |opt|
|
34
|
+
next unless opts[opt.to_sym] && opts[opt.to_sym].node
|
35
|
+
opts[:node] = opts[opt.to_sym].node
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
20
39
|
end
|
21
|
-
|
22
|
-
options[:node] ||= facts.facts['name']
|
23
|
-
end
|
40
|
+
)
|
24
41
|
end
|
25
42
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Allow catalogs to be saved to a file before they are diff'd.
|
4
|
+
# @param parser [OptionParser object] The OptionParser argument
|
5
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
6
|
+
OctocatalogDiff::Cli::Options::Option.newoption(:save_catalog) do
|
7
|
+
has_weight 155
|
8
|
+
|
9
|
+
def parse(parser, options)
|
10
|
+
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
|
11
|
+
parser: parser,
|
12
|
+
options: options,
|
13
|
+
cli_name: 'save-catalog',
|
14
|
+
option_name: 'save_catalog',
|
15
|
+
desc: 'Save intermediate catalogs into files',
|
16
|
+
datatype: '',
|
17
|
+
validator: lambda do |catalog_file|
|
18
|
+
target_dir = File.dirname(catalog_file)
|
19
|
+
unless File.directory?(target_dir)
|
20
|
+
raise Errno::ENOENT, "Cannot save catalog to #{catalog_file} because parent directory does not exist"
|
21
|
+
end
|
22
|
+
if File.exist?(catalog_file) && !File.file?(catalog_file)
|
23
|
+
raise ArgumentError, "Cannot overwrite #{catalog_file} which is not a file"
|
24
|
+
end
|
25
|
+
true
|
26
|
+
end,
|
27
|
+
post_process: lambda do |opts|
|
28
|
+
if opts[:to_save_catalog] && opts[:to_save_catalog] == opts[:from_save_catalog]
|
29
|
+
raise ArgumentError, 'Cannot use the same file for --to-save-catalog and --from-save-catalog'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
@@ -4,6 +4,7 @@ require_relative 'errors'
|
|
4
4
|
require_relative 'facts/json'
|
5
5
|
require_relative 'facts/yaml'
|
6
6
|
require_relative 'facts/puppetdb'
|
7
|
+
require_relative 'util/util'
|
7
8
|
require_relative 'external/pson/pure'
|
8
9
|
|
9
10
|
module OctocatalogDiff
|
@@ -19,8 +20,7 @@ module OctocatalogDiff
|
|
19
20
|
@timestamp = false
|
20
21
|
@options = options.dup
|
21
22
|
if facts
|
22
|
-
@facts =
|
23
|
-
facts.each { |k, v| @facts[k] = v.dup }
|
23
|
+
@facts = OctocatalogDiff::Util::Util.deep_dup(facts)
|
24
24
|
else
|
25
25
|
case options[:backend]
|
26
26
|
when :json
|
@@ -32,8 +32,7 @@ module OctocatalogDiff
|
|
32
32
|
else
|
33
33
|
raise ArgumentError, 'Invalid fact source backend'
|
34
34
|
end
|
35
|
-
@facts =
|
36
|
-
@orig_facts.each { |k, v| @facts[k] = v.dup }
|
35
|
+
@facts = OctocatalogDiff::Util::Util.deep_dup(@orig_facts)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -41,6 +40,15 @@ module OctocatalogDiff
|
|
41
40
|
self.class.new(@options, @orig_facts)
|
42
41
|
end
|
43
42
|
|
43
|
+
# Node - get the node name, either as set explicitly or as determined from the facts themselves.
|
44
|
+
# @return [String] Node name, explicit or guessed
|
45
|
+
def node
|
46
|
+
return @node unless @node.nil? || @node.empty?
|
47
|
+
return facts['name'] if facts.key?('name')
|
48
|
+
return facts['values']['fqdn'] if facts.key?('values') && facts['values'].key?('fqdn')
|
49
|
+
''
|
50
|
+
end
|
51
|
+
|
44
52
|
# Facts - returned the 'cleansed' facts.
|
45
53
|
# Clean up facts by setting 'name' to the node if given, and deleting _timestamp and expiration
|
46
54
|
# which may cause Puppet catalog compilation to fail if the facts are old.
|
@@ -21,8 +21,18 @@ module OctocatalogDiff
|
|
21
21
|
fact_file_data = fact_file_string.split(/\n/)
|
22
22
|
fact_file_data[0] = '---' if fact_file_data[0] =~ /^---/
|
23
23
|
|
24
|
-
# Load
|
25
|
-
|
24
|
+
# Load the parsed fact file.
|
25
|
+
parsed = YAML.load(fact_file_data.join("\n"))
|
26
|
+
|
27
|
+
# This is a handler for a YAML file that has just the facts and none of the
|
28
|
+
# structure. For example if you saved the output of `facter -y` to a file and
|
29
|
+
# are passing that in, this will work.
|
30
|
+
result = if parsed.key?('name') && parsed.key?('values')
|
31
|
+
parsed
|
32
|
+
else
|
33
|
+
{ 'name' => node || parsed['fqdn'] || '', 'values' => parsed }
|
34
|
+
end
|
35
|
+
|
26
36
|
result['name'] = node unless node == ''
|
27
37
|
result
|
28
38
|
end
|
@@ -197,6 +197,11 @@ module OctocatalogDiff
|
|
197
197
|
if catalog.valid?
|
198
198
|
# The catalog was successfully compiled.
|
199
199
|
result[key] = parallel_catalog_obj.output
|
200
|
+
|
201
|
+
if task.args[:save_catalog]
|
202
|
+
File.open(task.args[:save_catalog], 'w') { |f| f.write(catalog.catalog_json) }
|
203
|
+
@logger.debug "Saved catalog to #{task.args[:save_catalog]}"
|
204
|
+
end
|
200
205
|
else
|
201
206
|
# The catalog failed, but a catalog object was returned so that better error reporting
|
202
207
|
# can take place. In this error reporting, we will replace 'Error:' with '[Puppet Error]'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Handy methods that are not tied to one particular class
|
4
|
+
|
5
|
+
module OctocatalogDiff
|
6
|
+
module Util
|
7
|
+
# Helper class to construct catalogs, performing all necessary steps such as
|
8
|
+
# bootstrapping directories, installing facts, and running puppet.
|
9
|
+
class Util
|
10
|
+
# Utility Method!
|
11
|
+
# `is_a?(class)` only allows one method, but this uses an array
|
12
|
+
# @param object [?] Object to consider
|
13
|
+
# @param classes [Array] Classes to determine if object is a member of
|
14
|
+
# @return [Boolean] True if object is_a any of the classes, false otherwise
|
15
|
+
def self.object_is_any_of?(object, classes)
|
16
|
+
classes.each { |clazz| return true if object.is_a? clazz }
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
# Utility Method!
|
21
|
+
# `.dup` can't be called on certain objects (Fixnum for example). This
|
22
|
+
# method returns the original object if it can't be duplicated.
|
23
|
+
# @param object [?] Object to consider
|
24
|
+
# @return [?] Duplicated object if possible, otherwise the original object
|
25
|
+
def self.safe_dup(object)
|
26
|
+
object.dup
|
27
|
+
rescue TypeError
|
28
|
+
object
|
29
|
+
end
|
30
|
+
|
31
|
+
# Utility Method!
|
32
|
+
# This does a "deep" duplication via recursion. Handles hashes and arrays.
|
33
|
+
# @param object [?] Object to consider
|
34
|
+
# @return [?] Duplicated object
|
35
|
+
def self.deep_dup(object)
|
36
|
+
if object.is_a?(Hash)
|
37
|
+
result = {}
|
38
|
+
object.each { |k, v| result[k] = deep_dup(v) }
|
39
|
+
result
|
40
|
+
elsif object.is_a?(Array)
|
41
|
+
object.map { |ele| deep_dup(ele) }
|
42
|
+
else
|
43
|
+
safe_dup(object)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
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: 1.
|
4
|
+
version: 1.3.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-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: diffy
|
@@ -366,6 +366,7 @@ files:
|
|
366
366
|
- lib/octocatalog-diff/cli/options/quiet.rb
|
367
367
|
- lib/octocatalog-diff/cli/options/retry_failed_catalog.rb
|
368
368
|
- lib/octocatalog-diff/cli/options/safe_to_delete_cached_master_dir.rb
|
369
|
+
- lib/octocatalog-diff/cli/options/save_catalog.rb
|
369
370
|
- lib/octocatalog-diff/cli/options/storeconfigs.rb
|
370
371
|
- lib/octocatalog-diff/cli/options/suppress_absent_file_details.rb
|
371
372
|
- lib/octocatalog-diff/cli/options/to_from_branch.rb
|
@@ -391,6 +392,7 @@ files:
|
|
391
392
|
- lib/octocatalog-diff/util/parallel.rb
|
392
393
|
- lib/octocatalog-diff/util/puppetversion.rb
|
393
394
|
- lib/octocatalog-diff/util/scriptrunner.rb
|
395
|
+
- lib/octocatalog-diff/util/util.rb
|
394
396
|
- lib/octocatalog-diff/version.rb
|
395
397
|
- scripts/env/env.sh
|
396
398
|
- scripts/git-extract/git-extract.sh
|