Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/octocatalog-diff/catalog-util/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def self.bootstrap_directory_parallelizer(options, logger)
end

# Performs the actual bootstrap of a directory. Intended to be called by bootstrap_directory_parallelizer
# above, or as part of the parallelized catalog build process from cli/catalogs.
# above, or as part of the parallelized catalog build process from util/catalogs.
# @param logger [Logger] Logger object
# @param dir_opts [Hash] Directory options: branch, path, tag
def self.bootstrap_directory(options, logger)
Expand Down
4 changes: 2 additions & 2 deletions lib/octocatalog-diff/catalog-util/cached_master_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative 'bootstrap'
require_relative 'git'
require_relative '../cli/catalogs'
require_relative '../util/catalogs'

require 'fileutils'

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

logger.debug 'Begin bootstrap cached master directory'
catalogs_obj = OctocatalogDiff::Cli::Catalogs.new(fake_options, logger)
catalogs_obj = OctocatalogDiff::Util::Catalogs.new(fake_options, logger)
catalogs_obj.bootstrap_then_exit
logger.debug 'Success bootstrap cached master directory'

Expand Down
8 changes: 4 additions & 4 deletions lib/octocatalog-diff/cli.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

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

# Compile catalogs
Expand Down Expand Up @@ -181,7 +181,7 @@ def self.catalog_only(logger, options)
from_catalog: '-', # Prevents a compile
to_catalog: nil, # Forces a compile
)
cat_obj = OctocatalogDiff::Cli::Catalogs.new(catalog_opts, logger)
cat_obj = OctocatalogDiff::Util::Catalogs.new(catalog_opts, logger)
catalogs = cat_obj.catalogs

# If the catalog compilation failed, an exception would have been thrown. So if
Expand All @@ -201,7 +201,7 @@ def self.catalog_only(logger, options)
def self.bootstrap_then_exit(logger, catalogs_obj)
catalogs_obj.bootstrap_then_exit
return EXITCODE_SUCCESS_NO_DIFFS
rescue OctocatalogDiff::Cli::Catalogs::BootstrapError => exc
rescue OctocatalogDiff::Util::Catalogs::BootstrapError => exc
logger.fatal("--bootstrap-then-exit error: bootstrap failed (#{exc})")
return EXITCODE_FAILURE
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
require 'yaml'
require_relative '../catalog-util/bootstrap' # For BootstrapError
require_relative '../catalog'
require_relative '../util/parallel'
require_relative 'parallel'

module OctocatalogDiff
class Cli
module Util
# Helper class to construct catalogs, performing all necessary steps such as
# bootstrapping directories, installing facts, and running puppet.
class Catalogs
Expand Down
10 changes: 5 additions & 5 deletions spec/octocatalog-diff/integration/catalog_compute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative 'integration_helper'

require OctocatalogDiff::Spec.require_path('/cli/catalogs')
require OctocatalogDiff::Spec.require_path('/util/catalogs')
require OctocatalogDiff::Spec.require_path('/catalog')
require OctocatalogDiff::Spec.require_path('/facts')

Expand Down Expand Up @@ -48,7 +48,7 @@
if @has_git && @has_tar && @has_bash
options = @default_options.merge(enc: 'environments/production/config/enc.sh')
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
result = testobj.catalogs
@to = result[:to]
@from = result[:from]
Expand Down Expand Up @@ -111,7 +111,7 @@
if @has_git && @has_tar
options = @default_options.dup
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
result = testobj.catalogs
@to = result[:to]
@from = result[:from]
Expand Down Expand Up @@ -175,7 +175,7 @@
options = @default_options.merge(hiera_config: 'environments/production/config/hiera.yaml',
hiera_path_strip: '/var/lib/puppet')
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
result = testobj.catalogs
@to = result[:to]
@from = result[:from]
Expand Down Expand Up @@ -257,7 +257,7 @@
to_env: '.'
)
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
testobj = OctocatalogDiff::Cli::Catalogs.new(options, logger)
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
result = testobj.catalogs
@to = result[:to]
@from = result[:from]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
]
)
expect(result[:exitcode]).to eq(-1)
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
expect(result[:exception].message).to match(/failed to compile with Errno::ENOENT/)
expect(result[:exception].message).to match(%r{Unable to resolve 'puppet:///modules/test/foo-new'})
end
Expand Down
6 changes: 3 additions & 3 deletions spec/octocatalog-diff/integration/pe_enc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def self.respond(code, message, content_type = nil, body = '')
}
result = OctocatalogDiff::Integration.integration(opts)
expect(result[:exitcode]).to eq(-1)
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
end

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

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

Expand Down
20 changes: 10 additions & 10 deletions spec/octocatalog-diff/integration/preserve_environments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative 'integration_helper'

OctocatalogDiff::Spec.require_path('/cli/catalogs')
OctocatalogDiff::Spec.require_path('/util/catalogs')

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

it 'should raise OctocatalogDiff::Cli::Catalogs::CatalogError' do
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
it 'should raise OctocatalogDiff::Util::Catalogs::CatalogError' do
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
end

it 'should fail because ::bar could not be located' do
Expand Down Expand Up @@ -98,7 +98,7 @@

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

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

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

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

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

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

it 'should error on missing site directory' do
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Cli::Catalogs::CatalogError)
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Util::Catalogs::CatalogError)
expect(@result.exception.message).to match(/Could not find class (::)?sitetest/)
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/octocatalog-diff/integration/puppetdb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
opts = { argv: ['-n', 'not-found-node.github.net'], spec_repo: 'tiny-repo' }
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
expect(result[:exception].message).to match(/FactRetrievalError: Node not-found-node.github.net not found in PuppetDB/)
end
end
Expand Down Expand Up @@ -53,7 +53,7 @@
opts = { argv: args, spec_repo: 'tiny-repo' }
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
end

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

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

Expand All @@ -140,7 +140,7 @@
opts = { argv: arg, spec_repo: 'tiny-repo' }
result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts)
expect(result[:exitcode]).to eq(-1), OctocatalogDiff::Integration.format_exception(result)
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
expect(result[:exception].message).to match(/OpenSSL::PKey::RSAError/)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/octocatalog-diff/integration/puppetmaster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def self.response(method, uri, _headers, body)
}
result = OctocatalogDiff::Integration.integration(opts)
expect(result[:exitcode]).to eq(-1)
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Cli::Catalogs::CatalogError')
expect(result[:exception].class.to_s).to eq('OctocatalogDiff::Util::Catalogs::CatalogError')
expect(result[:exception].message).to match(/OpenSSL::SSL::SSLError/)
end

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

Expand Down
14 changes: 7 additions & 7 deletions spec/octocatalog-diff/tests/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
before(:each) do
catalog_json = File.read(OctocatalogDiff::Spec.fixture_path('catalogs/tiny-catalog.json'))
catalogs = { to: OctocatalogDiff::Catalog.new(json: catalog_json) }
d = double('OctocatalogDiff::Cli::Catalogs')
allow(OctocatalogDiff::Cli::Catalogs).to receive(:new).and_return(d)
d = double('OctocatalogDiff::Util::Catalogs')
allow(OctocatalogDiff::Util::Catalogs).to receive(:new).and_return(d)
allow(d).to receive(:catalogs).and_return(catalogs)
logger, @logger_str = OctocatalogDiff::Spec.setup_logger
@tmpdir = Dir.mktmpdir
Expand All @@ -222,8 +222,8 @@
it 'should output to STDOUT and exit' do
catalog_json = File.read(OctocatalogDiff::Spec.fixture_path('catalogs/tiny-catalog.json'))
catalogs = { to: OctocatalogDiff::Catalog.new(json: catalog_json) }
d = double('OctocatalogDiff::Cli::Catalogs')
allow(OctocatalogDiff::Cli::Catalogs).to receive(:new).and_return(d)
d = double('OctocatalogDiff::Util::Catalogs')
allow(OctocatalogDiff::Util::Catalogs).to receive(:new).and_return(d)
allow(d).to receive(:catalogs).and_return(catalogs)
logger, logger_str = OctocatalogDiff::Spec.setup_logger
rexp = Regexp.new('"document_type": "Catalog"')
Expand All @@ -236,7 +236,7 @@

describe '#bootstrap_then_exit' do
it 'should succeed and exit 0' do
d = double('OctocatalogDiff::Cli::Catalogs')
d = double('OctocatalogDiff::Util::Catalogs')
allow(d).to receive(:bootstrap_then_exit)
logger, logger_str = OctocatalogDiff::Spec.setup_logger
rc = OctocatalogDiff::Cli.bootstrap_then_exit(logger, d)
Expand All @@ -245,8 +245,8 @@
end

it 'should fail and exit 1 if BootstrapError occurs' do
d = double('OctocatalogDiff::Cli::Catalogs')
allow(d).to receive(:bootstrap_then_exit).and_raise(OctocatalogDiff::Cli::Catalogs::BootstrapError, 'hello')
d = double('OctocatalogDiff::Util::Catalogs')
allow(d).to receive(:bootstrap_then_exit).and_raise(OctocatalogDiff::Util::Catalogs::BootstrapError, 'hello')
logger, logger_str = OctocatalogDiff::Spec.setup_logger
rc = OctocatalogDiff::Cli.bootstrap_then_exit(logger, d)
expect(rc).to eq(1)
Expand Down
Loading