Class: OctocatalogDiff::Util::PuppetVersion
- Inherits:
-
Object
- Object
- OctocatalogDiff::Util::PuppetVersion
- Defined in:
- lib/octocatalog-diff/util/puppetversion.rb
Overview
This is a utility class to determine the version of Puppet.
Class Method Summary collapse
-
.puppet_version(puppet, options = {}) ⇒ String
Determine the version of Puppet.
Class Method Details
.puppet_version(puppet, options = {}) ⇒ String
Determine the version of Puppet.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/octocatalog-diff/util/puppetversion.rb', line 15 def self.puppet_version(puppet, = {}) raise ArgumentError, 'Puppet binary was not supplied' if puppet.nil? raise Errno::ENOENT, "Puppet binary #{puppet} doesn't exist" unless File.file?(puppet) sr_opts = { default_script: 'puppet/puppet.sh', override_script_path: [:override_script_path] } script = OctocatalogDiff::Util::ScriptRunner.new(sr_opts) sr_run_opts = { :logger => [:logger], :working_dir => File.dirname(puppet), :pass_env_vars => [:pass_env_vars], :argv => '--version', 'OCD_PUPPET_BINARY' => puppet } output = script.run(sr_run_opts) return Regexp.last_match(1) if output =~ /^([\d\.]+)\s*$/ # :nocov: raise "Unable to determine Puppet version: #{script.output}" # :nocov: end |