octocatalog-diff 0.5.6 → 0.6.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 +23 -5
- data/doc/advanced-bootstrap.md +25 -0
- data/doc/advanced-catalog-validation.md +41 -0
- data/doc/advanced-environments.md +93 -0
- data/doc/advanced-hiera-path-stripping.md +2 -0
- data/doc/advanced.md +2 -0
- data/doc/configuration-enc.md +34 -0
- data/doc/dev/releasing.md +40 -2
- data/doc/dev/run-from-branch.md +62 -0
- data/doc/installation.md +6 -0
- data/doc/optionsref.md +84 -22
- data/lib/octocatalog-diff/bootstrap.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli.rb +4 -1
- data/lib/octocatalog-diff/catalog-diff/cli/catalogs.rb +8 -2
- data/lib/octocatalog-diff/catalog-diff/cli/diffs.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/helpers/fact_override.rb +3 -2
- data/lib/octocatalog-diff/catalog-diff/cli/options.rb +14 -2
- data/lib/octocatalog-diff/catalog-diff/cli/options/basedir.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_current.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_environment.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_script.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_then_exit.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/cached_master_dir.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/catalog_only.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/color.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/command_line.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/compare_file_text.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/create_symlinks.rb +20 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/debug.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/debug_bootstrap.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/display_datatype_changes.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/display_detail_add.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/display_source_file_line.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/enc.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/environment.rb +19 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/existing_catalogs.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/fact_file.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/fact_override.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/facts_terminus.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/from_puppetdb.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/header.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_config.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_path.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_path_strip.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/hostname.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/ignore.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/ignore_attr.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/ignore_tags.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/include_tags.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/master_cache_branch.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/output_file.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/output_format.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/parallel.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/parser.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pass_env_vars.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_ca.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_cert.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_key.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token_file.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_url.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/preserve_environments.rb +16 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_binary.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_api_version.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_ca.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_cert.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_key.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_api_version.rb +14 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_ca.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_cert.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_key.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password_file.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_url.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/quiet.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/retry_failed_catalog.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/safe_to_delete_cached_master_dir.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/storeconfigs.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/suppress_absent_file_details.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/to_from_branch.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/cli/options/validate_references.rb +27 -0
- data/lib/octocatalog-diff/catalog-diff/cli/printer.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/differ.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/display.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/display/json.rb +2 -0
- data/lib/octocatalog-diff/catalog-diff/display/text.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/bootstrap.rb +7 -1
- data/lib/octocatalog-diff/catalog-util/builddir.rb +49 -13
- data/lib/octocatalog-diff/catalog-util/cached_master_directory.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/command.rb +61 -1
- data/lib/octocatalog-diff/catalog-util/enc.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/enc/noop.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/enc/pe.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/enc/pe/v1.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/enc/script.rb +3 -1
- data/lib/octocatalog-diff/catalog-util/facts.rb +2 -0
- data/lib/octocatalog-diff/catalog-util/fileresources.rb +19 -14
- data/lib/octocatalog-diff/catalog-util/git.rb +2 -0
- data/lib/octocatalog-diff/catalog.rb +75 -2
- data/lib/octocatalog-diff/catalog/computed.rb +16 -0
- data/lib/octocatalog-diff/catalog/json.rb +2 -0
- data/lib/octocatalog-diff/catalog/noop.rb +2 -0
- data/lib/octocatalog-diff/catalog/puppetdb.rb +2 -0
- data/lib/octocatalog-diff/catalog/puppetmaster.rb +8 -2
- data/lib/octocatalog-diff/facts.rb +2 -0
- data/lib/octocatalog-diff/facts/json.rb +2 -0
- data/lib/octocatalog-diff/facts/puppetdb.rb +10 -1
- data/lib/octocatalog-diff/facts/yaml.rb +2 -0
- data/lib/octocatalog-diff/puppetdb.rb +2 -0
- data/lib/octocatalog-diff/util/colored.rb +2 -0
- data/lib/octocatalog-diff/util/httparty.rb +2 -0
- data/lib/octocatalog-diff/util/parallel.rb +4 -1
- data/lib/octocatalog-diff/util/puppetversion.rb +2 -0
- data/lib/octocatalog-diff/version.rb +2 -0
- metadata +11 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'cli/catalogs'
|
2
4
|
require_relative 'cli/diffs'
|
3
5
|
require_relative 'cli/options'
|
@@ -164,7 +166,8 @@ module OctocatalogDiff
|
|
164
166
|
logger.level = Logger::ERROR if options[:quiet]
|
165
167
|
|
166
168
|
# Some debugging information up front
|
167
|
-
|
169
|
+
version_display = ENV['OCTOCATALOG_DIFF_CUSTOM_VERSION'] || VERSION
|
170
|
+
logger.debug "Running octocatalog-diff #{version_display} with ruby #{RUBY_VERSION}"
|
168
171
|
logger.debug "Command line arguments: #{argv_save.inspect}"
|
169
172
|
logger.debug "Running on host #{Socket.gethostname} (#{RUBY_PLATFORM})"
|
170
173
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'open3'
|
3
5
|
require 'yaml'
|
@@ -155,6 +157,7 @@ module OctocatalogDiff
|
|
155
157
|
task = OctocatalogDiff::Util::Parallel::Task.new(
|
156
158
|
method: method(:build_catalog),
|
157
159
|
validator: method(:catalog_validator),
|
160
|
+
validator_args: { task: key },
|
158
161
|
description: "build_catalog for #{@options["#{key}_env".to_sym]}",
|
159
162
|
args: args
|
160
163
|
)
|
@@ -195,7 +198,7 @@ module OctocatalogDiff
|
|
195
198
|
# and remove the compilation directory (which is a tmpdir) to reveal only the relative
|
196
199
|
# path to the files involved.
|
197
200
|
dir = catalog.compilation_dir || ''
|
198
|
-
dir_regex = Regexp.new(Regexp.escape(dir) + '/environments/
|
201
|
+
dir_regex = Regexp.new(Regexp.escape(dir) + '/environments/[^/]+/')
|
199
202
|
error_display = catalog.error_message.split("\n").map do |line|
|
200
203
|
line.sub(/^Error:/, '[Puppet Error]').gsub(dir_regex, '')
|
201
204
|
end.join("\n")
|
@@ -229,9 +232,12 @@ module OctocatalogDiff
|
|
229
232
|
|
230
233
|
# Validate a catalog in the parallel execution
|
231
234
|
# @param catalog [OctocatalogDiff::Catalog] Catalog object
|
235
|
+
# @param logger [Logger] Logger object (presently unused)
|
236
|
+
# @param args [Hash] Additional arguments set specifically for validator
|
232
237
|
# @return [Boolean] true if catalog is valid, false otherwise
|
233
|
-
def catalog_validator(catalog = nil, _logger = @logger)
|
238
|
+
def catalog_validator(catalog = nil, _logger = @logger, args = {})
|
234
239
|
return false unless catalog.is_a?(OctocatalogDiff::Catalog)
|
240
|
+
catalog.validate_references if args[:task] == :to
|
235
241
|
catalog.valid?
|
236
242
|
end
|
237
243
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module OctocatalogDiff
|
@@ -26,8 +28,7 @@ module OctocatalogDiff
|
|
26
28
|
unless input.include?('=')
|
27
29
|
raise ArgumentError, "Fact override '#{input}' is not in 'key=(data type)value' format"
|
28
30
|
end
|
29
|
-
input.strip
|
30
|
-
@key, raw_value = input.split('=', 2)
|
31
|
+
@key, raw_value = input.strip.split('=', 2)
|
31
32
|
@value = parsed_value(raw_value)
|
32
33
|
elsif key.nil?
|
33
34
|
message = "Define a key when the input is not a string (#{input.class} => #{input.inspect})"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../cli'
|
2
4
|
require_relative '../../facts'
|
3
5
|
require_relative '../../version'
|
@@ -28,6 +30,10 @@ module OctocatalogDiff
|
|
28
30
|
@weight || DEFAULT_WEIGHT
|
29
31
|
end
|
30
32
|
|
33
|
+
def self.name
|
34
|
+
self::NAME
|
35
|
+
end
|
36
|
+
|
31
37
|
def self.newoption(name, &block)
|
32
38
|
klass = Class.new(OctocatalogDiff::CatalogDiff::Cli::Options::Option)
|
33
39
|
klass.const_set('NAME', name)
|
@@ -59,12 +65,18 @@ module OctocatalogDiff
|
|
59
65
|
end
|
60
66
|
|
61
67
|
# Read in *.rb files in the 'options' directory and create classes from them.
|
62
|
-
# Sort the classes according to weight and return the list of sorted classes.
|
68
|
+
# Sort the classes according to weight and name and return the list of sorted classes.
|
63
69
|
# @return [Array<Class>] Sorted classes
|
64
70
|
def self.option_classes
|
65
71
|
files = Dir.glob(File.join(File.dirname(__FILE__), 'options', '*.rb'))
|
66
72
|
files.each { |file| load file } # Populates self.classes
|
67
|
-
classes.sort
|
73
|
+
classes.sort do |a, b|
|
74
|
+
[
|
75
|
+
a.weight <=> b.weight,
|
76
|
+
a.name.downcase <=> b.name.downcase,
|
77
|
+
a.object_id <=> b.object_id
|
78
|
+
].find(&:nonzero?)
|
79
|
+
end
|
68
80
|
end
|
69
81
|
|
70
82
|
# Sets up options that can be defined globally or for just one branch. For example, with a
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# When set, --catalog-only will only compile the catalog for the 'to' branch, and skip any
|
2
4
|
# diffing activity. The catalog will be printed to STDOUT or written to the output file.
|
3
5
|
# @param parser [OptionParser object] The OptionParser argument
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Provide additional command line flags to set when running Puppet to compile catalogs.
|
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(:command_line) do
|
7
|
+
has_weight 510
|
8
|
+
|
9
|
+
def parse(parser, options)
|
10
|
+
OctocatalogDiff::CatalogDiff::Cli::Options.option_globally_or_per_branch(
|
11
|
+
parser: parser,
|
12
|
+
options: options,
|
13
|
+
cli_name: 'command-line',
|
14
|
+
option_name: 'command_line',
|
15
|
+
desc: 'Command line arguments',
|
16
|
+
datatype: []
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# When a file is specified with `source => 'puppet:///modules/something/foo.txt'`, remove
|
2
4
|
# the 'source' attribute and populate the 'content' attribute with the text of the file.
|
3
5
|
# This allows for a diff of the content, rather than a diff of the location, which is
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Specify which directories from the base should be symlinked into the temporary compilation
|
4
|
+
# environment. This is useful only in conjunction with `--preserve-environments`.
|
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(:create_symlinks) do
|
8
|
+
has_weight 503
|
9
|
+
|
10
|
+
def parse(parser, options)
|
11
|
+
OctocatalogDiff::CatalogDiff::Cli::Options.option_globally_or_per_branch(
|
12
|
+
parser: parser,
|
13
|
+
options: options,
|
14
|
+
cli_name: 'create-symlinks',
|
15
|
+
option_name: 'create_symlinks',
|
16
|
+
desc: 'Symlinks to create',
|
17
|
+
datatype: []
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Toggle on or off the display of data type changes when the string representation
|
2
4
|
# is the same. For example with this enabled, '42' (the string) and 42 (the integer)
|
3
5
|
# will be displayed as a difference. With this disabled, this is not displayed as a
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Path to external node classifier, relative to the base directory of the checkout.
|
2
4
|
# @param parser [OptionParser object] The OptionParser argument
|
3
5
|
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Specify the environment to use when compiling the catalog. This is useful only in conjunction
|
4
|
+
# with `--preserve-environments`.
|
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(:environment) do
|
8
|
+
has_weight 502
|
9
|
+
|
10
|
+
def parse(parser, options)
|
11
|
+
OctocatalogDiff::CatalogDiff::Cli::Options.option_globally_or_per_branch(
|
12
|
+
parser: parser,
|
13
|
+
options: options,
|
14
|
+
cli_name: 'environment',
|
15
|
+
option_name: 'environment',
|
16
|
+
desc: 'Environment for catalog compilation'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Allow an existing fact file to be provided, to avoid pulling facts from PuppetDB.
|
2
4
|
# @param parser [OptionParser object] The OptionParser argument
|
3
5
|
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Allow override of facts on the command line. Fact overrides can be supplied for the 'to' or 'from' catalog,
|
2
4
|
# or for both. There is some attempt to handle data types here (since all items on the command line are strings)
|
3
5
|
# by permitting a data type specification as well.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Set --from-puppetdb to pull most recent catalog from PuppetDB instead of compiling
|
2
4
|
# @param parser [OptionParser object] The OptionParser argument
|
3
5
|
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Specify the path to the Hiera data directory (relative to the top level Puppet checkout). For Puppet Enterprise and the
|
2
4
|
# Puppet control repo template, the value of this should be 'hieradata', which is the default.
|
3
5
|
# @param parser [OptionParser object] The OptionParser argument
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Set hostname, which is used to look up facts in PuppetDB, and in the header of diff display.
|
2
4
|
# @param parser [OptionParser object] The OptionParser argument
|
3
5
|
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Options used when comparing catalogs - tags are generally ignored; you can un-ignore them.
|
2
4
|
# @param parser [OptionParser object] The OptionParser argument
|
3
5
|
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# One or more environment variables that should be made available to the Puppet binary when parsing
|
2
4
|
# the catalog. For example, --pass-env-vars FOO,BAR will make the FOO and BAR environment variables
|
3
5
|
# available. Setting these variables is your responsibility outside of octocatalog-diff.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Specify the CA certificate for the Puppet Enterprise ENC. If specified, this will enable SSL verification
|
2
4
|
# that the certificate being presented has been signed by this CA, and that the common name
|
3
5
|
# matches the name you are using to connecting.
|