@@ -30,6 +30,7 @@ def initialize(options)
30
30
super
31
31
32
32
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 ]
33
34
34
35
# Additional class variables
35
36
@pass_env_vars = options . fetch ( :pass_env_vars , [ ] )
@@ -41,17 +42,13 @@ def initialize(options)
41
42
@retries = nil
42
43
@builddir = nil
43
44
@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 ]
48
45
end
49
46
50
47
# Get the Puppet version
51
48
# @return [String] Puppet version
52
49
def puppet_version
53
50
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 )
55
52
end
56
53
57
54
# Compilation directory
@@ -63,7 +60,7 @@ def compilation_dir
63
60
64
61
# Environment used to compile catalog
65
62
def environment
66
- @opts . fetch ( :environment , 'production' )
63
+ @options . fetch ( :environment , 'production' )
67
64
end
68
65
69
66
# Convert file source => ... to content => ... if a basedir is given.
@@ -97,29 +94,29 @@ def bootstrap(logger)
97
94
return if @builddir
98
95
99
96
# Fill options for creating and populating the temporary directory
100
- tmphash = @opts . dup
97
+ tmphash = @options . dup
101
98
102
99
# 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 ]
108
105
tmphash [ :basedir ] = Dir . mktmpdir
109
106
at_exit { cleanup_checkout_dir ( tmphash [ :basedir ] , logger ) }
110
107
111
- FileUtils . cp_r File . join ( @opts [ :basedir ] , '.' ) , tmphash [ :basedir ]
108
+ FileUtils . cp_r File . join ( @options [ :basedir ] , '.' ) , tmphash [ :basedir ]
112
109
113
- o = @opts . reject { |k , _v | k == :branch } . merge ( path : tmphash [ :basedir ] )
110
+ o = @options . reject { |k , _v | k == :branch } . merge ( path : tmphash [ :basedir ] )
114
111
OctocatalogDiff ::CatalogUtil ::Bootstrap . bootstrap_directory ( o , logger )
115
112
else
116
- tmphash [ :basedir ] = @opts [ :basedir ]
113
+ tmphash [ :basedir ] = @options [ :basedir ]
117
114
end
118
115
else
119
116
checkout_dir = Dir . mktmpdir
120
117
at_exit { cleanup_checkout_dir ( checkout_dir , logger ) }
121
118
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 )
123
120
end
124
121
125
122
# Create and populate the temporary directory
@@ -130,9 +127,9 @@ def bootstrap(logger)
130
127
# @param logger [Logger] Logger object
131
128
def build_catalog ( logger )
132
129
if @facts_terminus != 'facter'
133
- facts_obj = OctocatalogDiff ::CatalogUtil ::Facts . new ( @opts , logger )
130
+ facts_obj = OctocatalogDiff ::CatalogUtil ::Facts . new ( @options , logger )
134
131
logger . debug "Start retrieving facts for #{ @node } from #{ self . class } "
135
- @opts [ :facts ] = facts_obj . facts
132
+ @options [ :facts ] = facts_obj . facts
136
133
logger . debug "Success retrieving facts for #{ @node } from #{ self . class } "
137
134
end
138
135
@@ -166,10 +163,10 @@ def puppet_command_obj
166
163
@puppet_command_obj ||= begin
167
164
raise ArgumentError , '"puppet_binary" was not passed to OctocatalogDiff::Catalog::Computed' unless @puppet_binary
168
165
169
- command_opts = @opts . merge (
166
+ command_opts = @options . merge (
170
167
node : @node ,
171
168
compilation_dir : @builddir . tempdir ,
172
- parser : @opts . fetch ( :parser , :default ) ,
169
+ parser : @options . fetch ( :parser , :default ) ,
173
170
puppet_binary : @puppet_binary ,
174
171
fact_file : @builddir . fact_file ,
175
172
dir : @builddir . tempdir ,
@@ -199,7 +196,7 @@ def exec_puppet(logger)
199
196
# Set up the ScriptRunner
200
197
scriptrunner = OctocatalogDiff ::Util ::ScriptRunner . new (
201
198
default_script : 'puppet/puppet.sh' ,
202
- override_script_path : @opts [ :override_script_path ]
199
+ override_script_path : @options [ :override_script_path ]
203
200
)
204
201
205
202
begin
0 commit comments