Skip to content

Add ability to set storeconfig_backends #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 16, 2024
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
8 changes: 8 additions & 0 deletions examples/octocatalog-diff.cfg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ def self.config

settings[:storeconfigs] = false

##############################################################################################
# storeconfigs_backend
# Override the default `storeconfigs` backend of `puppetdb`
# valid options include `puppetdb`, `yaml`, `json`
##############################################################################################

settings[:storeconfigs_backend] = 'puppetdb'

##############################################################################################
# bootstrap_script
# When you check out your Puppet repository, do you need to run a script to prepare that
Expand Down
7 changes: 6 additions & 1 deletion lib/octocatalog-diff/catalog-util/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ def setup

# storeconfigs?
if @options[:storeconfigs]
cmdline.concat %w(--storeconfigs --storeconfigs_backend=puppetdb)
if @options[:storeconfigs_backend]
cmdline << '--storeconfigs'
cmdline << "--storeconfigs_backend=#{Shellwords.escape(@options[:storeconfigs_backend])}"
else
cmdline.concat %w(--storeconfigs --storeconfigs_backend=puppetdb)
end
else
cmdline << '--no-storeconfigs'
end
Expand Down
1 change: 1 addition & 0 deletions lib/octocatalog-diff/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Cli
compare_file_text: true,
display_datatype_changes: true,
parallel: true,
storeconfigs_backend: 'puppetdb',
suppress_absent_file_details: true,
hiera_path: 'hieradata',
use_lcs: true
Expand Down
14 changes: 14 additions & 0 deletions lib/octocatalog-diff/cli/options/storeconfigs_backend.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# Set storeconfigs (integration with PuppetDB for collected resources)
# @param parser [OptionParser object] The OptionParser argument
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:storeconfigs) do
has_weight 220

def parse(parser, options)
parser.on('--storeconfigs-backend TERMINUS', 'Set the terminus used for storeconfigs') do |x|
options[:storeconfigs_backend] = x
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require_relative '../options_helper'

describe OctocatalogDiff::Cli::Options do
describe '#opt_storeconfigs_backend' do
it 'should accept all valid arguments' do
result = run_optparse(['--storeconfigs-backend', 'puppetdb'])
expect(result[:storeconfigs_backend]).to eq('puppetdb')
end
end
end
1 change: 1 addition & 0 deletions spec/octocatalog-diff/tests/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
colors: true,
debug: false,
quiet: false,
storeconfigs_backend: 'puppetdb',
format: :color_text,
display_source_file_line: false,
compare_file_text: true,
Expand Down
Loading