knife-spork 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'knife-spork'
16
- s.version = '0.1.9'
17
- s.date = '2012-04-03'
16
+ s.version = '0.1.10'
17
+ s.date = '2012-04-12'
18
18
  s.rubyforge_project = 'knife-spork'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
42
42
  ## that are needed for an end user to actually USE your code.
43
43
  s.add_dependency('chef', [">= 0.10.4"])
44
44
  s.add_dependency('git', [">= 1.2.5"])
45
- s.add_dependency('app_conf', [">= 0.3.0"])
45
+ s.add_dependency('app_conf', [">= 0.4.0"])
46
46
 
47
47
  ## Leave this section as-is. It will be automatically generated from the
48
48
  ## contents of your Git repository via the gemspec task. DO NOT REMOVE
@@ -36,26 +36,26 @@ module KnifeSpork
36
36
 
37
37
  self.config = Chef::Config.merge!(config)
38
38
 
39
+ @conf = AppConf.new
40
+
39
41
  if File.exists?("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
40
- AppConf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
42
+ @conf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
41
43
  ui.msg "Loaded config file #{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml...\n\n"
42
44
  end
43
45
 
44
46
  if File.exists?("/etc/spork-config.yml")
45
- AppConf.load("/etc/spork-config.yml")
47
+ @conf.load("/etc/spork-config.yml")
46
48
  ui.msg "Loaded config file /etc/spork-config.yml...\n\n"
47
49
  end
48
50
 
49
51
  if File.exists?(File.expand_path("~/.chef/spork-config.yml"))
50
- AppConf.load(File.expand_path("~/.chef/spork-config.yml"))
52
+ @conf.load(File.expand_path("~/.chef/spork-config.yml"))
51
53
  ui.msg "Loaded config file #{File.expand_path("~/.chef/spork-config.yml")}...\n\n"
52
54
  end
53
55
 
54
56
  bump_type=""
55
57
 
56
- if config.has_key?(:cookbook_path)
57
- cookbook_path = config["cookbook_path"]
58
- else
58
+ if !config.has_key?(:cookbook_path)
59
59
  ui.fatal "No default cookbook_path; Specify with -o or fix your knife.rb."
60
60
  show_usage
61
61
  exit 1
@@ -84,26 +84,25 @@ module KnifeSpork
84
84
  exit 1
85
85
  end
86
86
 
87
- if !AppConf.git.nil? && AppConf.git.enabled
87
+ cookbook = name_args.first
88
+ cookbook_path = cookbook_repo[cookbook].root_dir.gsub("#{cookbook}","")
89
+
90
+ if !@conf.git.nil? && @conf.git.enabled
88
91
  if !@@gitavail
89
92
  ui.msg "Git gem not available, skipping git pull.\n\n"
90
93
  else
91
- git_pull_if_repo
94
+ git_pull_if_repo([cookbook_path])
92
95
  end
93
96
  end
94
97
 
95
98
  if bump_type == "manual"
96
99
  manual_version = name_args.last
97
- cookbook = name_args.first
98
- cookbook_path = Array(config[:cookbook_path]).first
99
100
  patch_manual(cookbook_path, cookbook, manual_version)
100
101
  else
101
- cookbook = name_args.first
102
- cookbook_path = Array(config[:cookbook_path]).first
103
102
  patch(cookbook_path, cookbook, bump_type)
104
103
  end
105
104
 
106
- if !AppConf.git.nil? && AppConf.git.enabled
105
+ if !@conf.git.nil? && @conf.git.enabled
107
106
  if !@@gitavail
108
107
  ui.msg "Git gem not available, skipping git add.\n\n"
109
108
  else
@@ -112,6 +111,13 @@ module KnifeSpork
112
111
  end
113
112
  end
114
113
 
114
+ def cookbook_repo
115
+ @cookbook_loader ||= begin
116
+ Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, config[:cookbook_path]) }
117
+ Chef::CookbookLoader.new(config[:cookbook_path])
118
+ end
119
+ end
120
+
115
121
  def patch(cookbook_path, cookbook, type)
116
122
  t = TYPE_INDEX[type]
117
123
  current_version = get_version(cookbook_path, cookbook).split(".").map{|i| i.to_i}
@@ -164,60 +170,51 @@ module KnifeSpork
164
170
  def git_add(cookbook)
165
171
  strio = StringIO.new
166
172
  l = Logger.new strio
167
- cookbook_path = config[:cookbook_path]
168
- if cookbook_path.size > 1
169
- ui.warn "It looks like you have multiple cookbook paths defined so I can't tell if you're running inside a git repo.\n\n"
170
- else
171
- begin
172
- path = cookbook_path[0].gsub("cookbooks","")
173
- ui.msg "Opening git repo #{path}\n\n"
174
- g = Git.open(path, :log => Logger.new(strio))
175
- ui.msg "Git add'ing #{path}cookbooks/#{cookbook}/metadata.rb\n\n"
176
- g.add("#{path}cookbooks/#{cookbook}/metadata.rb")
177
- rescue ArgumentError => e
178
- ui.warn "Git: The root of your chef repo doesn't look like it's a git repo. Skipping git add...\n\n"
179
- rescue
180
- ui.warn "Git: Cookbook bump succeeded, but something went wrong with git add metadata.rb, so you'll want to manually git add it. Dumping log info..."
181
- ui.warn "#{strio.string}"
182
- end
173
+ cookbook_path = cookbook_repo[cookbook].root_dir.gsub("#{cookbook}","")
174
+ begin
175
+ path = cookbook_path.gsub("/site-cookbooks","").gsub("/cookbooks","")
176
+ ui.msg "Opening git repo #{path}\n\n"
177
+ g = Git.open(path, :log => Logger.new(strio))
178
+ ui.msg "Git add'ing #{cookbook_path}#{cookbook}/metadata.rb\n\n"
179
+ g.add("#{cookbook_path}/#{cookbook}/metadata.rb")
180
+ rescue ArgumentError => e
181
+ ui.warn "Git: The root of your chef repo doesn't look like it's a git repo. Skipping git add...\n\n"
182
+ rescue
183
+ ui.warn "Git: Cookbook bump succeeded, but something went wrong with git add metadata.rb, so you'll want to manually git add it. Dumping log info..."
184
+ ui.warn "#{strio.string}"
183
185
  end
184
186
  end
185
187
 
186
- def git_pull_if_repo
188
+ def git_pull_if_repo(cookbook_path)
187
189
  strio = StringIO.new
188
190
  l = Logger.new strio
189
- cookbook_path = config[:cookbook_path]
190
- if cookbook_path.size > 1
191
- ui.warn "It looks like you have multiple cookbook paths defined so I can't tell if you're running inside a git repo.\n\n"
192
- else
193
- begin
194
- path = cookbook_path[0].gsub("/cookbooks","")
195
- ui.msg "Opening git repo #{path}\n\n"
196
- g = Git.open(path, :log => Logger.new(strio))
197
- ui.msg "Pulling latest changes from git\n\n"
198
- output = IO.popen ("cd #{path} && git pull 2>&1")
199
- Process.wait
200
- exit_code = $?
201
- if exit_code.exitstatus == 0
202
- ui.msg "#{output.read()}\n"
203
- else
204
- ui.error "#{output.read()}\n"
205
- exit 1
206
- end
207
-
208
- ui.msg "Pulling latest changes from git submodules (if any)\n\n"
209
- output = IO.popen ("cd #{path} && git submodule foreach git pull 2>&1")
210
- Process.wait
211
- exit_code = $?
212
- if exit_code.exitstatus == 0
213
- ui.msg "#{output.read()}\n"
214
- else
215
- ui.error "#{output.read()}\n"
216
- exit 1
217
- end
218
- rescue ArgumentError => e
219
- ui.warn "Git: The root of your chef repo doesn't look like it's a git repo. Skipping git pull...\n\n"
191
+ begin
192
+ path = cookbook_path[0].gsub("/site-cookbooks","").gsub("/cookbooks","")
193
+ ui.msg "Opening git repo #{path}\n\n"
194
+ g = Git.open(path, :log => Logger.new(strio))
195
+ ui.msg "Pulling latest changes from git\n\n"
196
+ output = IO.popen ("cd #{path} && git pull 2>&1")
197
+ Process.wait
198
+ exit_code = $?
199
+ if exit_code.exitstatus == 0
200
+ ui.msg "#{output.read()}\n"
201
+ else
202
+ ui.error "#{output.read()}\n"
203
+ exit 1
204
+ end
205
+
206
+ ui.msg "Pulling latest changes from git submodules (if any)\n\n"
207
+ output = IO.popen ("cd #{path} && git submodule foreach git pull 2>&1")
208
+ Process.wait
209
+ exit_code = $?
210
+ if exit_code.exitstatus == 0
211
+ ui.msg "#{output.read()}\n"
212
+ else
213
+ ui.error "#{output.read()}\n"
214
+ exit 1
220
215
  end
216
+ rescue ArgumentError => e
217
+ ui.warn "Git: #{cookbook_path.join} doesn't look like it's a git repo. Skipping git pull...\n\n"
221
218
  end
222
219
  end
223
220
  end
@@ -32,19 +32,20 @@ module KnifeSpork
32
32
  end
33
33
 
34
34
  self.config = Chef::Config.merge!(config)
35
-
35
+ @conf = AppConf.new
36
+
36
37
  if File.exists?("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
37
- AppConf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
38
+ @conf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
38
39
  ui.msg "Loaded config file #{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml...\n\n"
39
40
  end
40
41
 
41
42
  if File.exists?("/etc/spork-config.yml")
42
- AppConf.load("/etc/spork-config.yml")
43
+ @conf.load("/etc/spork-config.yml")
43
44
  ui.msg "Loaded config file /etc/spork-config.yml...\n\n"
44
45
  end
45
46
 
46
47
  if File.exists?(File.expand_path("~/.chef/spork-config.yml"))
47
- AppConf.load(File.expand_path("~/.chef/spork-config.yml"))
48
+ @conf.load(File.expand_path("~/.chef/spork-config.yml"))
48
49
  ui.msg "Loaded config file #{File.expand_path("~/.chef/spork-config.yml")}...\n\n"
49
50
  end
50
51
 
@@ -68,15 +69,13 @@ module KnifeSpork
68
69
  end
69
70
 
70
71
  cookbook = name_args.first
71
- cookbook_path = Array(config[:cookbook_path]).first
72
-
72
+ cookbook_path = config[:cookbook_path]
73
73
  local_version = get_local_cookbook_version(cookbook_path, cookbook)
74
74
  remote_versions = get_remote_cookbook_versions(cookbook)
75
75
 
76
76
  check_versions(cookbook, local_version, remote_versions)
77
77
  end
78
78
 
79
-
80
79
  def get_local_cookbook_version(cookbook_path, cookbook)
81
80
  current_version = get_version(cookbook_path, cookbook).split(".").map{|i| i.to_i}
82
81
  metadata_file = File.join(cookbook_path, cookbook, "metadata.rb")
@@ -66,39 +66,40 @@ module KnifeSpork
66
66
  end
67
67
 
68
68
  self.config = Chef::Config.merge!(config)
69
-
69
+ @conf = AppConf.new
70
+
70
71
  if File.exists?("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
71
- AppConf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
72
+ @conf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
72
73
  ui.msg "Loaded config file #{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml...\n\n"
73
74
  end
74
75
 
75
76
  if File.exists?("/etc/spork-config.yml")
76
- AppConf.load("/etc/spork-config.yml")
77
+ @conf.load("/etc/spork-config.yml")
77
78
  ui.msg "Loaded config file /etc/spork-config.yml...\n\n"
78
79
  end
79
80
 
80
81
  if File.exists?(File.expand_path("~/.chef/spork-config.yml"))
81
- AppConf.load(File.expand_path("~/.chef/spork-config.yml"))
82
+ @conf.load(File.expand_path("~/.chef/spork-config.yml"))
82
83
  ui.msg "Loaded config file #{File.expand_path("~/.chef/spork-config.yml")}...\n\n"
83
84
  end
84
85
 
85
86
  config[:cookbook_path] ||= Chef::Config[:cookbook_path]
86
87
 
87
- if @name_args.empty? && AppConf.default_environments.nil?
88
+ if @name_args.empty? && @conf.default_environments.nil?
88
89
  show_usage
89
90
  ui.error("You must specify a cookbook name and an environment")
90
91
  exit 1
91
- elsif @name_args.empty? && !AppConf.default_environments.nil?
92
+ elsif @name_args.empty? && !@conf.default_environments.nil?
92
93
  show_usage
93
94
  ui.error("Default environments loaded from config, but you must specify a cookbook name")
94
95
  exit 1
95
- elsif @name_args.size != 2 && AppConf.default_environments.nil?
96
+ elsif @name_args.size != 2 && @conf.default_environments.nil?
96
97
  show_usage
97
98
  ui.error("You must specify a cookbook name and an environment")
98
99
  exit 1
99
100
  end
100
101
 
101
- if !AppConf.git.nil? && AppConf.git.enabled
102
+ if !@conf.git.nil? && @conf.git.enabled
102
103
  if !@@gitavail
103
104
  ui.msg "Git gem not available, skipping git pull.\n\n"
104
105
  else
@@ -106,14 +107,14 @@ module KnifeSpork
106
107
  end
107
108
  end
108
109
 
109
- if AppConf.default_environments.nil?
110
+ if @conf.default_environments.nil?
110
111
  environments = [ @name_args[0] ]
111
112
  @cookbook = @name_args[1]
112
- elsif !AppConf.default_environments.nil? && @name_args.size == 2
113
+ elsif !@conf.default_environments.nil? && @name_args.size == 2
113
114
  environments = [ @name_args[0] ]
114
115
  @cookbook = @name_args[1]
115
116
  else
116
- environments = AppConf.default_environments
117
+ environments = @conf.default_environments
117
118
  @cookbook = @name_args[0]
118
119
  end
119
120
 
@@ -229,29 +230,29 @@ module KnifeSpork
229
230
  end
230
231
  updated.save
231
232
 
232
- if !AppConf.gist.nil? && AppConf.gist.enabled
233
- if AppConf.gist.in_chef
234
- gist_path = AppConf.gist.chef_path
233
+ if !@conf.gist.nil? && @conf.gist.enabled
234
+ if @conf.gist.in_chef
235
+ gist_path = @conf.gist.chef_path
235
236
  else
236
- gist_path = AppConf.gist.path
237
+ gist_path = @conf.gist.path
237
238
  end
238
239
 
239
240
  msg = "Environment #{environment.gsub(".json","")} uploaded at #{Time.now.getutc} by #{ENV['USER']}\n\nConstraints updated on server in this version:\n\n#{env_diff.collect { |k, v| "#{k}: #{v}\n" }.join}"
240
241
  @gist = %x[ echo "#{msg}" | #{gist_path}]
241
242
  end
242
243
 
243
- if !AppConf.irccat.nil? && AppConf.irccat.enabled
244
+ if !@conf.irccat.nil? && @conf.irccat.enabled
244
245
  begin
245
246
 
246
- if !AppConf.irccat.channel?(String)
247
- channels = AppConf.irccat.channel
247
+ if !@conf.irccat.channel?(String)
248
+ channels = @conf.irccat.channel
248
249
  else
249
- channels = ["#{AppConf.irccat.channel}"]
250
+ channels = ["#{@conf.irccat.channel}"]
250
251
  end
251
252
 
252
253
  channels.each do |c|
253
254
  message = "#{c} #BOLD#PURPLECHEF:#NORMAL #{ENV['USER']} uploaded environment #TEAL#{environment.gsub(".json","")}#NORMAL #{@gist}"
254
- s = TCPSocket.open(AppConf.irccat.server,AppConf.irccat.port)
255
+ s = TCPSocket.open(@conf.irccat.server,@conf.irccat.port)
255
256
  s.write(message)
256
257
  s.close
257
258
  end
@@ -260,7 +261,7 @@ module KnifeSpork
260
261
  end
261
262
  end
262
263
 
263
- if !AppConf.eventinator.nil? && AppConf.eventinator.enabled
264
+ if !@conf.eventinator.nil? && @conf.eventinator.enabled
264
265
  metadata = {}
265
266
  metadata[:promoted_cookbooks] = {}
266
267
  promoted_cookbooks = []
@@ -274,7 +275,7 @@ module KnifeSpork
274
275
  event_data[:username] = ENV['USER']
275
276
  event_data[:status] = "#{ENV['USER']} promoted #{promoted_cookbooks.join(", ")} to #{environment.gsub(".json","")}"
276
277
  event_data[:metadata] = metadata.to_json
277
- uri = URI.parse(AppConf.eventinator.url)
278
+ uri = URI.parse(@conf.eventinator.url)
278
279
  http = Net::HTTP.new(uri.host, uri.port)
279
280
  ## TODO: should make this configurable, timeout after 5 sec
280
281
  http.read_timeout = 5;
@@ -283,19 +284,19 @@ module KnifeSpork
283
284
  begin
284
285
  response = http.request(request)
285
286
  if response.code != "200"
286
- ui.warn("Got a #{response.code} from #{AppConf.eventinator.url} promote wasn't eventinated")
287
+ ui.warn("Got a #{response.code} from #{@conf.eventinator.url} promote wasn't eventinated")
287
288
  end
288
289
  rescue Timeout::Error
289
- ui.warn("Timed out connecting to #{AppConf.eventinator.url} promote wasn't eventinated")
290
+ ui.warn("Timed out connecting to #{@conf.eventinator.url} promote wasn't eventinated")
290
291
  rescue Exception => msg
291
292
  ui.warn("An unhandled execption occured while eventinating: #{msg}")
292
293
  end
293
294
  end
294
- if !AppConf.graphite.nil? && AppConf.graphite.enabled
295
+ if !@conf.graphite.nil? && @conf.graphite.enabled
295
296
  begin
296
297
  time = Time.now
297
298
  message = "deploys.chef.#{environment.gsub(".json","")} 1 #{time.to_i}\n"
298
- s = TCPSocket.open(AppConf.graphite.server,AppConf.graphite.port)
299
+ s = TCPSocket.open(@conf.graphite.server,@conf.graphite.port)
299
300
  s.write(message)
300
301
  s.close
301
302
  rescue Exception => msg
@@ -308,18 +309,15 @@ module KnifeSpork
308
309
  cookbook_path = config[:cookbook_path]
309
310
 
310
311
  if cookbook_path.size > 1
311
- ui.warn "It looks like you have multiple cookbook paths defined so I'm not sure where to save your changed environment file.\n\n"
312
- ui.msg "Here's the JSON for you to paste into #{environment}.json in the environments directory you wish to use.\n\n"
313
- ui.msg "#{envjson}\n\n"
314
- else
315
- path = cookbook_path[0].gsub("cookbooks","environments") + "/#{environment}.json"
312
+ ui.warn "It looks like you have multiple cookbook paths defined so I'm trying the first one (#{cookbook_path[0]}).\n\n"
313
+ end
314
+ path = cookbook_path[0].gsub("cookbooks","environments") + "/#{environment}.json"
316
315
 
317
- File.open(path, 'w') do |f2|
318
- # use "\n" for two lines of text
319
- f2.puts envjson
320
- end
316
+ File.open(path, 'w') do |f2|
317
+ # use "\n" for two lines of text
318
+ f2.puts envjson
321
319
  end
322
- if !AppConf.git.nil? && AppConf.git.enabled
320
+ if !@conf.git.nil? && @conf.git.enabled
323
321
  if !@@gitavail
324
322
  ui.msg "Git gem not available, skipping git add.\n\n"
325
323
  else
@@ -75,19 +75,20 @@ module KnifeSpork
75
75
  end
76
76
 
77
77
  self.config = Chef::Config.merge!(config)
78
-
78
+ @conf = AppConf.new
79
+
79
80
  if File.exists?("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
80
- AppConf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
81
+ @conf.load("#{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml")
81
82
  ui.msg "Loaded config file #{config[:cookbook_path].first.gsub("cookbooks","")}config/spork-config.yml...\n\n"
82
83
  end
83
84
 
84
85
  if File.exists?("/etc/spork-config.yml")
85
- AppConf.load("/etc/spork-config.yml")
86
+ @conf.load("/etc/spork-config.yml")
86
87
  ui.msg "Loaded config file /etc/spork-config.yml...\n\n"
87
88
  end
88
89
 
89
90
  if File.exists?(File.expand_path("~/.chef/spork-config.yml"))
90
- AppConf.load(File.expand_path("~/.chef/spork-config.yml"))
91
+ @conf.load(File.expand_path("~/.chef/spork-config.yml"))
91
92
  ui.msg "Loaded config file #{File.expand_path("~/.chef/spork-config.yml")}...\n\n"
92
93
  end
93
94
 
@@ -113,7 +114,7 @@ module KnifeSpork
113
114
  end
114
115
  end
115
116
 
116
- if !AppConf.foodcritic.nil? && AppConf.foodcritic.enabled
117
+ if !@conf.foodcritic.nil? && @conf.foodcritic.enabled
117
118
  if !@@fcavail
118
119
  ui.msg "Foodcritic gem not available, skipping cookbook lint check.\n\n"
119
120
  else
@@ -127,18 +128,18 @@ module KnifeSpork
127
128
  cookbook.freeze_version
128
129
  upload(cookbook, justify_width)
129
130
 
130
- if !AppConf.irccat.nil? && AppConf.irccat.enabled
131
+ if !@conf.irccat.nil? && @conf.irccat.enabled
131
132
  begin
132
133
 
133
- if !AppConf.irccat.channel?(String)
134
- channels = AppConf.irccat.channel
134
+ if !@conf.irccat.channel?(String)
135
+ channels = @conf.irccat.channel
135
136
  else
136
- channels = ["#{AppConf.irccat.channel}"]
137
+ channels = ["#{@conf.irccat.channel}"]
137
138
  end
138
139
 
139
140
  channels.each do |c|
140
141
  message = "#{c} #BOLD#PURPLECHEF:#NORMAL #{ENV['USER']} uploaded and froze cookbook #TEAL#{cookbook_name}#NORMAL version #TEAL#{cookbook.version}#NORMAL"
141
- s = TCPSocket.open(AppConf.irccat.server,AppConf.irccat.port)
142
+ s = TCPSocket.open(@conf.irccat.server,@conf.irccat.port)
142
143
  s.write(message)
143
144
  s.close
144
145
  end
@@ -147,7 +148,7 @@ module KnifeSpork
147
148
  end
148
149
  end
149
150
 
150
- if !AppConf.eventinator.nil? && AppConf.eventinator.enabled
151
+ if !@conf.eventinator.nil? && @conf.eventinator.enabled
151
152
  metadata = {}
152
153
  metadata[:cookbook_name] = cookbook.name
153
154
  metadata[:cookbook_version] = cookbook.version
@@ -158,7 +159,7 @@ module KnifeSpork
158
159
  event_data[:status] = "#{ENV['USER']} uploaded and froze version #{cookbook.version} of cookbook #{cookbook_name}"
159
160
  event_data[:metadata] = metadata.to_json
160
161
 
161
- uri = URI.parse(AppConf.eventinator.url)
162
+ uri = URI.parse(@conf.eventinator.url)
162
163
 
163
164
  http = Net::HTTP.new(uri.host, uri.port)
164
165
 
@@ -171,10 +172,10 @@ module KnifeSpork
171
172
  begin
172
173
  response = http.request(request)
173
174
  if response.code != "200"
174
- ui.warn("Got a #{response.code} from #{AppConf.eventinator.url} upload wasn't eventinated")
175
+ ui.warn("Got a #{response.code} from #{@conf.eventinator.url} upload wasn't eventinated")
175
176
  end
176
177
  rescue Timeout::Error
177
- ui.warn("Timed out connecting to #{AppConf.eventinator.url} upload wasn't eventinated")
178
+ ui.warn("Timed out connecting to #{@conf.eventinator.url} upload wasn't eventinated")
178
179
  rescue Exception => msg
179
180
  ui.warn("An unhandled execption occured while eventinating: #{msg}")
180
181
  end
@@ -288,24 +289,20 @@ WARNING
288
289
 
289
290
  def foodcritic_lint_check(cookbook_name)
290
291
 
291
- if config[:cookbook_path].size > 1
292
- ui.warn "It looks like you have multiple cookbook paths defined so I'm not sure where to look for this cookbook.\n\n"
293
- ui.warn "Skipping Lint Check.\n\n"
294
- return
295
- end
296
-
292
+ cookbook_path = cookbook_repo[cookbook_name].root_dir
293
+
297
294
  fail_tags = []
298
- fail_tags = AppConf.foodcritic.fail_tags unless AppConf.foodcritic.fail_tags.nil?
295
+ fail_tags = @conf.foodcritic.fail_tags unless @conf.foodcritic.fail_tags.nil?
299
296
 
300
297
  tags = []
301
- tags = AppConf.foodcritic.tags unless AppConf.foodcritic.tags.nil?
298
+ tags = @conf.foodcritic.tags unless @conf.foodcritic.tags.nil?
302
299
 
303
300
  include_rules = []
304
- include_rules = AppConf.foodcritic.include_rules unless AppConf.foodcritic.include_rules.nil?
301
+ include_rules = @conf.foodcritic.include_rules unless @conf.foodcritic.include_rules.nil?
305
302
 
306
303
  ui.msg "Lint checking #{cookbook_name}..."
307
304
  options = {:fail_tags => fail_tags, :tags =>tags, :include_rules => include_rules}
308
- review = FoodCritic::Linter.new.check("#{config[:cookbook_path][0]}/#{cookbook_name}",options)
305
+ review = FoodCritic::Linter.new.check("#{cookbook_path}",options)
309
306
 
310
307
  if review.failed?
311
308
  ui.error "Lint check failed. Halting upload."
@@ -1,3 +1,3 @@
1
1
  module KnifeSpork
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 9
9
- version: 0.1.9
8
+ - 10
9
+ version: 0.1.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jon Cowie
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-04-03 00:00:00 +01:00
17
+ date: 2012-04-12 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -57,9 +57,9 @@ dependencies:
57
57
  - !ruby/object:Gem::Version
58
58
  segments:
59
59
  - 0
60
- - 3
60
+ - 4
61
61
  - 0
62
- version: 0.3.0
62
+ version: 0.4.0
63
63
  type: :runtime
64
64
  version_requirements: *id003
65
65
  description: A workflow plugin to help many devs work with the same chef repo/server