octocatalog-diff 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.version +1 -0
- data/LICENSE +20 -0
- data/README.md +82 -0
- data/bin/octocatalog-diff +75 -0
- data/doc/advanced-bootstrap.md +33 -0
- data/doc/advanced-cache-dir.md +24 -0
- data/doc/advanced-catalog-only.md +37 -0
- data/doc/advanced-ci.md +13 -0
- data/doc/advanced-dynamic-ignores.md +123 -0
- data/doc/advanced-future-parser.md +11 -0
- data/doc/advanced-ignores.md +224 -0
- data/doc/advanced-output-formats.md +96 -0
- data/doc/advanced-output-hacks.md +45 -0
- data/doc/advanced-override-facts.md +67 -0
- data/doc/advanced-pe-enc.md +52 -0
- data/doc/advanced-puppet-master.md +50 -0
- data/doc/advanced-puppet-versions.md +9 -0
- data/doc/advanced-storeconfigs.md +72 -0
- data/doc/advanced-using-without-git.md +15 -0
- data/doc/advanced.md +43 -0
- data/doc/basic.md +70 -0
- data/doc/configuration-enc.md +69 -0
- data/doc/configuration-hiera.md +103 -0
- data/doc/configuration-puppetdb.md +49 -0
- data/doc/configuration.md +51 -0
- data/doc/dev/README.md +1 -0
- data/doc/dev/coverage.md +34 -0
- data/doc/dev/how-to-add-options.md +83 -0
- data/doc/dev/integration-tests.md +63 -0
- data/doc/dev/releasing.md +19 -0
- data/doc/installation.md +49 -0
- data/doc/limitations.md +34 -0
- data/doc/optionsref.md +947 -0
- data/doc/requirements.md +16 -0
- data/doc/roadmap.md +26 -0
- data/doc/similar.md +17 -0
- data/doc/troubleshooting.md +54 -0
- data/lib/octocatalog-diff.rb +12 -0
- data/lib/octocatalog-diff/bootstrap.rb +53 -0
- data/lib/octocatalog-diff/catalog-diff/cli.rb +205 -0
- data/lib/octocatalog-diff/catalog-diff/cli/catalogs.rb +240 -0
- data/lib/octocatalog-diff/catalog-diff/cli/diffs.rb +145 -0
- data/lib/octocatalog-diff/catalog-diff/cli/helpers/fact_override.rb +99 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options.rb +173 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/basedir.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_environment.rb +18 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_script.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_then_exit.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb +18 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/cached_master_dir.rb +21 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/catalog_only.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/color.rb +13 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/compare_file_text.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/debug.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/display_datatype_changes.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/display_detail_add.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/display_source_file_line.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/enc.rb +31 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/existing_catalogs.rb +25 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/fact_file.rb +23 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/fact_override.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/facts_terminus.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/from_puppetdb.rb +13 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/header.rb +24 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_config.rb +18 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_path_strip.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hostname.rb +13 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/ignore.rb +24 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/ignore_attr.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/ignore_tags.rb +23 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/include_tags.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/master_cache_branch.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/output_file.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/output_format.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/parallel.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/parser.rb +48 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pass_env_vars.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_ca.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_cert.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_key.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token_file.rb +17 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_url.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_binary.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_api_version.rb +20 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_ca.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_cert.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_key.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_ca.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_cert.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_key.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password_file.rb +13 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_url.rb +18 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/quiet.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/retry_failed_catalog.rb +13 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/safe_to_delete_cached_master_dir.rb +15 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/storeconfigs.rb +12 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/suppress_absent_file_details.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/to_from_branch.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/printer.rb +52 -0
- data/lib/octocatalog-diff/catalog-diff/differ.rb +615 -0
- data/lib/octocatalog-diff/catalog-diff/display.rb +125 -0
- data/lib/octocatalog-diff/catalog-diff/display/json.rb +25 -0
- data/lib/octocatalog-diff/catalog-diff/display/text.rb +452 -0
- data/lib/octocatalog-diff/catalog-util/bootstrap.rb +145 -0
- data/lib/octocatalog-diff/catalog-util/builddir.rb +289 -0
- data/lib/octocatalog-diff/catalog-util/cached_master_directory.rb +169 -0
- data/lib/octocatalog-diff/catalog-util/command.rb +96 -0
- data/lib/octocatalog-diff/catalog-util/enc.rb +77 -0
- data/lib/octocatalog-diff/catalog-util/enc/noop.rb +22 -0
- data/lib/octocatalog-diff/catalog-util/enc/pe.rb +99 -0
- data/lib/octocatalog-diff/catalog-util/enc/pe/v1.rb +61 -0
- data/lib/octocatalog-diff/catalog-util/enc/script.rb +88 -0
- data/lib/octocatalog-diff/catalog-util/facts.rb +89 -0
- data/lib/octocatalog-diff/catalog-util/fileresources.rb +83 -0
- data/lib/octocatalog-diff/catalog-util/git.rb +65 -0
- data/lib/octocatalog-diff/catalog.rb +209 -0
- data/lib/octocatalog-diff/catalog/computed.rb +205 -0
- data/lib/octocatalog-diff/catalog/json.rb +30 -0
- data/lib/octocatalog-diff/catalog/noop.rb +19 -0
- data/lib/octocatalog-diff/catalog/puppetdb.rb +82 -0
- data/lib/octocatalog-diff/catalog/puppetmaster.rb +121 -0
- data/lib/octocatalog-diff/external/pson/LICENSE +17 -0
- data/lib/octocatalog-diff/external/pson/README.md +20 -0
- data/lib/octocatalog-diff/external/pson/common.rb +370 -0
- data/lib/octocatalog-diff/external/pson/pure.rb +15 -0
- data/lib/octocatalog-diff/external/pson/pure/generator.rb +395 -0
- data/lib/octocatalog-diff/external/pson/pure/parser.rb +307 -0
- data/lib/octocatalog-diff/external/pson/version.rb +8 -0
- data/lib/octocatalog-diff/facts.rb +125 -0
- data/lib/octocatalog-diff/facts/json.rb +20 -0
- data/lib/octocatalog-diff/facts/puppetdb.rb +59 -0
- data/lib/octocatalog-diff/facts/yaml.rb +29 -0
- data/lib/octocatalog-diff/puppetdb.rb +163 -0
- data/lib/octocatalog-diff/util/colored.rb +20 -0
- data/lib/octocatalog-diff/util/httparty.rb +158 -0
- data/lib/octocatalog-diff/util/parallel.rb +170 -0
- data/lib/octocatalog-diff/util/puppetversion.rb +24 -0
- data/lib/octocatalog-diff/version.rb +7 -0
- metadata +386 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Allow specification of a bootstrap script. This runs after checking out the directory, and before running
|
|
2
|
+
# puppet there. Good for running librarian to install modules, and anything else site-specific that needs
|
|
3
|
+
# to be done.
|
|
4
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
5
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
6
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:bootstrap_script) do
|
|
7
|
+
has_weight 40
|
|
8
|
+
|
|
9
|
+
def parse(parser, options)
|
|
10
|
+
parser.on('--bootstrap-script FILENAME', 'Bootstrap script relative to checkout directory') do |file|
|
|
11
|
+
options[:bootstrap_script] = file
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Option to bootstrap directories and then exit
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:bootstrap_then_exit) do
|
|
5
|
+
has_weight 70
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--bootstrap-then-exit', 'Bootstrap from-dir and/or to-dir and then exit') do
|
|
9
|
+
options[:bootstrap_then_exit] = true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Allow (or create) directories that are already bootstrapped. Handy to allow "bootstrap once, build many"
|
|
2
|
+
# to save time when diffing multiple catalogs on this system.
|
|
3
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
4
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
5
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:bootstrapped_dirs) do
|
|
6
|
+
has_weight 60
|
|
7
|
+
|
|
8
|
+
def parse(parser, options)
|
|
9
|
+
these_options = { 'from' => :bootstrapped_from_dir, 'to' => :bootstrapped_to_dir }
|
|
10
|
+
these_options.each do |tag, hash_key|
|
|
11
|
+
parser.on("--bootstrapped-#{tag}-dir DIRNAME", "Use a pre-bootstrapped '#{tag}' directory") do |dir|
|
|
12
|
+
options[hash_key] = File.absolute_path(dir)
|
|
13
|
+
Dir.mkdir options[hash_key], 0o700 unless Dir.exist?(options[hash_key])
|
|
14
|
+
raise "Invalid bootstrapped-#{tag}-dir: does not exist" unless Dir.exist?(options[hash_key])
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Cache a bootstrapped checkout of 'master' and use that for time-saving when the SHA
|
|
2
|
+
# has not changed.
|
|
3
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
4
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
5
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:cached_master_dir) do
|
|
6
|
+
has_weight 160
|
|
7
|
+
|
|
8
|
+
def parse(parser, options)
|
|
9
|
+
parser.on('--cached-master-dir PATH', 'Cache bootstrapped origin/master at this path') do |path_in|
|
|
10
|
+
path = File.absolute_path(path_in)
|
|
11
|
+
unless Dir.exist?(path)
|
|
12
|
+
begin
|
|
13
|
+
Dir.mkdir path, 0o755
|
|
14
|
+
rescue Errno::ENOENT => exc
|
|
15
|
+
raise Errno::ENOENT, "Invalid cached master directory path: #{exc}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
options[:cached_master_dir] = path
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# When set, --catalog-only will only compile the catalog for the 'to' branch, and skip any
|
|
2
|
+
# diffing activity. The catalog will be printed to STDOUT or written to the output file.
|
|
3
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
4
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
5
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:catalog_only) do
|
|
6
|
+
has_weight 290
|
|
7
|
+
|
|
8
|
+
def parse(parser, options)
|
|
9
|
+
desc = 'Only compile the catalog for the "to" branch but do not diff'
|
|
10
|
+
parser.on('--[no-]catalog-only', desc) do |x|
|
|
11
|
+
options[:catalog_only] = x
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Color printing option
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:color) do
|
|
5
|
+
has_weight 80
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--[no-]color', 'Enable/disable colors in output') do |color|
|
|
9
|
+
options[:colors] = color
|
|
10
|
+
options[:format] = color ? :color_text : :text
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# When a file is specified with `source => 'puppet:///modules/something/foo.txt'`, remove
|
|
2
|
+
# the 'source' attribute and populate the 'content' attribute with the text of the file.
|
|
3
|
+
# This allows for a diff of the content, rather than a diff of the location, which is
|
|
4
|
+
# what is most often desired.
|
|
5
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
6
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
7
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:compare_file_text) do
|
|
8
|
+
has_weight 210
|
|
9
|
+
|
|
10
|
+
def parse(parser, options)
|
|
11
|
+
parser.on('--[no-]compare-file-text', 'Compare text, not source location, of file resources') do |x|
|
|
12
|
+
options[:compare_file_text] = x
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Debugging option
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:debug) do
|
|
5
|
+
has_weight 110
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--[no-]debug', '-d', 'Print debugging messages to STDERR') do |x|
|
|
9
|
+
options[:debug] = x
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Toggle on or off the display of data type changes when the string representation
|
|
2
|
+
# is the same. For example with this enabled, '42' (the string) and 42 (the integer)
|
|
3
|
+
# will be displayed as a difference. With this disabled, this is not displayed as a
|
|
4
|
+
# difference.
|
|
5
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
6
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
7
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:display_datatype_changes) do
|
|
8
|
+
has_weight 280
|
|
9
|
+
|
|
10
|
+
def parse(parser, options)
|
|
11
|
+
desc = 'Display changes in data type even when strings match'
|
|
12
|
+
parser.on('--[no-]display-datatype-changes', desc) do |x|
|
|
13
|
+
options[:display_datatype_changes] = x
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Provide ability to display details of 'added' resources in the output.
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:display_detail_add) do
|
|
5
|
+
has_weight 250
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--[no-]display-detail-add', 'Display parameters and other details for added resources') do |x|
|
|
9
|
+
options[:display_detail_add] = x
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Display source filename and line number for diffs
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:display_source_file_line) do
|
|
5
|
+
has_weight 200
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--[no-]display-source', 'Show source file and line for each difference') do |x|
|
|
9
|
+
options[:display_source_file_line] = x
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Path to external node classifier, relative to the base directory of the checkout.
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:enc) do
|
|
5
|
+
has_weight 240
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--no-enc', 'Disable ENC') do
|
|
9
|
+
options[:no_enc] = true
|
|
10
|
+
options[:enc] = nil
|
|
11
|
+
options[:from_enc] = nil
|
|
12
|
+
options[:to_enc] = nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
parser.on('--enc PATH', 'Path to ENC script, relative to checkout directory or absolute') do |x|
|
|
16
|
+
unless options[:no_enc]
|
|
17
|
+
proposed_enc_path = x.start_with?('/') ? x : File.join(options[:basedir], x)
|
|
18
|
+
raise Errno::ENOENT, "Provided ENC (#{proposed_enc_path}) does not exist" unless File.file?(proposed_enc_path)
|
|
19
|
+
options[:enc] = proposed_enc_path
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
parser.on('--from-enc PATH', 'Path to ENC script (for the from catalog only)') do |x|
|
|
24
|
+
options[:from_enc] = x unless options[:no_enc]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
parser.on('--to-enc PATH', 'Path to ENC script (for the to catalog only)') do |x|
|
|
28
|
+
options[:to_enc] = x unless options[:no_enc]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
# If pre-compiled catalogs are available, these can be used to short-circuit the build process.
|
|
4
|
+
# These files must exist and be in Puppet catalog format.
|
|
5
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
6
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
7
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:existing_catalogs) do
|
|
8
|
+
has_weight 30
|
|
9
|
+
|
|
10
|
+
def parse(parser, options)
|
|
11
|
+
these_options = { 'from' => :from_catalog, 'to' => :to_catalog }
|
|
12
|
+
these_options.each do |tag, hash_key|
|
|
13
|
+
parser.on("--#{tag}-catalog FILENAME", "Use a pre-compiled catalog '#{tag}'") do |catalog_file|
|
|
14
|
+
path = File.absolute_path(catalog_file)
|
|
15
|
+
raise Errno::ENOENT, "Invalid '#{hash_key} catalog' file provided" unless File.file?(path)
|
|
16
|
+
options[hash_key] = path
|
|
17
|
+
if options[:node].nil?
|
|
18
|
+
x = JSON.parse(File.read(path))
|
|
19
|
+
options[:node] ||= x['data']['name'] if x['data'].is_a?(Hash)
|
|
20
|
+
options[:node] ||= x['name'] if x['name'].is_a?(String)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Allow an existing fact file to be provided, to avoid pulling facts from PuppetDB.
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:fact_file) do
|
|
5
|
+
has_weight 150
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--fact-file FILENAME', 'Fact file to use instead of node lookup') do |fact_file|
|
|
9
|
+
raise Errno::ENOENT, 'Invalid fact file provided' unless File.file?(fact_file)
|
|
10
|
+
facts = nil
|
|
11
|
+
local_opts = { fact_file_string: File.read(fact_file) }
|
|
12
|
+
if fact_file =~ /\.ya?ml$/
|
|
13
|
+
facts = OctocatalogDiff::Facts.new(local_opts.merge(backend: :yaml))
|
|
14
|
+
elsif fact_file =~ /\.json$/
|
|
15
|
+
facts = OctocatalogDiff::Facts.new(local_opts.merge(backend: :json))
|
|
16
|
+
else
|
|
17
|
+
raise ArgumentError, 'I do not know how to parse the provided fact file. Needs .yaml or .json extension.'
|
|
18
|
+
end
|
|
19
|
+
options[:facts] = facts
|
|
20
|
+
options[:node] ||= facts.facts['name']
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Allow override of facts on the command line. Fact overrides can be supplied for the 'to' or 'from' catalog,
|
|
2
|
+
# or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
|
3
|
+
# by permitting a data type specification as well.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:fact_override) do
|
|
5
|
+
has_weight 320
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
# Set 'fact_override_in' because more processing is needed, once the command line options
|
|
9
|
+
# have been parsed, to make this into the final form 'fact_override'.
|
|
10
|
+
OctocatalogDiff::CatalogDiff::Cli::Options.option_globally_or_per_branch(
|
|
11
|
+
parser: parser,
|
|
12
|
+
options: options,
|
|
13
|
+
cli_name: 'fact-override',
|
|
14
|
+
option_name: 'fact_override_in',
|
|
15
|
+
desc: 'Override fact',
|
|
16
|
+
datatype: []
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Get the facts terminus. Generally this is 'yaml' and a fact file will be loaded from PuppetDB or
|
|
2
|
+
# elsewhere in the environment. However it can be set to 'facter' which will run facter on the host
|
|
3
|
+
# on which this is running.
|
|
4
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
5
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
6
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:facts_terminus) do
|
|
7
|
+
has_weight 310
|
|
8
|
+
|
|
9
|
+
def parse(parser, options)
|
|
10
|
+
termini = %w(yaml facter)
|
|
11
|
+
parser.on('--facts-terminus STRING', "Facts terminus: one of #{termini.join(', ')}") do |x|
|
|
12
|
+
raise ArgumentError, "Invalid facts terminus #{x}; supported: #{termini.join(', ')}" unless termini.include?(x)
|
|
13
|
+
options[:facts_terminus] = x
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Set --from-puppetdb to pull most recent catalog from PuppetDB instead of compiling
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:from_puppetdb) do
|
|
5
|
+
has_weight 300
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
desc = 'Pull "from" catalog from PuppetDB instead of compiling'
|
|
9
|
+
parser.on('--[no-]from-puppetdb', desc) do |x|
|
|
10
|
+
options[:from_puppetdb] = x
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Provide ability to set custom header or to display no header at all
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:header) do
|
|
5
|
+
has_weight 260
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--no-header', 'Do not print a header') do
|
|
9
|
+
raise ArgumentError, '--no-header incompatible with --default-header' if options[:header] == :default
|
|
10
|
+
raise ArgumentError, '--no-header incompatible with --header' unless options[:header].nil?
|
|
11
|
+
options[:no_header] = true
|
|
12
|
+
end
|
|
13
|
+
parser.on('--default-header', 'Print default header with output') do
|
|
14
|
+
raise ArgumentError, '--default-header incompatible with --header' unless options[:header].nil?
|
|
15
|
+
raise ArgumentError, '--default-header incompatible with --no-header' unless options[:no_header].nil?
|
|
16
|
+
options[:header] = :default
|
|
17
|
+
end
|
|
18
|
+
parser.on('--header STRING', 'Specify header for output') do |x|
|
|
19
|
+
raise ArgumentError, '--header incompatible with --default-header' if options[:header] == :default
|
|
20
|
+
raise ArgumentError, '--header incompatible with --no-header' unless options[:no_header].nil?
|
|
21
|
+
options[:header] = x
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Specify a relative path to the Hiera yaml file
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:hiera_config) do
|
|
5
|
+
has_weight 180
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--hiera-config PATH', 'Relative path to hiera YAML file') do |path_in|
|
|
9
|
+
raise ArgumentError, '--no-hiera-config incompatible with --hiera-config' if options[:no_hiera_config]
|
|
10
|
+
options[:hiera_config] = path_in
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
parser.on('--no-hiera-config', 'Disable hiera config file installation') do
|
|
14
|
+
raise ArgumentError, '--no-hiera-config incompatible with --hiera-config' if options[:hiera_config]
|
|
15
|
+
options[:no_hiera_config] = true
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Specify the path to strip off the datadir to munge hiera.yaml file
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:hiera_path_strip) do
|
|
5
|
+
has_weight 181
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--hiera-path-strip PATH', 'Path prefix to strip when munging hiera.yaml') do |path_in|
|
|
9
|
+
options[:hiera_path_strip] = path_in
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Set hostname, which is used to look up facts in PuppetDB, and in the header of diff display.
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
|
|
5
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:hostname) do
|
|
6
|
+
has_weight 1
|
|
7
|
+
|
|
8
|
+
def parse(parser, options)
|
|
9
|
+
parser.on('--hostname HOSTNAME', '-n', 'Use PuppetDB facts from last run of hostname') do |hostname|
|
|
10
|
+
options[:node] = hostname
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Options used when comparing catalogs - set ignored changes.
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:ignore) do
|
|
5
|
+
has_weight 130
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
descriptive_text = 'More resources to ignore in format type[title]'
|
|
9
|
+
parser.on('--ignore "Type1[Title1],Type2[Title2],..."', Array, descriptive_text) do |res|
|
|
10
|
+
options[:ignore] ||= []
|
|
11
|
+
res.each do |item|
|
|
12
|
+
if item =~ /\A(.+?)\[(.+)\](.+)/
|
|
13
|
+
h = { type: Regexp.last_match(1), title: Regexp.last_match(2) }
|
|
14
|
+
h[:attr] = Regexp.last_match(3).gsub(/(\\f|::)/, "\f")
|
|
15
|
+
options[:ignore] << h
|
|
16
|
+
elsif item =~ /^(.+?)\[(.+)\]$/
|
|
17
|
+
options[:ignore] << { type: Regexp.last_match(1), title: Regexp.last_match(2) }
|
|
18
|
+
else
|
|
19
|
+
raise ArgumentError, "Ignore #{item} must be in Type[Title] or Type[Title]::Attribute format!"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Specify attributes to ignore
|
|
2
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
3
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
4
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:ignore_attr) do
|
|
5
|
+
has_weight 190
|
|
6
|
+
|
|
7
|
+
def parse(parser, options)
|
|
8
|
+
parser.on('--ignore-attr "attr1,attr2,..."', Array, 'Attributes to ignore') do |res|
|
|
9
|
+
options[:ignore] ||= []
|
|
10
|
+
res.each do |item|
|
|
11
|
+
item_subst = item.gsub(/(\\f|::)/, "\f")
|
|
12
|
+
options[:ignore] << { attr: item_subst }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Provide ability to set one or more tags, which will cause catalog-diff
|
|
2
|
+
# to ignore any changes for any defined type where this tag is set.
|
|
3
|
+
# @param parser [OptionParser object] The OptionParser argument
|
|
4
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
|
5
|
+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:ignore_tags) do
|
|
6
|
+
has_weight 400
|
|
7
|
+
|
|
8
|
+
def parse(parser, options)
|
|
9
|
+
parser.on('--no-ignore-tags', 'Disable ignoring based on tags') do
|
|
10
|
+
if options[:ignore_tags]
|
|
11
|
+
raise ArgumentError, '--no-ignore-tags incompatible with --ignore-tags'
|
|
12
|
+
end
|
|
13
|
+
options[:no_ignore_tags] = true
|
|
14
|
+
end
|
|
15
|
+
parser.on('--ignore-tags STRING1[,STRING2[,...]]', Array, 'Specify tags to ignore') do |x|
|
|
16
|
+
if options[:no_ignore_tags]
|
|
17
|
+
raise ArgumentError, '--ignore-tags incompatible with --no-ignore-tags'
|
|
18
|
+
end
|
|
19
|
+
options[:ignore_tags] ||= []
|
|
20
|
+
options[:ignore_tags].concat x
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|