Skip to content

Commit 5d9e0f4

Browse files
authored
Merge pull request #48 from github/kpaulisse-split-cli-catalogs
Move cli/catalogs -> util/catalogs
2 parents 6768f58 + 503b668 commit 5d9e0f4

12 files changed

Lines changed: 63 additions & 63 deletions

File tree

lib/octocatalog-diff/catalog-util/bootstrap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def self.bootstrap_directory_parallelizer(options, logger)
8484
end
8585

8686
# Performs the actual bootstrap of a directory. Intended to be called by bootstrap_directory_parallelizer
87-
# above, or as part of the parallelized catalog build process from cli/catalogs.
87+
# above, or as part of the parallelized catalog build process from util/catalogs.
8888
# @param logger [Logger] Logger object
8989
# @param dir_opts [Hash] Directory options: branch, path, tag
9090
def self.bootstrap_directory(options, logger)

lib/octocatalog-diff/catalog-util/cached_master_directory.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative 'bootstrap'
44
require_relative 'git'
5-
require_relative '../cli/catalogs'
5+
require_relative '../util/catalogs'
66

77
require 'fileutils'
88

@@ -134,7 +134,7 @@ def self.git_repo_checkout_bootstrap(options, logger)
134134
fake_options[:from_env] = master_branch(options)
135135

136136
logger.debug 'Begin bootstrap cached master directory'
137-
catalogs_obj = OctocatalogDiff::Cli::Catalogs.new(fake_options, logger)
137+
catalogs_obj = OctocatalogDiff::Util::Catalogs.new(fake_options, logger)
138138
catalogs_obj.bootstrap_then_exit
139139
logger.debug 'Success bootstrap cached master directory'
140140

lib/octocatalog-diff/cli.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require_relative 'cli/catalogs'
3+
require_relative 'util/catalogs'
44
require_relative 'cli/diffs'
55
require_relative 'cli/helpers/fact_override'
66
require_relative 'cli/options'
@@ -101,7 +101,7 @@ def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {})
101101
# depend on facts. This happens within the 'catalogs' object, since bootstrapping and
102102
# preparing catalogs are tightly coupled operations. However this does not actually
103103
# build catalogs.
104-
catalogs_obj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
104+
catalogs_obj = OctocatalogDiff::Util::Catalogs.new(options, logger)
105105
return bootstrap_then_exit(logger, catalogs_obj) if options[:bootstrap_then_exit]
106106

107107
# Compile catalogs
@@ -181,7 +181,7 @@ def self.catalog_only(logger, options)
181181
from_catalog: '-', # Prevents a compile
182182
to_catalog: nil, # Forces a compile
183183
)
184-
cat_obj = OctocatalogDiff::Cli::Catalogs.new(catalog_opts, logger)
184+
cat_obj = OctocatalogDiff::Util::Catalogs.new(catalog_opts, logger)
185185
catalogs = cat_obj.catalogs
186186

187187
# If the catalog compilation failed, an exception would have been thrown. So if
@@ -201,7 +201,7 @@ def self.catalog_only(logger, options)
201201
def self.bootstrap_then_exit(logger, catalogs_obj)
202202
catalogs_obj.bootstrap_then_exit
203203
return EXITCODE_SUCCESS_NO_DIFFS
204-
rescue OctocatalogDiff::Cli::Catalogs::BootstrapError => exc
204+
rescue OctocatalogDiff::Util::Catalogs::BootstrapError => exc
205205
logger.fatal("--bootstrap-then-exit error: bootstrap failed (#{exc})")
206206
return EXITCODE_FAILURE
207207
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
require 'yaml'
66
require_relative '../catalog-util/bootstrap' # For BootstrapError
77
require_relative '../catalog'
8-
require_relative '../util/parallel'
8+
require_relative 'parallel'
99

1010
module OctocatalogDiff
11-
class Cli
11+
module Util
1212
# Helper class to construct catalogs, performing all necessary steps such as
1313
# bootstrapping directories, installing facts, and running puppet.
1414
class Catalogs

spec/octocatalog-diff/integration/catalog_compute_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative 'integration_helper'
44

5-
require OctocatalogDiff::Spec.require_path('/cli/catalogs')
5+
require OctocatalogDiff::Spec.require_path('/util/catalogs')
66
require OctocatalogDiff::Spec.require_path('/catalog')
77
require OctocatalogDiff::Spec.require_path('/facts')
88

@@ -48,7 +48,7 @@
4848
if @has_git && @has_tar && @has_bash
4949
options = @default_options.merge(enc: 'environments/production/config/enc.sh')
5050
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
51-
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
51+
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
5252
result = testobj.catalogs
5353
@to = result[:to]
5454
@from = result[:from]
@@ -111,7 +111,7 @@
111111
if @has_git && @has_tar
112112
options = @default_options.dup
113113
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
114-
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
114+
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
115115
result = testobj.catalogs
116116
@to = result[:to]
117117
@from = result[:from]
@@ -175,7 +175,7 @@
175175
options = @default_options.merge(hiera_config: 'environments/production/config/hiera.yaml',
176176
hiera_path_strip: '/var/lib/puppet')
177177
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
178-
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
178+
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
179179
result = testobj.catalogs
180180
@to = result[:to]
181181
@from = result[:from]
@@ -257,7 +257,7 @@
257257
to_env: '.'
258258
)
259259
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
260-
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
260+
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
261261
result = testobj.catalogs
262262
@to = result[:to]
263263
@from = result[:from]

spec/octocatalog-diff/integration/convert_file_resources_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
]
119119
)
120120
expect(result[:exitcode]).to eq(-1)
121-
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
121+
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
122122
expect(result[:exception].message).to match(/failed to compile with Errno::ENOENT/)
123123
expect(result[:exception].message).to match(%r{Unable to resolve 'puppet:///modules/test/foo-new'})
124124
end

spec/octocatalog-diff/integration/pe_enc_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def self.respond(code, message, content_type = nil, body = '')
129129
}
130130
result = OctocatalogDiff::Integration.integration(opts)
131131
expect(result[:exitcode]).to eq(-1)
132-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
132+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
133133
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
134134
end
135135

@@ -194,7 +194,7 @@ def self.respond(code, message, content_type = nil, body = '')
194194
}
195195
result = OctocatalogDiff::Integration.integration(opts)
196196
expect(result[:exitcode]).to eq(-1)
197-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
197+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
198198
expect(result[:exception].message).to match(/Failed ENC: Response from https:.+rspec-node.xyz.github.net was 403/)
199199
end
200200

@@ -212,7 +212,7 @@ def self.respond(code, message, content_type = nil, body = '')
212212
}
213213
result = OctocatalogDiff::Integration.integration(opts)
214214
expect(result[:exitcode]).to eq(-1)
215-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
215+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
216216
expect(result[:exception].message).to match(/Failed ENC: Response from https:.+rspec-node.xyz.github.net was 403/)
217217
end
218218

spec/octocatalog-diff/integration/preserve_environments_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative 'integration_helper'
44

5-
OctocatalogDiff::Spec.require_path('/cli/catalogs')
5+
OctocatalogDiff::Spec.require_path('/util/catalogs')
66

77
describe 'preserve environments integration' do
88
context 'without --preserve-environments set' do
@@ -22,8 +22,8 @@
2222
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
2323
end
2424

25-
it 'should raise OctocatalogDiff::Cli::Catalogs::CatalogError' do
26-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
25+
it 'should raise OctocatalogDiff::Util::Catalogs::CatalogError' do
26+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
2727
end
2828

2929
it 'should fail because ::bar could not be located' do
@@ -98,7 +98,7 @@
9898

9999
it 'should exit with error status due modules in production environment not being found' do
100100
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
101-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
101+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
102102
expect(@result.exception.message).to match(/Errno::ENOENT: No such file or directory - Environment directory/)
103103
end
104104
end
@@ -121,7 +121,7 @@
121121

122122
it 'should error on missing environment' do
123123
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
124-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
124+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
125125
expect(@result.exception.message).to match(%r{Environment directory .+/environments/fluffy does not exist})
126126
end
127127
end
@@ -208,7 +208,7 @@
208208

209209
it 'should error on missing site directory' do
210210
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
211-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
211+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
212212
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
213213
end
214214
end
@@ -231,7 +231,7 @@
231231

232232
it 'should error on missing module' do
233233
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
234-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
234+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
235235
expect(@result.exception.message).to match(/Could not find class (::)?foo/)
236236
end
237237
end
@@ -254,7 +254,7 @@
254254

255255
it 'should raise exception due to missing symlink request' do
256256
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
257-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
257+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
258258
expect(@result.exception.message).to match(%r{Catalog for 'from' \(origin/master\) failed.+ Errno::ENOENT})
259259
expect(@result.exception.message).to match(%r{Specified directory .+/preserve-environments/fluffy doesn't exist})
260260
end
@@ -303,7 +303,7 @@
303303

304304
it 'should error on missing site directory' do
305305
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
306-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
306+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
307307
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
308308
end
309309
end
@@ -326,7 +326,7 @@
326326

327327
it 'should error on missing site directory' do
328328
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
329-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
329+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
330330
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
331331
end
332332
end

spec/octocatalog-diff/integration/puppetdb_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
opts = { argv: ['-n', 'not-found-node.github.net'], spec_repo: 'tiny-repo' }
2323
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
2424
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
25-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
25+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
2626
expect(result[:exception].message).to match(/FactRetrievalError: Node not-found-node.github.net not found in PuppetDB/)
2727
end
2828
end
@@ -53,7 +53,7 @@
5353
opts = { argv: args, spec_repo: 'tiny-repo' }
5454
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
5555
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
56-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
56+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
5757
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
5858
end
5959

@@ -71,7 +71,7 @@
7171
opts = { argv: args, spec_repo: 'tiny-repo' }
7272
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
7373
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
74-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
74+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
7575
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
7676
end
7777
end
@@ -88,7 +88,7 @@
8888
it 'should fail to connect to authenticated puppetdb with no client cert', retry: 3 do
8989
opts = { argv: ['-n', 'rspec-node.github.net'], spec_repo: 'tiny-repo' }
9090
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
91-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
91+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
9292
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
9393
end
9494

@@ -127,7 +127,7 @@
127127
opts = { argv: arg, spec_repo: 'tiny-repo' }
128128
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
129129
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
130-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
130+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
131131
expect(result[:exception].message).to match(/OpenSSL::PKey::RSAError/)
132132
end
133133

@@ -140,7 +140,7 @@
140140
opts = { argv: arg, spec_repo: 'tiny-repo' }
141141
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
142142
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
143-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
143+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
144144
expect(result[:exception].message).to match(/OpenSSL::PKey::RSAError/)
145145
end
146146
end

spec/octocatalog-diff/integration/puppetmaster_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def self.response(method, uri, _headers, body)
157157
}
158158
result = OctocatalogDiff::Integration.integration(opts)
159159
expect(result[:exitcode]).to eq(-1)
160-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
160+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
161161
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
162162
end
163163

@@ -174,7 +174,7 @@ def self.response(method, uri, _headers, body)
174174
}
175175
result = OctocatalogDiff::Integration.integration(opts)
176176
expect(result[:exitcode]).to eq(-1)
177-
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
177+
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
178178
expect(result[:exception].message).to match(/foobaz.local: 404/)
179179
end
180180

0 commit comments

Comments
 (0)