Sha256: de7b93e796883a8e9114c483dc9ab7eeb56c522fa0d2ca197dde848249f5ccb4
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
require 'json' # If pre-compiled catalogs are available, these can be used to short-circuit the build process. # These files must exist and be in Puppet catalog format. # @param parser [OptionParser object] The OptionParser argument # @param options [Hash] Options hash being constructed; this is modified in this method. OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:existing_catalogs) do has_weight 30 def parse(parser, options) these_options = { 'from' => :from_catalog, 'to' => :to_catalog } these_options.each do |tag, hash_key| parser.on("--#{tag}-catalog FILENAME", "Use a pre-compiled catalog '#{tag}'") do |catalog_file| path = File.absolute_path(catalog_file) raise Errno::ENOENT, "Invalid '#{hash_key} catalog' file provided" unless File.file?(path) options[hash_key] = path if options[:node].nil? x = JSON.parse(File.read(path)) options[:node] ||= x['data']['name'] if x['data'].is_a?(Hash) options[:node] ||= x['name'] if x['name'].is_a?(String) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems