@@ -30,6 +30,7 @@ def initialize(options)
3030 super
3131
3232 raise ArgumentError , 'Node name must be passed to OctocatalogDiff::Catalog::Computed' unless options [ :node ] . is_a? ( String )
33+ raise ArgumentError , 'Branch is undefined' unless options [ :branch ]
3334
3435 # Additional class variables
3536 @pass_env_vars = options . fetch ( :pass_env_vars , [ ] )
@@ -41,17 +42,13 @@ def initialize(options)
4142 @retries = nil
4243 @builddir = nil
4344 @facts_terminus = options . fetch ( :facts_terminus , 'yaml' )
44-
45- # Pass through the input for other access
46- @opts = options
47- raise ArgumentError , 'Branch is undefined' unless @opts [ :branch ]
4845 end
4946
5047 # Get the Puppet version
5148 # @return [String] Puppet version
5249 def puppet_version
5350 raise ArgumentError , '"puppet_binary" was not passed to OctocatalogDiff::Catalog::Computed' unless @puppet_binary
54- @puppet_version ||= OctocatalogDiff ::Util ::PuppetVersion . puppet_version ( @puppet_binary , @opts )
51+ @puppet_version ||= OctocatalogDiff ::Util ::PuppetVersion . puppet_version ( @puppet_binary , @options )
5552 end
5653
5754 # Compilation directory
@@ -63,7 +60,7 @@ def compilation_dir
6360
6461 # Environment used to compile catalog
6562 def environment
66- @opts . fetch ( :environment , 'production' )
63+ @options . fetch ( :environment , 'production' )
6764 end
6865
6966 # Convert file source => ... to content => ... if a basedir is given.
@@ -97,29 +94,29 @@ def bootstrap(logger)
9794 return if @builddir
9895
9996 # Fill options for creating and populating the temporary directory
100- tmphash = @opts . dup
97+ tmphash = @options . dup
10198
10299 # Bootstrap directory if needed
103- if !@opts [ :bootstrapped_dir ] . nil?
104- raise Errno ::ENOENT , "Invalid dir #{ @opts [ :bootstrapped_dir ] } " unless File . directory? ( @opts [ :bootstrapped_dir ] )
105- tmphash [ :basedir ] = @opts [ :bootstrapped_dir ]
106- elsif @opts [ :branch ] == '.'
107- if @opts [ :bootstrap_current ]
100+ if !@options [ :bootstrapped_dir ] . nil?
101+ raise Errno ::ENOENT , "Invalid dir #{ @options [ :bootstrapped_dir ] } " unless File . directory? ( @options [ :bootstrapped_dir ] )
102+ tmphash [ :basedir ] = @options [ :bootstrapped_dir ]
103+ elsif @options [ :branch ] == '.'
104+ if @options [ :bootstrap_current ]
108105 tmphash [ :basedir ] = Dir . mktmpdir
109106 at_exit { cleanup_checkout_dir ( tmphash [ :basedir ] , logger ) }
110107
111- FileUtils . cp_r File . join ( @opts [ :basedir ] , '.' ) , tmphash [ :basedir ]
108+ FileUtils . cp_r File . join ( @options [ :basedir ] , '.' ) , tmphash [ :basedir ]
112109
113- o = @opts . reject { |k , _v | k == :branch } . merge ( path : tmphash [ :basedir ] )
110+ o = @options . reject { |k , _v | k == :branch } . merge ( path : tmphash [ :basedir ] )
114111 OctocatalogDiff ::CatalogUtil ::Bootstrap . bootstrap_directory ( o , logger )
115112 else
116- tmphash [ :basedir ] = @opts [ :basedir ]
113+ tmphash [ :basedir ] = @options [ :basedir ]
117114 end
118115 else
119116 checkout_dir = Dir . mktmpdir
120117 at_exit { cleanup_checkout_dir ( checkout_dir , logger ) }
121118 tmphash [ :basedir ] = checkout_dir
122- OctocatalogDiff ::CatalogUtil ::Bootstrap . bootstrap_directory ( @opts . merge ( path : checkout_dir ) , logger )
119+ OctocatalogDiff ::CatalogUtil ::Bootstrap . bootstrap_directory ( @options . merge ( path : checkout_dir ) , logger )
123120 end
124121
125122 # Create and populate the temporary directory
@@ -130,9 +127,9 @@ def bootstrap(logger)
130127 # @param logger [Logger] Logger object
131128 def build_catalog ( logger )
132129 if @facts_terminus != 'facter'
133- facts_obj = OctocatalogDiff ::CatalogUtil ::Facts . new ( @opts , logger )
130+ facts_obj = OctocatalogDiff ::CatalogUtil ::Facts . new ( @options , logger )
134131 logger . debug "Start retrieving facts for #{ @node } from #{ self . class } "
135- @opts [ :facts ] = facts_obj . facts
132+ @options [ :facts ] = facts_obj . facts
136133 logger . debug "Success retrieving facts for #{ @node } from #{ self . class } "
137134 end
138135
@@ -166,10 +163,10 @@ def puppet_command_obj
166163 @puppet_command_obj ||= begin
167164 raise ArgumentError , '"puppet_binary" was not passed to OctocatalogDiff::Catalog::Computed' unless @puppet_binary
168165
169- command_opts = @opts . merge (
166+ command_opts = @options . merge (
170167 node : @node ,
171168 compilation_dir : @builddir . tempdir ,
172- parser : @opts . fetch ( :parser , :default ) ,
169+ parser : @options . fetch ( :parser , :default ) ,
173170 puppet_binary : @puppet_binary ,
174171 fact_file : @builddir . fact_file ,
175172 dir : @builddir . tempdir ,
@@ -199,7 +196,7 @@ def exec_puppet(logger)
199196 # Set up the ScriptRunner
200197 scriptrunner = OctocatalogDiff ::Util ::ScriptRunner . new (
201198 default_script : 'puppet/puppet.sh' ,
202- override_script_path : @opts [ :override_script_path ]
199+ override_script_path : @options [ :override_script_path ]
203200 )
204201
205202 begin
0 commit comments