|
11 | 11 | require_relative 'version' |
12 | 12 |
|
13 | 13 | require 'logger' |
| 14 | +require 'parallel' |
14 | 15 | require 'socket' |
15 | 16 |
|
16 | 17 | module OctocatalogDiff |
@@ -116,16 +117,34 @@ def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {}) |
116 | 117 | end |
117 | 118 |
|
118 | 119 | # Compile catalogs and do catalog-diff |
119 | | - catalog_diff = OctocatalogDiff::API::V1.catalog_diff(options.merge(logger: logger)) |
120 | | - diffs = catalog_diff.diffs |
121 | | - |
122 | | - # Display diffs |
123 | | - printer_obj = OctocatalogDiff::Cli::Printer.new(options, logger) |
124 | | - printer_obj.printer(diffs, catalog_diff.from.compilation_dir, catalog_diff.to.compilation_dir) |
| 120 | + node_set = options.delete(:node) |
| 121 | + node_set = [node_set] unless node_set.is_a?(Array) |
| 122 | + catalog_diff = nil |
| 123 | + all_diffs = [] |
| 124 | + |
| 125 | + # run multiple node diffs in parallel |
| 126 | + Parallel.map(node_set, in_threads: 4) do |node| |
| 127 | + options[:node] = node |
| 128 | + catalog_diff = OctocatalogDiff::API::V1.catalog_diff(options.merge(logger: logger)) |
| 129 | + diffs = catalog_diff.diffs |
| 130 | + |
| 131 | + # Display diffs |
| 132 | + printer_obj = OctocatalogDiff::Cli::Printer.new(options, logger) |
| 133 | + printer_obj.printer(diffs, catalog_diff.from.compilation_dir, catalog_diff.to.compilation_dir) |
| 134 | + |
| 135 | + # Append any diffs for final exit status |
| 136 | + all_diffs << diffs |
| 137 | + end |
125 | 138 |
|
126 | 139 | # Return the resulting diff object if requested (generally for testing) or otherwise return exit code |
127 | 140 | return catalog_diff if opts[:INTEGRATION] |
128 | | - diffs.any? ? EXITCODE_SUCCESS_WITH_DIFFS : EXITCODE_SUCCESS_NO_DIFFS |
| 141 | + |
| 142 | + all_diffs.each do |diff| |
| 143 | + next unless diff.any? |
| 144 | + return EXITCODE_SUCCESS_WITH_DIFFS |
| 145 | + end |
| 146 | + |
| 147 | + EXITCODE_SUCCESS_NO_DIFFS |
129 | 148 | end |
130 | 149 |
|
131 | 150 | # Parse command line options with 'optparse'. Returns a hash with the parsed arguments. |
|
0 commit comments