Skip to content

Commit

Permalink
Merge pull request #312 from github/storeconfigs-backend
Browse files Browse the repository at this point in the history
Add ability to set storeconfig_backends
  • Loading branch information
jhongturney authored Sep 16, 2024
2 parents 7e9ac7e + 883c429 commit 14e49ca
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
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

0 comments on commit 14e49ca

Please sign in to comment.