Skip to content

Commit 5daa1e7

Browse files
author
Kevin Paulisse
committed
Move puppet version to puppet.sh
1 parent e9b1b37 commit 5daa1e7

4 files changed

Lines changed: 18 additions & 17 deletions

File tree

doc/advanced-script-override.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,4 @@ This is an explanation of the [existing scripts supplied by octocatalog-diff](/s
4848

4949
- [`puppet.sh`](/scripts/puppet)
5050

51-
Runs puppet (with additional command line arguments), generally used to compile a catalog.
52-
53-
- [`puppet-version.sh`](/scripts/puppet-version)
54-
55-
Runs `puppet --version` to determine the version of Puppet being used.
51+
Runs puppet (with additional command line arguments), generally used to compile a catalog or determine the Puppet version.

lib/octocatalog-diff/util/puppetversion.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ def self.puppet_version(puppet, options = {})
1818
raise ArgumentError, 'Puppet binary was not supplied' if puppet.nil?
1919
raise Errno::ENOENT, "Puppet binary #{puppet} doesn't exist" unless File.file?(puppet)
2020

21+
logger = options[:logger] || Logger.new(StringIO.new)
22+
2123
sr_opts = {
22-
logger: Logger.new(StringIO.new),
23-
default_script: 'puppet-version/puppet-version.sh',
24+
logger: logger,
25+
default_script: 'puppet/puppet.sh',
2426
override_script_path: options[:override_script_path]
2527
}
2628

@@ -29,6 +31,7 @@ def self.puppet_version(puppet, options = {})
2931
sr_run_opts = {
3032
:working_dir => File.dirname(puppet),
3133
:pass_env_vars => options[:pass_env_vars],
34+
:argv => '--version',
3235
'OCD_PUPPET_BINARY' => puppet
3336
}
3437

scripts/puppet-version/puppet-version.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

scripts/puppet/puppet.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Script to run Puppet. The default implementation here is simply to pass
4+
# through the command line arguments (which are likely to be numerous when
5+
# compiling a catalog).
6+
7+
if [ -z "$OCD_PUPPET_BINARY" ]; then
8+
echo "Error: PUPPET_BINARY must be set"
9+
exit 255
10+
fi
11+
12+
"$OCD_PUPPET_BINARY" "$@"

0 commit comments

Comments
 (0)