knife-spork 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/CHANGELOG.md +18 -0
  2. data/LICENSE +1 -1
  3. data/README.md +131 -5
  4. data/knife-spork.gemspec +3 -2
  5. data/lib/chef/knife/spork-check.rb +13 -1
  6. data/lib/chef/knife/spork-databag-create.rb +53 -0
  7. data/lib/chef/knife/spork-databag-delete.rb +51 -0
  8. data/lib/chef/knife/spork-databag-edit.rb +54 -0
  9. data/lib/chef/knife/spork-databag-fromfile.rb +82 -0
  10. data/lib/chef/knife/spork-node-create.rb +38 -0
  11. data/lib/chef/knife/spork-node-delete.rb +38 -0
  12. data/lib/chef/knife/spork-node-edit.rb +45 -0
  13. data/lib/chef/knife/spork-node-fromfile.rb +43 -0
  14. data/lib/chef/knife/spork-node-runlistadd.rb +48 -0
  15. data/lib/chef/knife/spork-node-runlistremove.rb +42 -0
  16. data/lib/chef/knife/spork-node-runlistset.rb +42 -0
  17. data/lib/chef/knife/spork-omni.rb +107 -0
  18. data/lib/chef/knife/spork-promote.rb +2 -6
  19. data/lib/chef/knife/spork-role-create.rb +43 -0
  20. data/lib/chef/knife/spork-role-delete.rb +36 -0
  21. data/lib/chef/knife/spork-role-edit.rb +37 -0
  22. data/lib/chef/knife/spork-role-fromfile.rb +42 -0
  23. data/lib/knife-spork/plugins/campfire.rb +128 -0
  24. data/lib/knife-spork/plugins/eventinator.rb +199 -0
  25. data/lib/knife-spork/plugins/foodcritic.rb +8 -3
  26. data/lib/knife-spork/plugins/grove.rb +96 -0
  27. data/lib/knife-spork/plugins/hipchat.rb +65 -0
  28. data/lib/knife-spork/plugins/irccat.rb +190 -3
  29. data/lib/knife-spork/plugins/jabber.rb +64 -0
  30. data/lib/knife-spork/plugins/plugin.rb +12 -0
  31. data/lib/knife-spork/plugins/statusnet.rb +64 -0
  32. data/lib/knife-spork/plugins.rb +3 -0
  33. data/lib/knife-spork/runner.rb +51 -4
  34. data/plugins/Foodcritic.md +1 -1
  35. metadata +36 -4
@@ -41,6 +41,205 @@ module KnifeSpork
41
41
  end
42
42
  end
43
43
 
44
+
45
+ def after_rolefromfile
46
+ event_data = {
47
+ :tag => 'knife',
48
+ :username => current_user,
49
+ :status => "#{organization}#{current_user} uploaded role #{object_name}",
50
+ :metadata => {
51
+ :role_name => object_name,
52
+ }.to_json
53
+ }
54
+ eventinate(event_data)
55
+ end
56
+
57
+ def after_roleedit
58
+ event_data = {
59
+ :tag => 'knife',
60
+ :username => current_user,
61
+ :status => "#{organization}#{current_user} edited role #{object_name}",
62
+ :metadata => {
63
+ :role_name => object_name,
64
+ }.to_json
65
+ }
66
+ eventinate(event_data)
67
+ end
68
+
69
+ def after_rolecreate
70
+ event_data = {
71
+ :tag => 'knife',
72
+ :username => current_user,
73
+ :status => "#{organization}#{current_user} created role #{object_name}",
74
+ :metadata => {
75
+ :role_name => object_name,
76
+ }.to_json
77
+ }
78
+ eventinate(event_data)
79
+ end
80
+
81
+ def after_roledelete
82
+ event_data = {
83
+ :tag => 'knife',
84
+ :username => current_user,
85
+ :status => "#{organization}#{current_user} deleted role #{object_name}",
86
+ :metadata => {
87
+ :role_name => object_name,
88
+ }.to_json
89
+ }
90
+ eventinate(event_data)
91
+ end
92
+
93
+ def after_databagedit
94
+ event_data = {
95
+ :tag => 'knife',
96
+ :username => current_user,
97
+ :status => "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}",
98
+ :metadata => {
99
+ :databag_name => object_name,
100
+ :databag_item => object_secondary_name,
101
+ }.to_json
102
+ }
103
+ eventinate(event_data)
104
+ end
105
+
106
+ def after_databagcreate
107
+ event_data = {
108
+ :tag => 'knife',
109
+ :username => current_user,
110
+ :status => "#{organization}#{current_user} created data bag #{object_name}",
111
+ :metadata => {
112
+ :databag_name => object_name,
113
+ }.to_json
114
+ }
115
+ eventinate(event_data)
116
+ end
117
+
118
+ def after_databagdelete
119
+ event_data = {
120
+ :tag => 'knife',
121
+ :username => current_user,
122
+ :status => "#{organization}#{current_user} deleted data bag item #{object_name}",
123
+ :metadata => {
124
+ :databag_name => object_name,
125
+ }.to_json
126
+ }
127
+ eventinate(event_data)
128
+ end
129
+
130
+ def after_databagitemdelete
131
+ event_data = {
132
+ :tag => 'knife',
133
+ :username => current_user,
134
+ :status => "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}",
135
+ :metadata => {
136
+ :databag_name => object_name,
137
+ :databag_item => object_secondary_name,
138
+ }.to_json
139
+ }
140
+ eventinate(event_data)
141
+ end
142
+
143
+ def after_databagfromfile
144
+ event_data = {
145
+ :tag => 'knife',
146
+ :username => current_user,
147
+ :status => "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}",
148
+ :metadata => {
149
+ :databag_name => object_name,
150
+ :databag_item => object_secondary_name,
151
+ }.to_json
152
+ }
153
+ eventinate(event_data)
154
+ end
155
+
156
+ def after_nodeedit
157
+ event_data = {
158
+ :tag => 'knife',
159
+ :username => current_user,
160
+ :status => "#{organization}#{current_user} edited node #{object_name}",
161
+ :metadata => {
162
+ :node_name => object_name
163
+ }.to_json
164
+ }
165
+ eventinate(event_data)
166
+ end
167
+
168
+ def after_nodedelete
169
+ event_data = {
170
+ :tag => 'knife',
171
+ :username => current_user,
172
+ :status => "#{organization}#{current_user} deleted node #{object_name}",
173
+ :metadata => {
174
+ :node_name => object_name
175
+ }.to_json
176
+ }
177
+ eventinate(event_data)
178
+ end
179
+
180
+ def after_nodecreate
181
+ event_data = {
182
+ :tag => 'knife',
183
+ :username => current_user,
184
+ :status => "#{organization}#{current_user} created node #{object_name}",
185
+ :metadata => {
186
+ :node_name => object_name
187
+ }.to_json
188
+ }
189
+ eventinate(event_data)
190
+ end
191
+
192
+ def after_nodefromfile
193
+ event_data = {
194
+ :tag => 'knife',
195
+ :username => current_user,
196
+ :status => "#{organization}#{current_user} uploaded node #{object_name}",
197
+ :metadata => {
198
+ :node_name => object_name
199
+ }.to_json
200
+ }
201
+ eventinate(event_data)
202
+ end
203
+
204
+ def after_noderunlistadd
205
+ event_data = {
206
+ :tag => 'knife',
207
+ :username => current_user,
208
+ :status => "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}",
209
+ :metadata => {
210
+ :node_name => object_name,
211
+ :run_list_items => object_secondary_name,
212
+ }.to_json
213
+ }
214
+ eventinate(event_data)
215
+ end
216
+
217
+ def after_noderunlistremove
218
+ event_data = {
219
+ :tag => 'knife',
220
+ :username => current_user,
221
+ :status => "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}",
222
+ :metadata => {
223
+ :node_name => object_name,
224
+ :run_list_items => object_secondary_name,
225
+ }.to_json
226
+ }
227
+ eventinate(event_data)
228
+ end
229
+
230
+ def after_noderunlistset
231
+ event_data = {
232
+ :tag => 'knife',
233
+ :username => current_user,
234
+ :status => "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}",
235
+ :metadata => {
236
+ :node_name => object_name,
237
+ :run_list_items => object_secondary_name,
238
+ }.to_json
239
+ }
240
+ eventinate(event_data)
241
+ end
242
+
44
243
  def eventinate(event_data)
45
244
  begin
46
245
  uri = URI.parse(config.url)
@@ -9,6 +9,11 @@ module KnifeSpork
9
9
  def perform
10
10
  safe_require 'foodcritic'
11
11
 
12
+ if Gem::Specification.find_all_by_name("foodcritic", "~> 3.0.0").empty?
13
+ ui.fatal "The knife-spork foodcritic plugin requires foodcritic >= 3.0.0. Please install a more recent foodcritic version."
14
+ exit 1
15
+ end
16
+
12
17
  tags = config.tags || []
13
18
  fail_tags = config.fail_tags || ['any']
14
19
  include_rules = config.include_rules || []
@@ -20,8 +25,8 @@ module KnifeSpork
20
25
 
21
26
  ui.info cookbook_path
22
27
 
23
- options = {:tags => tags, :fail_tags => fail_tags, :include_rules => include_rules}
24
- review = ::FoodCritic::Linter.new.check([cookbook_path], options)
28
+ options = {:tags => tags, :fail_tags => fail_tags, :include_rules => include_rules, :cookbook_paths => [cookbook_path]}
29
+ review = ::FoodCritic::Linter.new.check(options)
25
30
 
26
31
  if review.failed?
27
32
  ui.error "Foodcritic failed!"
@@ -38,4 +43,4 @@ module KnifeSpork
38
43
  end
39
44
  end
40
45
  end
41
- end
46
+ end
@@ -19,6 +19,102 @@ module KnifeSpork
19
19
  EOH
20
20
  end
21
21
 
22
+ def after_rolefromfile
23
+ grove <<-EOH
24
+ #{current_user} uploaded role #{object_name}
25
+ EOH
26
+ end
27
+
28
+ def after_roleedit
29
+ grove <<-EOH
30
+ #{current_user} edited role #{object_name}
31
+ EOH
32
+ end
33
+
34
+ def after_rolecreate
35
+ grove <<-EOH
36
+ #{current_user} created role #{object_name}
37
+ EOH
38
+ end
39
+
40
+ def after_roledelete
41
+ grove <<-EOH
42
+ #{current_user} deleted role #{object_name}
43
+ EOH
44
+ end
45
+
46
+ def after_databagcreate
47
+ grove <<-EOH
48
+ #{current_user} created data bag #{object_name}
49
+ EOH
50
+ end
51
+
52
+ def after_databagedit
53
+ grove <<-EOH
54
+ #{current_user} edited data bag item #{object_name}:#{object_secondary_name}
55
+ EOH
56
+ end
57
+
58
+ def after_databagitemdelete
59
+ grove <<-EOH
60
+ #{current_user} edited data bag item #{object_name}:#{object_secondary_name}
61
+ EOH
62
+ end
63
+
64
+ def after_databagdelete
65
+ grove <<-EOH
66
+ #{current_user} edited data bag #{object_name}
67
+ EOH
68
+ end
69
+
70
+ def after_databagfromfile
71
+ grove <<-EOH
72
+ #{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}
73
+ EOH
74
+ end
75
+
76
+ def after_nodeedit
77
+ grove <<-EOH
78
+ #{current_user} edited node #{object_name}
79
+ EOH
80
+ end
81
+
82
+ def after_nodedelete
83
+ grove <<-EOH
84
+ #{current_user} deleted node #{object_name}
85
+ EOH
86
+ end
87
+
88
+ def after_nodecreate
89
+ grove <<-EOH
90
+ #{current_user} created node #{object_name}
91
+ EOH
92
+ end
93
+
94
+ def after_nodefromfile
95
+ grove <<-EOH
96
+ #{current_user} uploaded node #{object_name}
97
+ EOH
98
+ end
99
+
100
+ def after_noderunlistadd
101
+ grove <<-EOH
102
+ #{current_user} added run_list items to #{object_name}: #{object_secondary_name}
103
+ EOH
104
+ end
105
+
106
+ def after_noderunlistremove
107
+ grove <<-EOH
108
+ #{current_user} removed run_list items from #{object_name}: #{object_secondary_name}
109
+ EOH
110
+ end
111
+
112
+ def after_noderunlistset
113
+ grove <<-EOH
114
+ #{current_user} set the run_list for #{object_name} to #{object_secondary_name}
115
+ EOH
116
+ end
117
+
22
118
  private
23
119
  def grove(message)
24
120
  safe_require 'rest_client'
@@ -15,6 +15,71 @@ module KnifeSpork
15
15
  hipchat "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
16
16
  end
17
17
 
18
+ def after_rolefromfile
19
+ hipchat "#{organization}#{current_user} uploaded role #{object_name}"
20
+ end
21
+
22
+ def after_roleedit
23
+ hipchat "#{organization}#{current_user} edited role #{object_name}"
24
+ end
25
+
26
+ def after_rolecreate
27
+ hipchat "#{organization}#{current_user} created role #{object_name}"
28
+ end
29
+
30
+ def after_roledelete
31
+ hipchat "#{organization}#{current_user} deleted role #{object_name}"
32
+ end
33
+
34
+ def after_databagedit
35
+ hipchat "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}"
36
+ end
37
+
38
+ def after_databagcreate
39
+ hipchat "#{organization}#{current_user} created data bag #{object_name}"
40
+ end
41
+
42
+ def after_databagdelete
43
+ hipchat "#{organization}#{current_user} deleted data bag item #{object_name}"
44
+ end
45
+
46
+ def after_databagitemdelete
47
+ hipchat "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}"
48
+ end
49
+
50
+ def after_databagfromfile
51
+ hipchat "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}"
52
+ end
53
+
54
+ def after_nodeedit
55
+ hipchat "#{organization}#{current_user} edited node #{object_name}"
56
+ end
57
+
58
+ def after_nodedelete
59
+ hipchat "#{organization}#{current_user} deleted node #{object_name}"
60
+ end
61
+
62
+ def after_nodecreate
63
+ hipchat "#{organization}#{current_user} created node #{object_name}"
64
+ end
65
+
66
+ def after_nodefromfile
67
+ hipchat "#{organization}#{current_user} uploaded node #{object_name}"
68
+ end
69
+
70
+ def after_noderunlistadd
71
+ hipchat "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}"
72
+ end
73
+
74
+ def after_noderunlistremove
75
+ hipchat "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}"
76
+ end
77
+
78
+ def after_noderunlistset
79
+ hipchat "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}"
80
+ end
81
+
82
+
18
83
  private
19
84
  def hipchat(message)
20
85
  safe_require 'hipchat'
@@ -7,7 +7,23 @@ module KnifeSpork
7
7
 
8
8
  TEMPLATES = {
9
9
  :upload => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded #TEAL%{cookbooks}#NORMAL',
10
- :promote => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} promoted #TEAL%{cookbooks}#NORMAL to %{environment} %{gist}'
10
+ :promote => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} promoted #TEAL%{cookbooks}#NORMAL to %{environment} %{gist}',
11
+ :rolefromfile => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded role #TEAL%{object_name}#NORMAL %{gist}',
12
+ :roleedit => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} edited role #TEAL%{object_name}#NORMAL %{gist}',
13
+ :rolecreate => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} created role #TEAL%{object_name}#NORMAL %{gist}',
14
+ :roledelete => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} deleted role #TEAL%{object_name}#NORMAL %{gist}',
15
+ :databagedit => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} edited data bag item #TEAL%{object_name}:%{object_secondary_name}#NORMAL %{gist}',
16
+ :databagdelete => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} deleted data bag #TEAL%{object_name}#NORMAL %{gist}',
17
+ :databagitemdelete => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} deleted data bag item #TEAL%{object_name}:%{object_secondary_name}#NORMAL %{gist}',
18
+ :databagcreate => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} created data bag #TEAL%{object_name}#NORMAL %{gist}',
19
+ :databagfromfile => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded data bag item #TEAL%{object_name}:%{object_secondary_name}#NORMAL %{gist}',
20
+ :nodeedit => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} edited node #TEAL%{object_name}#NORMAL %{gist}',
21
+ :nodedelete => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} deleted node #TEAL%{object_name}#NORMAL %{gist}',
22
+ :nodecreate => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} created node #TEAL%{object_name}#NORMAL %{gist}',
23
+ :nodefromfile => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded node #TEAL%{object_name}#NORMAL %{gist}',
24
+ :noderunlistadd => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} added run_list items to #TEAL%{object_name}: %{object_secondary_name}#NORMAL %{gist}',
25
+ :noderunlistremove => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} removed run_list items from #TEAL%{object_name}: %{object_secondary_name}#NORMAL %{gist}',
26
+ :noderunlistset => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} set the run_list for #TEAL%{object_name} to %{object_secondary_name}#NORMAL %{gist}'
11
27
  }
12
28
 
13
29
  def perform; end
@@ -23,7 +39,7 @@ module KnifeSpork
23
39
  def after_promote_remote
24
40
  environments.each do |environment|
25
41
  diff = environment_diffs[environment.name]
26
- env_gist = gist(environment, diff) if config.gist
42
+ env_gist = env_gist(environment, diff) if config.gist
27
43
  irccat(template(:promote) % {
28
44
  :organization => organization,
29
45
  :current_user => current_user,
@@ -34,6 +50,172 @@ module KnifeSpork
34
50
  end
35
51
  end
36
52
 
53
+ def after_rolefromfile
54
+ role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
55
+ irccat(template(:rolefromfile) % {
56
+ :organization => organization,
57
+ :current_user => current_user,
58
+ :object_name => object_name,
59
+ :gist => role_gist
60
+ })
61
+ end
62
+
63
+ def after_roleedit
64
+ role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
65
+ irccat(template(:roleedit) % {
66
+ :organization => organization,
67
+ :current_user => current_user,
68
+ :object_name => object_name,
69
+ :gist => role_gist
70
+ })
71
+ end
72
+
73
+ def after_rolecreate
74
+ role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
75
+ irccat(template(:rolecreate) % {
76
+ :organization => organization,
77
+ :current_user => current_user,
78
+ :object_name => object_name,
79
+ :gist => role_gist
80
+ })
81
+ end
82
+
83
+ def after_roledelete
84
+ role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
85
+ irccat(template(:roledelete) % {
86
+ :organization => organization,
87
+ :current_user => current_user,
88
+ :object_name => object_name,
89
+ :gist => role_gist
90
+ })
91
+ end
92
+
93
+ def after_databagedit
94
+ databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
95
+ irccat(template(:databagedit) % {
96
+ :organization => organization,
97
+ :current_user => current_user,
98
+ :object_name => object_name,
99
+ :object_secondary_name => object_secondary_name,
100
+ :gist => databag_gist
101
+ })
102
+ end
103
+
104
+ def after_databagdelete
105
+ databag_gist = object_gist("databag item", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
106
+ irccat(template(:databagdelete) % {
107
+ :organization => organization,
108
+ :current_user => current_user,
109
+ :object_name => object_name,
110
+ :gist => databag_gist
111
+ })
112
+ end
113
+
114
+ def after_databagitemdelete
115
+ databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
116
+ irccat(template(:databagitemdelete) % {
117
+ :organization => organization,
118
+ :current_user => current_user,
119
+ :object_name => object_name,
120
+ :object_secondary_name => object_secondary_name,
121
+ :gist => databag_gist
122
+ })
123
+ end
124
+
125
+ def after_databagcreate
126
+ databag_gist = object_gist("databag", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
127
+ irccat(template(:databagcreate) % {
128
+ :organization => organization,
129
+ :current_user => current_user,
130
+ :object_name => object_name,
131
+ :gist => databag_gist
132
+ })
133
+ end
134
+
135
+ def after_databagfromfile
136
+ databag_gist = object_gist("databag", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
137
+ irccat(template(:databagfromfile) % {
138
+ :organization => organization,
139
+ :current_user => current_user,
140
+ :object_name => object_name,
141
+ :object_secondary_name => object_secondary_name,
142
+ :gist => databag_gist
143
+ })
144
+ end
145
+
146
+ def after_nodeedit
147
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
148
+ irccat(template(:nodeedit) % {
149
+ :organization => organization,
150
+ :current_user => current_user,
151
+ :object_name => object_name,
152
+ :gist => node_gist
153
+ })
154
+ end
155
+
156
+ def after_nodedelete
157
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
158
+ irccat(template(:nodedelete) % {
159
+ :organization => organization,
160
+ :current_user => current_user,
161
+ :object_name => object_name,
162
+ :gist => node_gist
163
+ })
164
+ end
165
+
166
+ def after_nodecreate
167
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
168
+ irccat(template(:nodecreate) % {
169
+ :organization => organization,
170
+ :current_user => current_user,
171
+ :object_name => object_name,
172
+ :gist => node_gist
173
+ })
174
+ end
175
+
176
+ def after_nodefromfile
177
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
178
+ irccat(template(:nodefromfile) % {
179
+ :organization => organization,
180
+ :current_user => current_user,
181
+ :object_name => object_name,
182
+ :gist => node_gist
183
+ })
184
+ end
185
+
186
+ def after_noderunlistadd
187
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
188
+ irccat(template(:noderunlistadd) % {
189
+ :organization => organization,
190
+ :current_user => current_user,
191
+ :object_name => object_name,
192
+ :object_secondary_name => object_secondary_name,
193
+ :gist => node_gist
194
+ })
195
+ end
196
+
197
+ def after_noderunlistremove
198
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
199
+ irccat(template(:noderunlistremove) % {
200
+ :organization => organization,
201
+ :current_user => current_user,
202
+ :object_name => object_name,
203
+ :object_secondary_name => object_secondary_name,
204
+ :gist => node_gist
205
+ })
206
+ end
207
+
208
+ def after_noderunlistset
209
+ node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
210
+ irccat(template(:noderunlistset) % {
211
+ :organization => organization,
212
+ :current_user => current_user,
213
+ :object_name => object_name,
214
+ :object_secondary_name => object_secondary_name,
215
+ :gist => node_gist
216
+ })
217
+ end
218
+
37
219
  private
38
220
  def irccat(message)
39
221
  channels.each do |channel|
@@ -50,11 +232,16 @@ module KnifeSpork
50
232
  end
51
233
  end
52
234
 
53
- def gist(environment, diff)
235
+ def env_gist(environment, diff)
54
236
  msg = "Environment #{environment} uploaded at #{Time.now.getutc} by #{current_user}\n\nConstraints updated on server in this version:\n\n#{diff.collect { |k, v| "#{k}: #{v}\n" }.join}"
55
237
  %x[ echo "#{msg}" | #{config.gist}]
56
238
  end
57
239
 
240
+ def object_gist(object_type, object_name, object_diff)
241
+ msg = "#{object_type.capitalize} #{object_name} changed at #{Time.now.getutc} by #{current_user}\n\nDiff is as follows:\n\n#{object_diff}"
242
+ %x[ echo "#{msg}" | #{config.gist}]
243
+ end
244
+
58
245
  def channels
59
246
  [ config.channel || config.channels ].flatten
60
247
  end