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.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/README.md +5 -2
  4. data/bin/octocatalog-diff +9 -49
  5. data/doc/CHANGELOG.md +14 -0
  6. data/doc/advanced-filter.md +59 -1
  7. data/doc/advanced-override-enc.md +54 -0
  8. data/doc/advanced-pe-enc.md +1 -1
  9. data/doc/advanced.md +2 -1
  10. data/doc/dev/api.md +5 -0
  11. data/doc/dev/api/v1.md +41 -0
  12. data/doc/dev/api/v1/calls/catalog-diff.md +209 -0
  13. data/doc/dev/api/v1/calls/catalog.md +115 -0
  14. data/doc/dev/api/v1/calls/config.md +37 -0
  15. data/doc/dev/api/v1/objects/catalog.md +127 -0
  16. data/doc/dev/api/v1/objects/diff.md +261 -0
  17. data/doc/dev/api/v1/objects/override.md +30 -0
  18. data/doc/dev/how-to-add-options.md +12 -12
  19. data/doc/optionsref.md +91 -74
  20. data/doc/versions/v1.md +22 -0
  21. data/lib/octocatalog-diff.rb +1 -8
  22. data/lib/octocatalog-diff/api/v1.rb +27 -0
  23. data/lib/octocatalog-diff/api/v1/catalog-compile.rb +40 -0
  24. data/lib/octocatalog-diff/api/v1/catalog-diff.rb +68 -0
  25. data/lib/octocatalog-diff/api/v1/catalog.rb +84 -0
  26. data/lib/octocatalog-diff/api/v1/common.rb +24 -0
  27. data/lib/octocatalog-diff/api/v1/config.rb +125 -0
  28. data/lib/octocatalog-diff/api/v1/diff.rb +194 -0
  29. data/lib/octocatalog-diff/api/v1/override.rb +103 -0
  30. data/lib/octocatalog-diff/catalog-diff/differ.rb +66 -47
  31. data/lib/octocatalog-diff/catalog-diff/display.rb +8 -2
  32. data/lib/octocatalog-diff/catalog-diff/display/json.rb +3 -2
  33. data/lib/octocatalog-diff/catalog-diff/display/legacy_json.rb +28 -0
  34. data/lib/octocatalog-diff/catalog-diff/display/text.rb +64 -9
  35. data/lib/octocatalog-diff/catalog-diff/filter.rb +45 -6
  36. data/lib/octocatalog-diff/catalog-diff/filter/absent_file.rb +65 -0
  37. data/lib/octocatalog-diff/catalog-diff/filter/compilation_dir.rb +78 -0
  38. data/lib/octocatalog-diff/catalog-diff/filter/yaml.rb +10 -7
  39. data/lib/octocatalog-diff/catalog-util/bootstrap.rb +13 -14
  40. data/lib/octocatalog-diff/catalog-util/builddir.rb +1 -0
  41. data/lib/octocatalog-diff/catalog-util/cached_master_directory.rb +2 -2
  42. data/lib/octocatalog-diff/catalog-util/enc.rb +49 -14
  43. data/lib/octocatalog-diff/catalog-util/enc/pe.rb +3 -5
  44. data/lib/octocatalog-diff/catalog-util/enc/pe/v1.rb +3 -1
  45. data/lib/octocatalog-diff/catalog-util/git.rb +36 -24
  46. data/lib/octocatalog-diff/catalog.rb +5 -9
  47. data/lib/octocatalog-diff/catalog/computed.rb +9 -1
  48. data/lib/octocatalog-diff/catalog/puppetdb.rb +4 -3
  49. data/lib/octocatalog-diff/cli.rb +195 -0
  50. data/lib/octocatalog-diff/cli/diffs.rb +40 -0
  51. data/lib/octocatalog-diff/cli/options.rb +183 -0
  52. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/basedir.rb +1 -1
  53. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_current.rb +1 -1
  54. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_environment.rb +1 -1
  55. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_script.rb +1 -1
  56. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrap_then_exit.rb +1 -1
  57. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/bootstrapped_dirs.rb +1 -1
  58. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/cached_master_dir.rb +1 -1
  59. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/catalog_only.rb +1 -1
  60. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/color.rb +1 -1
  61. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/command_line.rb +2 -2
  62. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/compare_file_text.rb +1 -1
  63. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/create_symlinks.rb +2 -2
  64. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/debug.rb +1 -1
  65. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/debug_bootstrap.rb +1 -1
  66. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/display_datatype_changes.rb +1 -1
  67. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/display_detail_add.rb +1 -1
  68. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/display_source_file_line.rb +1 -1
  69. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/enc.rb +1 -1
  70. data/lib/octocatalog-diff/cli/options/enc_override.rb +21 -0
  71. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/environment.rb +2 -2
  72. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/existing_catalogs.rb +1 -1
  73. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/fact_file.rb +1 -1
  74. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/fact_override.rb +2 -2
  75. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/facts_terminus.rb +1 -1
  76. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/filters.rb +5 -2
  77. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/from_puppetdb.rb +1 -1
  78. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/header.rb +1 -1
  79. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hiera_config.rb +1 -1
  80. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hiera_path.rb +1 -1
  81. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hiera_path_strip.rb +1 -1
  82. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/hostname.rb +1 -1
  83. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/ignore.rb +1 -1
  84. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/ignore_attr.rb +1 -1
  85. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/ignore_tags.rb +1 -1
  86. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/include_tags.rb +1 -1
  87. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/master_cache_branch.rb +1 -1
  88. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/output_file.rb +1 -1
  89. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/output_format.rb +5 -3
  90. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/parallel.rb +1 -1
  91. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/parser.rb +1 -1
  92. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pass_env_vars.rb +1 -1
  93. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_ssl_ca.rb +1 -1
  94. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_ssl_client_cert.rb +1 -1
  95. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_ssl_client_key.rb +1 -1
  96. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_token.rb +1 -1
  97. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_token_file.rb +1 -1
  98. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/pe_enc_url.rb +1 -1
  99. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/preserve_environments.rb +1 -1
  100. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_binary.rb +2 -2
  101. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master.rb +2 -2
  102. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_api_version.rb +2 -2
  103. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_ssl_ca.rb +2 -2
  104. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_ssl_client_cert.rb +2 -2
  105. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppet_master_ssl_client_key.rb +2 -2
  106. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_api_version.rb +1 -1
  107. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_ca.rb +1 -1
  108. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_cert.rb +1 -1
  109. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_key.rb +1 -1
  110. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_password.rb +1 -1
  111. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_ssl_client_password_file.rb +1 -1
  112. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/puppetdb_url.rb +1 -1
  113. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/quiet.rb +1 -1
  114. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/retry_failed_catalog.rb +1 -1
  115. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/safe_to_delete_cached_master_dir.rb +1 -1
  116. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/storeconfigs.rb +1 -1
  117. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/suppress_absent_file_details.rb +2 -1
  118. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/to_from_branch.rb +1 -1
  119. data/lib/octocatalog-diff/{catalog-diff/cli → cli}/options/validate_references.rb +1 -1
  120. data/lib/octocatalog-diff/cli/printer.rb +52 -0
  121. data/lib/octocatalog-diff/errors.rb +33 -0
  122. data/lib/octocatalog-diff/facts.rb +1 -4
  123. data/lib/octocatalog-diff/facts/puppetdb.rb +8 -7
  124. data/lib/octocatalog-diff/puppetdb.rb +5 -9
  125. data/lib/octocatalog-diff/util/catalogs.rb +242 -0
  126. metadata +97 -75
  127. data/lib/octocatalog-diff/catalog-diff/cli.rb +0 -211
  128. data/lib/octocatalog-diff/catalog-diff/cli/catalogs.rb +0 -246
  129. data/lib/octocatalog-diff/catalog-diff/cli/diffs.rb +0 -147
  130. data/lib/octocatalog-diff/catalog-diff/cli/helpers/fact_override.rb +0 -100
  131. data/lib/octocatalog-diff/catalog-diff/cli/options.rb +0 -185
  132. data/lib/octocatalog-diff/catalog-diff/cli/printer.rb +0 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a89d4a61710f5fd7a044241c3dd99d0d50ec2737
4
- data.tar.gz: 362d9371778130cc5eda6978ce9563ac6a1d93e1
3
+ metadata.gz: 94e2cf0a922da25cff91452ca8e2a3631cc1d97c
4
+ data.tar.gz: 6fbf668920f43516ccae0cd58095187e9d78f8d9
5
5
  SHA512:
6
- metadata.gz: 5fcf1c9e9373f21fc8c14cb3cca8163659e6b0be55a4c449e500d95f35172d29f546de3deba0028d2702e53310a77b9182a06dadace338ec15afa237ddb1fc90
7
- data.tar.gz: cad1f341cf55e43336f1e1945035491f949f9d81d6cfa13359e5b9c8ae50b6caccf3e7c8c7822e86e05d09fdddff45c7135d2949b5cffe085ff9301cb10ae785
6
+ metadata.gz: 616ac7fe5586015dd0afa7511074db94358ae09150e183392ab68aba81d1ade9750594ec3d4d7a62ad333b088ef758aa094bfa4392457f800a41dbf3d1a78b51
7
+ data.tar.gz: afaa669b726b5f983be6fefd0ded47e14fc649c25e459a2d286a7b28d378908c1081309f788ce9d45e7674b590295b4562a93ac7b3c5d27538c30cd10431f1f5
data/.version CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 1.0.0
data/README.md CHANGED
@@ -8,7 +8,9 @@ At GitHub, we manage thousands of nodes with a Puppet code base containing 500,0
8
8
 
9
9
  `octocatalog-diff` is written in Ruby and is distributed as a gem. It runs on Mac OS and Unix/Linux platforms.
10
10
 
11
- It is under active development at this time. We suspect that with the initial release, some people who try it out could be using configurations of Puppet that we haven't experienced within our environment. We are eager to identify and fix as many of these as we can to expand the compatibility of this tool as much as possible.
11
+ We consider the 1.x release of `octocatalog-diff` to be stable and production-quality. We continue to maintain and enhance `octocatalog-diff` to meet GitHub's internal needs and to incorporate suggestions from the community. Please consult the [change log](/doc/CHANGELOG.md) for details.
12
+
13
+ If you've been using version 0.6.1 or earlier, please read about [What's new in octocatalog-diff 1.0](/doc/versions/v1.md) for a summary of new capabilities and breaking changes.
12
14
 
13
15
  ## How?
14
16
 
@@ -58,6 +60,7 @@ The example above reflects the changes in the Puppet catalog from switching an u
58
60
  - [Similar tools](/doc/similar.md)
59
61
  - [Contributing](/.github/CONTRIBUTING.md)
60
62
  - [Developer documentation](/doc/dev)
63
+ - [API documentation](/doc/dev/api.md)
61
64
 
62
65
  ## What's in a name?
63
66
 
@@ -79,4 +82,4 @@ It requires 3rd party ruby gems found [here](/vendor/cache). It also includes po
79
82
 
80
83
  ## Authors
81
84
 
82
- `octocatalog-diff` was designed and authored by [Kevin Paulisse](https://github.com/kpaulisse) and is now maintained, reviewed, and tested by the Site Reliability Engineering team at GitHub.
85
+ `octocatalog-diff` was designed and authored by [Kevin Paulisse](https://github.com/kpaulisse) and is now maintained, reviewed, and tested by Kevin and the rest of the Site Reliability Engineering team at GitHub.
@@ -20,56 +20,16 @@ end
20
20
 
21
21
  config_test = ARGV.include?('--config-test')
22
22
 
23
- paths = [
24
- ENV['OCTOCATALOG_DIFF_CONFIG_FILE'],
25
- File.join(Dir.pwd, '.octocatalog-diff.cfg.rb'),
26
- File.join(ENV['HOME'], '.octocatalog-diff.cfg.rb'),
27
- '/opt/puppetlabs/octocatalog-diff/octocatalog-diff.cfg.rb',
28
- '/usr/local/etc/octocatalog-diff.cfg.rb',
29
- '/etc/octocatalog-diff.cfg.rb'
30
- ]
31
-
32
- cfgfile = nil
33
-
34
- paths.each do |path|
35
- next if path.nil?
36
- puts "Looking for config in: #{path}" if config_test
37
- next unless File.file?(path)
38
- begin
39
- cfgfile = path
40
- puts "Loading config: #{path}" if config_test
41
- require path
42
- rescue => exc
43
- STDERR.puts "#{exc.class} error with #{path}: #{exc.message}\n#{exc.backtrace}"
44
- exit 1
45
- end
46
- break
47
- end
48
-
49
- options = {}
50
-
51
- if cfgfile
52
- begin
53
- options = OctocatalogDiff::Config.config
54
- rescue => exc
55
- STDERR.puts "#{exc.class} error with #{cfgfile}: #{exc.message}\n#{exc.backtrace}"
56
- exit 1
57
- end
58
- unless options.is_a?(Hash)
59
- STDERR.puts "Configuration must be Hash not #{options.class}!"
60
- exit 1
61
- end
62
- if config_test
63
- options.each do |key, val|
64
- puts ":#{key} => (#{val.class}) #{val.inspect}"
65
- end
66
- exit 0
67
- end
68
- elsif config_test
69
- STDERR.puts 'No configuration files found'
70
- exit 1
23
+ logger = Logger.new(STDERR)
24
+ logger.level = Logger::INFO
25
+ logger.level = Logger::DEBUG if config_test
26
+
27
+ options = OctocatalogDiff::API::V1.config(logger: logger, test: config_test)
28
+ if config_test
29
+ logger.info 'Exiting now because --config-test was specified'
30
+ exit(0)
71
31
  end
72
32
 
73
33
  argv = ARGV.dup
74
- exit_code = OctocatalogDiff::CatalogDiff::Cli.cli(argv, Logger.new(STDERR), options)
34
+ exit_code = OctocatalogDiff::Cli.cli(argv, Logger.new(STDERR), options)
75
35
  exit(exit_code)
@@ -8,6 +8,20 @@
8
8
  </tr>
9
9
  </thead><tbody>
10
10
  <tr valign=top>
11
+ <td>1.0.0</td>
12
+ <td>2017-02-06</td>
13
+ <td>
14
+ This is the first release of the 1.0 series. For more information please see <a href="./versions/v1.md">What's new in octocatalog-diff 1.0</a>.
15
+ <br>
16
+ <br>
17
+ The most significant change in version 1.0 is the addition of the <a href="./dev/api.md">V1 API</a>, which permits developers to build catalogs (<code>--catalog-only</code>) and compare/diff catalogs using octocatalog-diff. Under the hood, we've rearranged the code to support these APIs, which should improve the reliability and allow faster development cycles.
18
+
19
+ <h4>Breaking Changes</h4>
20
+
21
+ The format of the output from <code>--output-format json</code> has changed. In version 0.x of the software, each difference was represented by an array. In version 1.x, each difference is represented by a hash with meaningful English keys. We have added an option <code>--output-format legacy_json</code> for anyone who may depend on the old format.
22
+ </td>
23
+ </tr>
24
+ <tr valign=top>
11
25
  <td>0.6.1</td>
12
26
  <td>2017-01-07</td>
13
27
  <td>
@@ -9,7 +9,65 @@ Please note that there are other options to ignore specified diffs, including:
9
9
 
10
10
  Here is the list of available filters and an explanation of each:
11
11
 
12
- - [YAML](#YAML) - Ignore whitespace/comment differences if YAML parses to the same object
12
+ - [Absent File](/doc/advanced-filter.md#absent-file) - Ignore parameter changes of a file that is declared to be absent
13
+ - [YAML](/doc/advanced-filter.md#yaml) - Ignore whitespace/comment differences if YAML parses to the same object
14
+
15
+ ## Absent File
16
+
17
+ #### Usage
18
+
19
+ ```
20
+ --filters AbsentFile
21
+ ```
22
+
23
+ #### Description
24
+
25
+ When the `AbsentFile` filter is enabled, if any file is `ensure => absent` in the *new* catalog, then changes to any other parameters will be suppressed.
26
+
27
+ Consider that a file resource is declared as follows in two catalogs:
28
+
29
+ ```
30
+ # Old catalog
31
+ file { '/etc/some-file':
32
+ ensure => present,
33
+ owner => 'root',
34
+ group => 'nobody',
35
+ content => 'my content here',
36
+ }
37
+
38
+ # New catalog
39
+ file { '/etc/some-file':
40
+ ensure => absent,
41
+ owner => 'bob',
42
+ }
43
+ ```
44
+
45
+ Since the practical effect of the new catalog will be to remove the file, it doesn't matter that the owner of the (non-existent) file has changed from 'root' to 'bob', or that the content and group have changed from a string to undefined. Consider the default output without the filter:
46
+
47
+ ```
48
+ File[/etc/some-file] =>
49
+ parameters =>
50
+ ensure =>
51
+ - present
52
+ + absent
53
+ group =>
54
+ - nobody
55
+ owner =>
56
+ - root
57
+ + bob
58
+ content =>
59
+ - my content here
60
+ ```
61
+
62
+ Wouldn't it be nice if the meaningless information didn't appear, and all you saw was the transition you actually care about, from present to absent? With `--filters AbsentFile` it does just this:
63
+
64
+ ```
65
+ File[/etc/some-file] =>
66
+ parameters =>
67
+ ensure =>
68
+ - present
69
+ + absent
70
+ ```
13
71
 
14
72
  ## YAML
15
73
 
@@ -0,0 +1,54 @@
1
+ # Overriding ENC parameters
2
+
3
+ One powerful feature of `octocatalog-diff` allows you to override ENC parameters when compiling the catalogs, to predict the effect of an ENC parameter change on the catalog. This is useful to simulate a change in agent node configuration without actually setting up an agent to do so.
4
+
5
+ ## Usage
6
+
7
+ To override an ENC parameter in both catalogs:
8
+
9
+ ```
10
+ --enc-override parameters::some_class::some_param=value
11
+ ```
12
+
13
+ To override an ENC parameter in the "to" catalog:
14
+
15
+ ```
16
+ --to-enc-override parameters::some_class::some_param=value
17
+ ```
18
+
19
+ To override an ENC parameter in the "from" catalog:
20
+
21
+ ```
22
+ --from-enc-override parameters::some_class::some_param=value
23
+ ```
24
+
25
+ You may use as many of these arguments as you wish to adjust as many ENC parameters as you wish.
26
+
27
+ ## Limitations
28
+
29
+ As presently implemented, this only works on ENCs that supply their results as YAML.
30
+
31
+ Is your ENC doing something different? Please [let us know](https://github.com/github/octocatalog-diff/issues/new) so we can enhance octocatalog-diff to handle it!
32
+
33
+ ## Examples
34
+
35
+ Simulate a change to a top-level parameter named "role" only in the "to" catalog:
36
+
37
+ ```
38
+ octocatalog-diff -n some-node.example.com -f master -t master \
39
+ --to-enc-override parameters::role=some_new_role
40
+ ```
41
+
42
+ Simulate a change in a class parameter between the catalogs:
43
+
44
+ ```
45
+ octocatalog-diff -n some-node.example.com -f master -t master \
46
+ --from-enc-override parameters::my_class::my_value=value_in_old \
47
+ --to-enc-override parameters::my_class::my_value=value_in_new
48
+ ```
49
+
50
+ Note that each of the examples specified the from branch and to branch to be `master`. There is no requirement that you do this, but you can generally obtain the most accurate test results by changing only one variable at a time.
51
+
52
+ ## Advanced usage
53
+
54
+ The format for declaring overrides with data types is the same as [overriding facts](/doc/advanced-override-facts.md#advanced-usage).
@@ -39,7 +39,7 @@ Please see [Authentication token](https://docs.puppet.com/pe/latest/nc_forming_r
39
39
 
40
40
  The referenced document contains links to generate a token with the `puppet-access` command.
41
41
 
42
- Note that if you wish to hard-code an authentication token in your [configuration file](/doc/configuration.md), the internal variable key is `:pe_enc_token` and the content is a string containing the entire token. (The `--pe-enc-token-file` option simply reads the provided file and stores the content in the `:pe_enc_token` key. See [source](/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token_file.rb).)
42
+ Note that if you wish to hard-code an authentication token in your [configuration file](/doc/configuration.md), the internal variable key is `:pe_enc_token` and the content is a string containing the entire token. (The `--pe-enc-token-file` option simply reads the provided file and stores the content in the `:pe_enc_token` key. See [source](/lib/octocatalog-diff/cli/options/pe_enc_token_file.rb).)
43
43
 
44
44
  ### SSL client keypair
45
45
 
@@ -18,11 +18,12 @@ See also:
18
18
  - [Building catalogs instead of diffing catalogs](/doc/advanced-catalog-only.md)
19
19
  - [Enabling storeconfigs for exported resources in PuppetDB](/doc/advanced-storeconfigs.md)
20
20
  - [Fetching catalogs from Puppet Master / PuppetServer](/doc/advanced-puppet-master.md)
21
+ - [Overriding ENC parameters](/doc/advanced-override-enc.md)
21
22
  - [Overriding facts](/doc/advanced-override-facts.md)
22
23
  - [Puppet Enterprise node classification service](/doc/advanced-pe-enc.md)
23
24
  - [Using `octocatalog-diff` without git](/doc/advanced-using-without-git.md)
24
25
  - [Catalog validation](/doc/advanced-catalog-validation.md)
25
- - [Environment setup](/doc/advanced-environment.md)
26
+ - [Environment setup](/doc/advanced-environments.md)
26
27
 
27
28
  ### Controlling output
28
29
 
@@ -0,0 +1,5 @@
1
+ # octocatalog-diff API documentation
2
+
3
+ The octocatalog-diff API allows developers to construct and work with certain octocatalog-diff internals in their own projects.
4
+
5
+ The current API version is [API v1](/doc/dev/api/v1.md), which is available as of octocatalog-diff version 1.0.
@@ -0,0 +1,41 @@
1
+ # octocatalog-diff v1 API documentation
2
+
3
+ ## API calls
4
+
5
+ #### catalog
6
+
7
+ `catalog` allows you to build a catalog using the octocatalog-diff compiler or to obtain a catalog from a Puppet server.
8
+
9
+ [Read more about the `catalog` call](/doc/dev/api/v1/calls/catalog.md)
10
+
11
+ #### catalog-diff
12
+
13
+ `catalog-diff` allows you compare two catalogs and obtain the differences between them. Catalogs can be built if necessary.
14
+
15
+ [Read more about the `catalog-diff` call](/doc/dev/api/v1/calls/catalog-diff.md)
16
+
17
+ #### config
18
+
19
+ `config` allows you read and parse an [octocatalog-diff configuration file](/doc/configuration.md).
20
+
21
+ [Read more about the `config` call](/doc/dev/api/v1/calls/config.md)
22
+
23
+ ## Objects
24
+
25
+ #### OctocatalogDiff::API::V1::Catalog
26
+
27
+ The `OctocatalogDiff::API::V1::Catalog` object represents a compiled catalog and supports several methods to get information about the catalog.
28
+
29
+ [Read more about the `OctocatalogDiff::API::V1::Catalog` object](/doc/dev/api/v1/objects/catalog.md)
30
+
31
+ #### OctocatalogDiff::API::V1::Diff
32
+
33
+ The `OctocatalogDiff::API::V1::Diff` object represents a difference between two catalogs and supports several methods to get information about the difference.
34
+
35
+ [Read more about the `OctocatalogDiff::API::V1::Diff` object](/doc/dev/api/v1/objects/diff.md)
36
+
37
+ #### OctocatalogDiff::API::V1::Override
38
+
39
+ The `OctocatalogDiff::API::V1::Override` object represents a user-supplied fact or ENC parameter that will be used when compiling a catalog.
40
+
41
+ [Read more about the `OctocatalogDiff::API::V1::Override` object](/doc/dev/api/v1/objects/override.md)
@@ -0,0 +1,209 @@
1
+ # octocatalog-diff v1 API documentation: catalog-diff
2
+
3
+ ## Overview
4
+
5
+ `catalog-diff` allows you compare two catalogs and obtain the differences between them. Catalogs can be built if necessary.
6
+
7
+ This is analogous to using the default arguments with the octocatalog-diff command-line script.
8
+
9
+ ```
10
+ catalog_diff_result = OctocatalogDiff::API::V1.catalog_diff(<Hash>)
11
+ #=> {
12
+ diffs: Array<OctocatalogDiff::API::V1::Diff>,
13
+ from: OctocatalogDiff::API::V1::Catalog,
14
+ to: OctocatalogDiff::API::V1::Catalog
15
+ }
16
+ ```
17
+
18
+ Return values:
19
+ - [`OctocatalogDiff::API::V1::Diff`](/doc/dev/api/v1/objects/diff.md)
20
+ - [`OctocatalogDiff::API::V1::Catalog`](/doc/dev/api/v1/objects/catalog.md)
21
+
22
+ For an example, see [catalog-diff-local-files.rb](/examples/api/v1/catalog-diff-local-files.rb).
23
+
24
+ ## Parameters
25
+
26
+ The `catalog_diff` method takes one argument, which is a Hash containing parameters.
27
+
28
+ The list of parameters here is not exhaustive. The `.catalog_diff` method accepts most parameters described in [Configuration](/doc/configuration.md), [Advanced options](/doc/advanced.md), and [Command line options reference](/doc/optionsref.md).
29
+
30
+ It is also possible to use the parameters from [OctocatalogDiff::API::V1.config](/doc/dev/api/v1/calls/config.md) for the catalog-diff calculation. Simply combine the hash returned by `.config` with any additional keys, and pass the merged hash to the `.catalog_diff` method.
31
+
32
+ ### Global parameters
33
+
34
+ #### `:logger` (Logger, Optional)
35
+
36
+ Debugging and informational messages will be logged to this object as the catalogs are built and differences are computed.
37
+
38
+ If no Logger object is passed, these messages will be silently discarded.
39
+
40
+ #### `:node` (String, Required)
41
+
42
+ The node name whose catalogs are to be compiled and differences obtained obtained. This should be the fully qualified domain name that matches the node's name as seen in Puppet.
43
+
44
+ ### Computed catalog parameters
45
+
46
+ #### `:basedir` (String, Optional)
47
+
48
+ Directory that contains a git repository with the Puppet code. Use in conjunction with `:to_branch` and `:from_branch` to specify the branch names that should be checked out.
49
+
50
+ If your Puppet code is not in a git repository, or you already have the branches checked out via some other process, use `:bootstrapped_to_dir` and `:bootstrapped_from_dir` instead.
51
+
52
+ #### `:bootstrap_script` (String, Optional)
53
+
54
+ Path to a script to run after checking out the selected branch of Puppet code from the git repository. See [Bootstrapping your Puppet checkout](/doc/advanced-bootstrap.md) for details.
55
+
56
+ #### `:bootstrapped_to_dir` / `:bootstrapped_from_dir` (String, Optional)
57
+
58
+ Directories that is already prepared ("bootstrapped") and can have Puppet run against its contents to compile the catalog. `:bootstrapped_to_dir` is used for the "to" catalog, while `:bootstrapped_from_dir` is used for the "from" catalog.
59
+
60
+ Often this means that you have done the following to this directory:
61
+
62
+ - Checked out the necessary branch of Puppet code from your version control system
63
+ - Installed any third party modules (e.g. with librarian-puppet or r10k)
64
+
65
+ You may mix and match `:bootstrapped_XXX_dir` and `:basedir` + `:XXX_branch`. For example, you may specify `:bootstrapped_from_dir`, `:basedir`, and `:to_branch`, which will compile the "from" catalog in the bootstrapped "from" directory you specified, and the "to" catalog from the "to_branch" branch of the git repository found in the "basedir".
66
+
67
+ #### `:enc` / `:to_enc` / `:from_enc` (String, Optional)
68
+
69
+ File path to your External Node Classifier.
70
+
71
+ See [Configuring octocatalog-diff to use ENC](/doc/configuration-enc.md) for details on using octocatalog-diff with an External Node Classifier.
72
+
73
+ In most cases, you will use the `:enc` option to set the ENC for both the "to" and "from" catalogs. In the case that you are comparing two different ENCs, you may use `:to_enc` and/or `:from_enc` as needed.
74
+
75
+ #### `:fact_file` / `:to_fact_file` / `:from_fact_file` (String, Optional)
76
+
77
+ Path to the file that contains the facts for the node whose catalog you are going to compile.
78
+
79
+ Generally, must either specify the fact file, or [configure octocatalog-diff to use PuppetDB](/doc/configuration-puppetdb.md) to retrieve node facts.
80
+
81
+ In most cases, you will use the `:fact_file` option to set the fact file for both the "to" and "from" catalogs. In the case that you are comparing the results from two different sets of facts, you may use `:to_fact_file` and/or `:from_fact_file` as needed.
82
+
83
+ #### `:hiera_config` (String, Optional)
84
+
85
+ Path to the Hiera configuration file (generally named `hiera.yaml`) for your Puppet installation. Please see [Configuring octocatalog-diff to use Hiera](/doc/configuration-hiera.md) for details on Hiera configuration.
86
+
87
+ #### `:hiera_path` (String, Optional)
88
+
89
+ Directory within your Puppet installation where Hiera data is stored. Please see [Configuring octocatalog-diff to use Hiera](/doc/configuration-hiera.md) for details on Hiera configuration.
90
+
91
+ If your Puppet setup is modeled after the [Puppet control repository template](https://github.com/puppetlabs/control-repo), the correct setting for `:hiera_path` is `'hieradata'`.
92
+
93
+ #### `:puppet_binary` / `:to_puppet_binary` / `:from_puppet_binary` (String, Required)
94
+
95
+ Path to the Puppet binary on your system.
96
+
97
+ Please refer to [Configuring octocatalog-diff to use Puppet](/doc/configuration-puppet.md) for details of connecting octocatalog-diff to your Puppet installation.
98
+
99
+ In most cases, you will use the `:puppet_binary` option to set the Puppet binary for both the "to" and "from" catalogs. In the case that you are comparing the catalogs produced by two different versions of Puppet, you may use `:to_puppet_binary` and/or `:from_puppet_binary` as needed.
100
+
101
+ #### `:puppetdb_url` (String, Optional)
102
+
103
+ URL to PuppetDB. See [Configuring octocatalog-diff to use PuppetDB](/doc/configuration-puppetdb.md) for instructions on this setting, and other settings that may be needed in your environment.
104
+
105
+ #### `:to_branch` / `:from_branch` (String, Optional)
106
+
107
+ Branch name in git repository to use for Puppet code. Each option must be used in conjunction with `:basedir` so that code can be located.
108
+
109
+ If you have specified `:bootstrapped_from_dir` or `:from_catalog`, then `:from_branch` will be ignored.
110
+
111
+ If you have specified `:bootstrapped_to_dir` or `:to_catalog`, then `:from_branch` will be ignored.
112
+
113
+ #### `:to_catalog` / `:from_catalog` (String, Optional)
114
+
115
+ If you have already compiled a catalog, set `:to_catalog` and/or `:from_catalog` to the full path to the catalog file.
116
+
117
+ If you specify a `:XXX_catalog` setting, this will cause `:bootstrapped_XXX_dir` and `:XXX_branch` parameters to be ignored.
118
+
119
+ ### Controlling diffs
120
+
121
+ #### `:ignore` (Array&lt;Hash&gt;, Optional)
122
+
123
+ Populating the `:ignore` array filters out matching differences from the overall result using the built-in logic. Please refer to [Ignoring certain changes from the command line](/doc/advanced-ignores.md) for details.
124
+
125
+ The expected data structure for ignoring a type (e.g. `File` or `Exec`) or title is to construct a hash with a regular expression, like this.
126
+
127
+ ```
128
+ # Simple definition, ignores File[/etc/foo]
129
+ [ { type: Regexp.new('\AFile\z'), title: Regexp.new('\A/etc/foo\z') } ]
130
+
131
+ # More complicated definition, ignores files in 'tmp' or '.tmp' directories wherever they exist
132
+ [ { type: Regexp.new('\AFile\z'), title: Regexp.new('/\.?tmp/') } ]
133
+
134
+ # Ignore all anchors
135
+ [ { type: Regexp.new('\AAnchor\z') } ]
136
+
137
+ # Ignore all resources of any type that contain 'foo' in the title
138
+ [ { title: Regexp.new('foo') } ]
139
+ ```
140
+
141
+ To ignore based on attributes, it is important to understand that each catalog resource is structured as a hash, sometimes with depth greater than 1. An example of Puppet code and the corresponding catalog structure is shown here:
142
+
143
+ ```
144
+ # Puppet code
145
+ file { '/etc/hostname':
146
+ owner => 'root',
147
+ notify => [ Service['postfix'], Exec['update hostname'] ],
148
+ content => $::fqdn,
149
+ }
150
+
151
+ # In the catalog (somewhat abbreviated for brevity)...
152
+ {
153
+ "type": "File",
154
+ "title": "/etc/hostname",
155
+ "parameters": {
156
+ "owner": "root",
157
+ "notify": [
158
+ "Service[postfix]",
159
+ "Exec[update hostname]"
160
+ ],
161
+ "content": "foo-bar.example.com"
162
+ }
163
+ }
164
+ ```
165
+
166
+ In this case, "owner", "notify", and "content" are nested under "parameters". Internally in octocatalog-diff, this nesting is represented by the "\f" character. (We chose a character that you should have no reason to put in your resource titles or key names.) Thus, the following examples work:
167
+
168
+ ```
169
+ # Ignore all changes to the `owner` attribute of a file.
170
+ [ { type: Regexp.new('\AFile\z'), attr: Regexp.new("\Aparameters\fowner\z" } ]
171
+
172
+ # Ignore changes to `owner` or `group` for a file or an exec.
173
+ [ { type: Regexp.new('\A(File|Exec)\z'), attr: Regexp.new("\Aparameters\f(owner|group)\z" } ]
174
+ ```
175
+
176
+ #### `:validate_references` (Array&lt;String&gt;, Optional)
177
+
178
+ Invoke the [catalog validation](/doc/advanced-catalog-validation.md) feature to ensure resources targeted by `before`, `notify`, `require`, and/or `subscribe` exist in the catalog. If this parameter is not defined, no reference validation occurs.
179
+
180
+ You must set this parameter to an **Array** that contains one or more of the following values:
181
+
182
+ - `before`
183
+ - `notify`
184
+ - `require`
185
+ - `subscribe`
186
+
187
+ ## Exceptions
188
+
189
+ The following exceptions may occur during the compilation of a catalog within the catalog-diff operation:
190
+
191
+ - `OctocatalogDiff::Errors::BootstrapError`
192
+
193
+ Bootstrapping failed.
194
+
195
+ - `OctocatalogDiff::Errors::CatalogError`
196
+
197
+ Catalog failed to compile. Please note that whenever possible, a `OctocatalogDiff::API::V1::Catalog` object is still constructed for a failed catalog, with `#valid?` returning false.
198
+
199
+ - `OctocatalogDiff::Errors::GitCheckoutError`
200
+
201
+ Git checkout failed.
202
+
203
+ - `OctocatalogDiff::Errors::PuppetVersionError`
204
+
205
+ The version of Puppet could not be determined, generally because the Puppet binary was not found, or does not respond as expected to `puppet version`.
206
+
207
+ - `OctocatalogDiff::Errors::ReferenceValidationError`
208
+
209
+ See [Catalog validation](/doc/advanced-catalog-validation.md).