Skip to content

Commit 14e49ca

Browse files
authored
Merge pull request #312 from github/storeconfigs-backend
Add ability to set storeconfig_backends
2 parents 7e9ac7e + 883c429 commit 14e49ca

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

examples/octocatalog-diff.cfg.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ def self.config
163163

164164
settings[:storeconfigs] = false
165165

166+
##############################################################################################
167+
# storeconfigs_backend
168+
# Override the default `storeconfigs` backend of `puppetdb`
169+
# valid options include `puppetdb`, `yaml`, `json`
170+
##############################################################################################
171+
172+
settings[:storeconfigs_backend] = 'puppetdb'
173+
166174
##############################################################################################
167175
# bootstrap_script
168176
# When you check out your Puppet repository, do you need to run a script to prepare that

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ def setup
7272

7373
# storeconfigs?
7474
if @options[:storeconfigs]
75-
cmdline.concat %w(--storeconfigs --storeconfigs_backend=puppetdb)
75+
if @options[:storeconfigs_backend]
76+
cmdline << '--storeconfigs'
77+
cmdline << "--storeconfigs_backend=#{Shellwords.escape(@options[:storeconfigs_backend])}"
78+
else
79+
cmdline.concat %w(--storeconfigs --storeconfigs_backend=puppetdb)
80+
end
7681
else
7782
cmdline << '--no-storeconfigs'
7883
end

lib/octocatalog-diff/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Cli
4343
compare_file_text: true,
4444
display_datatype_changes: true,
4545
parallel: true,
46+
storeconfigs_backend: 'puppetdb',
4647
suppress_absent_file_details: true,
4748
hiera_path: 'hieradata',
4849
use_lcs: true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
# Set storeconfigs (integration with PuppetDB for collected resources)
4+
# @param parser [OptionParser object] The OptionParser argument
5+
# @param options [Hash] Options hash being constructed; this is modified in this method.
6+
OctocatalogDiff::Cli::Options::Option.newoption(:storeconfigs) do
7+
has_weight 220
8+
9+
def parse(parser, options)
10+
parser.on('--storeconfigs-backend TERMINUS', 'Set the terminus used for storeconfigs') do |x|
11+
options[:storeconfigs_backend] = x
12+
end
13+
end
14+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../options_helper'
4+
5+
describe OctocatalogDiff::Cli::Options do
6+
describe '#opt_storeconfigs_backend' do
7+
it 'should accept all valid arguments' do
8+
result = run_optparse(['--storeconfigs-backend', 'puppetdb'])
9+
expect(result[:storeconfigs_backend]).to eq('puppetdb')
10+
end
11+
end
12+
end

spec/octocatalog-diff/tests/cli_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
colors: true,
3232
debug: false,
3333
quiet: false,
34+
storeconfigs_backend: 'puppetdb',
3435
format: :color_text,
3536
display_source_file_line: false,
3637
compare_file_text: true,

0 commit comments

Comments
 (0)