knife-spork 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +35 -35
- data/lib/chef/knife/spork-bump.rb +100 -100
- data/lib/chef/knife/spork-check.rb +165 -161
- data/lib/chef/knife/spork-databag-create.rb +54 -54
- data/lib/chef/knife/spork-databag-delete.rb +51 -51
- data/lib/chef/knife/spork-databag-edit.rb +54 -54
- data/lib/chef/knife/spork-databag-fromfile.rb +88 -88
- data/lib/chef/knife/spork-delete.rb +132 -132
- data/lib/chef/knife/spork-environment-check.rb +90 -90
- data/lib/chef/knife/spork-environment-create.rb +63 -63
- data/lib/chef/knife/spork-environment-delete.rb +38 -38
- data/lib/chef/knife/spork-environment-edit.rb +40 -40
- data/lib/chef/knife/spork-environment-fromfile.rb +46 -46
- data/lib/chef/knife/spork-info.rb +34 -34
- data/lib/chef/knife/spork-node-create.rb +41 -41
- data/lib/chef/knife/spork-node-delete.rb +41 -41
- data/lib/chef/knife/spork-node-edit.rb +48 -48
- data/lib/chef/knife/spork-node-fromfile.rb +46 -46
- data/lib/chef/knife/spork-node-runlistadd.rb +51 -51
- data/lib/chef/knife/spork-node-runlistremove.rb +44 -44
- data/lib/chef/knife/spork-node-runlistset.rb +44 -44
- data/lib/chef/knife/spork-omni.rb +112 -112
- data/lib/chef/knife/spork-promote.rb +197 -197
- data/lib/chef/knife/spork-role-create.rb +46 -46
- data/lib/chef/knife/spork-role-delete.rb +50 -50
- data/lib/chef/knife/spork-role-edit.rb +40 -40
- data/lib/chef/knife/spork-role-fromfile.rb +65 -65
- data/lib/chef/knife/spork-upload.rb +151 -151
- data/lib/chef/knife/spork-version.rb +12 -12
- data/lib/knife-spork.rb +3 -3
- data/lib/knife-spork/plugins.rb +27 -27
- data/lib/knife-spork/plugins/campfire.rb +219 -219
- data/lib/knife-spork/plugins/eventinator.rb +329 -329
- data/lib/knife-spork/plugins/foodcritic.rb +46 -46
- data/lib/knife-spork/plugins/git.rb +393 -399
- data/lib/knife-spork/plugins/graphite.rb +25 -25
- data/lib/knife-spork/plugins/grove.rb +167 -167
- data/lib/knife-spork/plugins/hipchat.rb +171 -171
- data/lib/knife-spork/plugins/influxdb.rb +28 -28
- data/lib/knife-spork/plugins/irccat.rb +332 -332
- data/lib/knife-spork/plugins/jabber.rb +133 -133
- data/lib/knife-spork/plugins/plugin.rb +117 -117
- data/lib/knife-spork/plugins/rubocop.rb +56 -56
- data/lib/knife-spork/plugins/slack.rb +125 -125
- data/lib/knife-spork/plugins/statusnet.rb +122 -122
- data/lib/knife-spork/runner.rb +342 -342
- data/lib/knife-spork/version.rb +5 -5
- metadata +4 -51
- data/.gitignore +0 -21
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -3
- data/CHANGELOG.md +0 -445
- data/Gemfile +0 -3
- data/README.md +0 -544
- data/Rakefile +0 -35
- data/knife-spork.gemspec +0 -28
- data/plugins/Campfire.md +0 -43
- data/plugins/Eventinator.md +0 -30
- data/plugins/Foodcritic.md +0 -53
- data/plugins/Git.md +0 -53
- data/plugins/Graphite.md +0 -30
- data/plugins/Grove.md +0 -31
- data/plugins/HipChat.md +0 -69
- data/plugins/Influxdb.md +0 -25
- data/plugins/Irccat.md +0 -50
- data/plugins/Jabber.md +0 -61
- data/plugins/README.md +0 -70
- data/plugins/Rubocop.md +0 -110
- data/plugins/Slack.md +0 -48
- data/plugins/StatusNet.md +0 -41
- data/plugins/Template.md +0 -34
- data/spec/spec_helper.rb +0 -10
- data/spec/test_helpers.rb +0 -46
- data/spec/unit/fixtures/config/spork-config.yml +0 -1
- data/spec/unit/fixtures/cookbooks/example/metadata.rb +0 -8
- data/spec/unit/fixtures/environments/example.json +0 -12
- data/spec/unit/fixtures/knife.rb +0 -6
- data/spec/unit/fixtures/test_client.pem +0 -27
- data/spec/unit/spork_bump_spec.rb +0 -75
- data/spec/unit/spork_info_spec.rb +0 -40
- data/spec/unit/spork_promote_spec.rb +0 -77
- data/spec/unit/spork_upload_spec.rb +0 -46
@@ -1,25 +1,25 @@
|
|
1
|
-
require 'knife-spork/plugins/plugin'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
module Plugins
|
5
|
-
class Graphite < Plugin
|
6
|
-
name :graphite
|
7
|
-
hooks :after_promote_remote
|
8
|
-
|
9
|
-
def perform
|
10
|
-
environments.each do |environment|
|
11
|
-
begin
|
12
|
-
message = "deploys.chef.#{environment} 1 #{Time.now.to_i}\n"
|
13
|
-
socket = TCPSocket.open(config.server, config.port)
|
14
|
-
socket.write(message)
|
15
|
-
rescue Exception => e
|
16
|
-
ui.error 'Graphite was unable to process the request.'
|
17
|
-
ui.error e.to_s
|
18
|
-
ensure
|
19
|
-
socket.close unless socket.nil?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require 'knife-spork/plugins/plugin'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
module Plugins
|
5
|
+
class Graphite < Plugin
|
6
|
+
name :graphite
|
7
|
+
hooks :after_promote_remote
|
8
|
+
|
9
|
+
def perform
|
10
|
+
environments.each do |environment|
|
11
|
+
begin
|
12
|
+
message = "deploys.chef.#{environment} 1 #{Time.now.to_i}\n"
|
13
|
+
socket = TCPSocket.open(config.server, config.port)
|
14
|
+
socket.write(message)
|
15
|
+
rescue Exception => e
|
16
|
+
ui.error 'Graphite was unable to process the request.'
|
17
|
+
ui.error e.to_s
|
18
|
+
ensure
|
19
|
+
socket.close unless socket.nil?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,167 +1,167 @@
|
|
1
|
-
require 'knife-spork/plugins/plugin'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
module Plugins
|
5
|
-
class Grove < Plugin
|
6
|
-
name :grove
|
7
|
-
|
8
|
-
def perform; end
|
9
|
-
|
10
|
-
def after_upload
|
11
|
-
grove <<-EOH
|
12
|
-
#{current_user} froze the following cookbooks on Chef Server: #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')}
|
13
|
-
EOH
|
14
|
-
end
|
15
|
-
|
16
|
-
def after_delete
|
17
|
-
grove <<-EOH
|
18
|
-
#{organization}#{current_user} deleted the following cookbooks: #{misc_output}
|
19
|
-
EOH
|
20
|
-
end
|
21
|
-
|
22
|
-
def after_promote_remote
|
23
|
-
grove <<-EOH
|
24
|
-
#{current_user} promoted #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')} on #{environments.collect{|e| "#{e.name}"}.join(', ')}
|
25
|
-
EOH
|
26
|
-
end
|
27
|
-
|
28
|
-
def after_environmentfromfile
|
29
|
-
grove <<-EOH
|
30
|
-
#{current_user} uploaded environment #{object_name}
|
31
|
-
EOH
|
32
|
-
end
|
33
|
-
|
34
|
-
def after_environmentedit
|
35
|
-
grove <<-EOH
|
36
|
-
#{current_user} edited environment #{object_name}
|
37
|
-
EOH
|
38
|
-
end
|
39
|
-
|
40
|
-
def after_environmentcreate
|
41
|
-
grove <<-EOH
|
42
|
-
#{current_user} created environment #{object_name}
|
43
|
-
EOH
|
44
|
-
end
|
45
|
-
|
46
|
-
def after_environmentdelete
|
47
|
-
grove <<-EOH
|
48
|
-
#{current_user} deleted environment #{object_name}
|
49
|
-
EOH
|
50
|
-
end
|
51
|
-
|
52
|
-
def after_rolefromfile
|
53
|
-
grove <<-EOH
|
54
|
-
#{current_user} uploaded role #{object_name}
|
55
|
-
EOH
|
56
|
-
end
|
57
|
-
|
58
|
-
def after_roleedit
|
59
|
-
grove <<-EOH
|
60
|
-
#{current_user} edited role #{object_name}
|
61
|
-
EOH
|
62
|
-
end
|
63
|
-
|
64
|
-
def after_rolecreate
|
65
|
-
grove <<-EOH
|
66
|
-
#{current_user} created role #{object_name}
|
67
|
-
EOH
|
68
|
-
end
|
69
|
-
|
70
|
-
def after_roledelete
|
71
|
-
grove <<-EOH
|
72
|
-
#{current_user} deleted role #{object_name}
|
73
|
-
EOH
|
74
|
-
end
|
75
|
-
|
76
|
-
def after_databagcreate
|
77
|
-
grove <<-EOH
|
78
|
-
#{current_user} created data bag #{object_name}
|
79
|
-
EOH
|
80
|
-
end
|
81
|
-
|
82
|
-
def after_databagedit
|
83
|
-
grove <<-EOH
|
84
|
-
#{current_user} edited data bag item #{object_name}:#{object_secondary_name}
|
85
|
-
EOH
|
86
|
-
end
|
87
|
-
|
88
|
-
def after_databagitemdelete
|
89
|
-
grove <<-EOH
|
90
|
-
#{current_user} edited data bag item #{object_name}:#{object_secondary_name}
|
91
|
-
EOH
|
92
|
-
end
|
93
|
-
|
94
|
-
def after_databagdelete
|
95
|
-
grove <<-EOH
|
96
|
-
#{current_user} edited data bag #{object_name}
|
97
|
-
EOH
|
98
|
-
end
|
99
|
-
|
100
|
-
def after_databagfromfile
|
101
|
-
grove <<-EOH
|
102
|
-
#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}
|
103
|
-
EOH
|
104
|
-
end
|
105
|
-
|
106
|
-
def after_nodeedit
|
107
|
-
grove <<-EOH
|
108
|
-
#{current_user} edited node #{object_name}
|
109
|
-
EOH
|
110
|
-
end
|
111
|
-
|
112
|
-
def after_nodedelete
|
113
|
-
grove <<-EOH
|
114
|
-
#{current_user} deleted node #{object_name}
|
115
|
-
EOH
|
116
|
-
end
|
117
|
-
|
118
|
-
def after_nodecreate
|
119
|
-
grove <<-EOH
|
120
|
-
#{current_user} created node #{object_name}
|
121
|
-
EOH
|
122
|
-
end
|
123
|
-
|
124
|
-
def after_nodefromfile
|
125
|
-
grove <<-EOH
|
126
|
-
#{current_user} uploaded node #{object_name}
|
127
|
-
EOH
|
128
|
-
end
|
129
|
-
|
130
|
-
def after_noderunlistadd
|
131
|
-
grove <<-EOH
|
132
|
-
#{current_user} added run_list items to #{object_name}: #{object_secondary_name}
|
133
|
-
EOH
|
134
|
-
end
|
135
|
-
|
136
|
-
def after_noderunlistremove
|
137
|
-
grove <<-EOH
|
138
|
-
#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}
|
139
|
-
EOH
|
140
|
-
end
|
141
|
-
|
142
|
-
def after_noderunlistset
|
143
|
-
grove <<-EOH
|
144
|
-
#{current_user} set the run_list for #{object_name} to #{object_secondary_name}
|
145
|
-
EOH
|
146
|
-
end
|
147
|
-
|
148
|
-
private
|
149
|
-
def grove(message)
|
150
|
-
safe_require 'rest_client'
|
151
|
-
|
152
|
-
config.tokens.each do |token|
|
153
|
-
# Grove can't handle multi-line messages, so let's split by line
|
154
|
-
message.split("\n").flatten.delete_if(&:empty?).each do |line|
|
155
|
-
RestClient.post "https://grove.io/api/notice/#{token}/",
|
156
|
-
:message => line,
|
157
|
-
:service => 'knife-spork'
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def tokens
|
163
|
-
Array(config.token || config.tokens)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
1
|
+
require 'knife-spork/plugins/plugin'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
module Plugins
|
5
|
+
class Grove < Plugin
|
6
|
+
name :grove
|
7
|
+
|
8
|
+
def perform; end
|
9
|
+
|
10
|
+
def after_upload
|
11
|
+
grove <<-EOH
|
12
|
+
#{current_user} froze the following cookbooks on Chef Server: #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')}
|
13
|
+
EOH
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_delete
|
17
|
+
grove <<-EOH
|
18
|
+
#{organization}#{current_user} deleted the following cookbooks: #{misc_output}
|
19
|
+
EOH
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_promote_remote
|
23
|
+
grove <<-EOH
|
24
|
+
#{current_user} promoted #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')} on #{environments.collect{|e| "#{e.name}"}.join(', ')}
|
25
|
+
EOH
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_environmentfromfile
|
29
|
+
grove <<-EOH
|
30
|
+
#{current_user} uploaded environment #{object_name}
|
31
|
+
EOH
|
32
|
+
end
|
33
|
+
|
34
|
+
def after_environmentedit
|
35
|
+
grove <<-EOH
|
36
|
+
#{current_user} edited environment #{object_name}
|
37
|
+
EOH
|
38
|
+
end
|
39
|
+
|
40
|
+
def after_environmentcreate
|
41
|
+
grove <<-EOH
|
42
|
+
#{current_user} created environment #{object_name}
|
43
|
+
EOH
|
44
|
+
end
|
45
|
+
|
46
|
+
def after_environmentdelete
|
47
|
+
grove <<-EOH
|
48
|
+
#{current_user} deleted environment #{object_name}
|
49
|
+
EOH
|
50
|
+
end
|
51
|
+
|
52
|
+
def after_rolefromfile
|
53
|
+
grove <<-EOH
|
54
|
+
#{current_user} uploaded role #{object_name}
|
55
|
+
EOH
|
56
|
+
end
|
57
|
+
|
58
|
+
def after_roleedit
|
59
|
+
grove <<-EOH
|
60
|
+
#{current_user} edited role #{object_name}
|
61
|
+
EOH
|
62
|
+
end
|
63
|
+
|
64
|
+
def after_rolecreate
|
65
|
+
grove <<-EOH
|
66
|
+
#{current_user} created role #{object_name}
|
67
|
+
EOH
|
68
|
+
end
|
69
|
+
|
70
|
+
def after_roledelete
|
71
|
+
grove <<-EOH
|
72
|
+
#{current_user} deleted role #{object_name}
|
73
|
+
EOH
|
74
|
+
end
|
75
|
+
|
76
|
+
def after_databagcreate
|
77
|
+
grove <<-EOH
|
78
|
+
#{current_user} created data bag #{object_name}
|
79
|
+
EOH
|
80
|
+
end
|
81
|
+
|
82
|
+
def after_databagedit
|
83
|
+
grove <<-EOH
|
84
|
+
#{current_user} edited data bag item #{object_name}:#{object_secondary_name}
|
85
|
+
EOH
|
86
|
+
end
|
87
|
+
|
88
|
+
def after_databagitemdelete
|
89
|
+
grove <<-EOH
|
90
|
+
#{current_user} edited data bag item #{object_name}:#{object_secondary_name}
|
91
|
+
EOH
|
92
|
+
end
|
93
|
+
|
94
|
+
def after_databagdelete
|
95
|
+
grove <<-EOH
|
96
|
+
#{current_user} edited data bag #{object_name}
|
97
|
+
EOH
|
98
|
+
end
|
99
|
+
|
100
|
+
def after_databagfromfile
|
101
|
+
grove <<-EOH
|
102
|
+
#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}
|
103
|
+
EOH
|
104
|
+
end
|
105
|
+
|
106
|
+
def after_nodeedit
|
107
|
+
grove <<-EOH
|
108
|
+
#{current_user} edited node #{object_name}
|
109
|
+
EOH
|
110
|
+
end
|
111
|
+
|
112
|
+
def after_nodedelete
|
113
|
+
grove <<-EOH
|
114
|
+
#{current_user} deleted node #{object_name}
|
115
|
+
EOH
|
116
|
+
end
|
117
|
+
|
118
|
+
def after_nodecreate
|
119
|
+
grove <<-EOH
|
120
|
+
#{current_user} created node #{object_name}
|
121
|
+
EOH
|
122
|
+
end
|
123
|
+
|
124
|
+
def after_nodefromfile
|
125
|
+
grove <<-EOH
|
126
|
+
#{current_user} uploaded node #{object_name}
|
127
|
+
EOH
|
128
|
+
end
|
129
|
+
|
130
|
+
def after_noderunlistadd
|
131
|
+
grove <<-EOH
|
132
|
+
#{current_user} added run_list items to #{object_name}: #{object_secondary_name}
|
133
|
+
EOH
|
134
|
+
end
|
135
|
+
|
136
|
+
def after_noderunlistremove
|
137
|
+
grove <<-EOH
|
138
|
+
#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}
|
139
|
+
EOH
|
140
|
+
end
|
141
|
+
|
142
|
+
def after_noderunlistset
|
143
|
+
grove <<-EOH
|
144
|
+
#{current_user} set the run_list for #{object_name} to #{object_secondary_name}
|
145
|
+
EOH
|
146
|
+
end
|
147
|
+
|
148
|
+
private
|
149
|
+
def grove(message)
|
150
|
+
safe_require 'rest_client'
|
151
|
+
|
152
|
+
config.tokens.each do |token|
|
153
|
+
# Grove can't handle multi-line messages, so let's split by line
|
154
|
+
message.split("\n").flatten.delete_if(&:empty?).each do |line|
|
155
|
+
RestClient.post "https://grove.io/api/notice/#{token}/",
|
156
|
+
:message => line,
|
157
|
+
:service => 'knife-spork'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def tokens
|
163
|
+
Array(config.token || config.tokens)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -1,171 +1,171 @@
|
|
1
|
-
require 'knife-spork/plugins/plugin'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
module Plugins
|
5
|
-
class HipChat < Plugin
|
6
|
-
name :hipchat
|
7
|
-
|
8
|
-
def perform; end
|
9
|
-
|
10
|
-
def after_upload
|
11
|
-
hipchat "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def after_delete
|
15
|
-
hipchat "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def after_promote_remote
|
19
|
-
environments.each do |environment|
|
20
|
-
diff = environment_diffs[environment.name]
|
21
|
-
env_gist = env_gist(environment, diff) if config.gist
|
22
|
-
hipchat "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environment} #{env_gist}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def after_environmentfromfile
|
27
|
-
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
28
|
-
hipchat "#{organization}#{current_user} uploaded environment #{object_name} #{environment_gist}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def after_environmentedit
|
32
|
-
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
33
|
-
hipchat "#{organization}#{current_user} edited environment #{object_name} #{environment_gist}"
|
34
|
-
end
|
35
|
-
|
36
|
-
def after_environmentcreate
|
37
|
-
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
38
|
-
hipchat "#{organization}#{current_user} created environment #{object_name} #{environment_gist}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def after_environmentdelete
|
42
|
-
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
43
|
-
hipchat "#{organization}#{current_user} deleted environment #{object_name} #{environment_gist}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def after_rolefromfile
|
47
|
-
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
48
|
-
hipchat "#{organization}#{current_user} uploaded role #{object_name} #{role_gist}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def after_roleedit
|
52
|
-
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
53
|
-
hipchat "#{organization}#{current_user} edited role #{object_name} #{role_gist}"
|
54
|
-
end
|
55
|
-
|
56
|
-
def after_rolecreate
|
57
|
-
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
58
|
-
hipchat "#{organization}#{current_user} created role #{object_name} #{role_gist}"
|
59
|
-
end
|
60
|
-
|
61
|
-
def after_roledelete
|
62
|
-
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
63
|
-
hipchat "#{organization}#{current_user} deleted role #{object_name} #{role_gist}"
|
64
|
-
end
|
65
|
-
|
66
|
-
def after_databagedit
|
67
|
-
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
68
|
-
hipchat "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name} #{databag_gist}"
|
69
|
-
end
|
70
|
-
|
71
|
-
def after_databagcreate
|
72
|
-
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
73
|
-
hipchat "#{organization}#{current_user} created data bag #{object_name} #{databag_gist}"
|
74
|
-
end
|
75
|
-
|
76
|
-
def after_databagdelete
|
77
|
-
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
78
|
-
hipchat "#{organization}#{current_user} deleted data bag item #{object_name} #{databag_gist}"
|
79
|
-
end
|
80
|
-
|
81
|
-
def after_databagitemdelete
|
82
|
-
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
83
|
-
hipchat "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name} #{databag_gist}"
|
84
|
-
end
|
85
|
-
|
86
|
-
def after_databagfromfile
|
87
|
-
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
88
|
-
hipchat "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name} #{databag_gist}"
|
89
|
-
end
|
90
|
-
|
91
|
-
def after_nodeedit
|
92
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
93
|
-
hipchat "#{organization}#{current_user} edited node #{object_name} #{node_gist}"
|
94
|
-
end
|
95
|
-
|
96
|
-
def after_nodedelete
|
97
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
98
|
-
hipchat "#{organization}#{current_user} deleted node #{object_name} #{node_gist}"
|
99
|
-
end
|
100
|
-
|
101
|
-
def after_nodecreate
|
102
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
103
|
-
hipchat "#{organization}#{current_user} created node #{object_name} #{node_gist}"
|
104
|
-
end
|
105
|
-
|
106
|
-
def after_nodefromfile
|
107
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
108
|
-
hipchat "#{organization}#{current_user} uploaded node #{object_name} #{node_gist}"
|
109
|
-
end
|
110
|
-
|
111
|
-
def after_noderunlistadd
|
112
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
113
|
-
hipchat "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name} #{node_gist}"
|
114
|
-
end
|
115
|
-
|
116
|
-
def after_noderunlistremove
|
117
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
118
|
-
hipchat "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name} #{node_gist}"
|
119
|
-
end
|
120
|
-
|
121
|
-
def after_noderunlistset
|
122
|
-
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
123
|
-
hipchat "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name} #{node_gist}"
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
private
|
128
|
-
def hipchat(message)
|
129
|
-
safe_require 'hipchat'
|
130
|
-
|
131
|
-
rooms.each do |room_name|
|
132
|
-
begin
|
133
|
-
client = ::HipChat::Client.new(config.api_token, :api_version => config.api_version ||= 'v1', :server_url => config.server_url ||= 'https://api.hipchat.com')
|
134
|
-
client[room_name].send(nickname, message, :notify => notify, :color =>color)
|
135
|
-
rescue Exception => e
|
136
|
-
ui.error 'Something went wrong sending to HipChat.'
|
137
|
-
ui.error e.to_s
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def env_gist(environment, diff)
|
143
|
-
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}"
|
144
|
-
link = %x[ echo "#{msg}" | #{config.gist}]
|
145
|
-
return "<a href=\"#{link}\">Diff</a>" if !link.nil? || !link.empty?
|
146
|
-
end
|
147
|
-
|
148
|
-
def object_gist(object_type, object_name, object_diff)
|
149
|
-
msg = "#{object_type.capitalize} #{object_name} changed at #{Time.now.getutc} by #{current_user}\n\nDiff is as follows:\n\n#{object_diff}"
|
150
|
-
link = %x[ echo "#{msg}" | #{config.gist}]
|
151
|
-
return "<a href=\"#{link}\">Diff</a>" if !link.nil? || !link.empty?
|
152
|
-
end
|
153
|
-
|
154
|
-
def rooms
|
155
|
-
[ config.room || config.rooms ].flatten
|
156
|
-
end
|
157
|
-
|
158
|
-
def nickname
|
159
|
-
config.nickname || 'KnifeSpork'
|
160
|
-
end
|
161
|
-
|
162
|
-
def notify
|
163
|
-
config.notify.nil? ? true : config.notify
|
164
|
-
end
|
165
|
-
|
166
|
-
def color
|
167
|
-
config.color || 'yellow'
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
1
|
+
require 'knife-spork/plugins/plugin'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
module Plugins
|
5
|
+
class HipChat < Plugin
|
6
|
+
name :hipchat
|
7
|
+
|
8
|
+
def perform; end
|
9
|
+
|
10
|
+
def after_upload
|
11
|
+
hipchat "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def after_delete
|
15
|
+
hipchat "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def after_promote_remote
|
19
|
+
environments.each do |environment|
|
20
|
+
diff = environment_diffs[environment.name]
|
21
|
+
env_gist = env_gist(environment, diff) if config.gist
|
22
|
+
hipchat "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environment} #{env_gist}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def after_environmentfromfile
|
27
|
+
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
28
|
+
hipchat "#{organization}#{current_user} uploaded environment #{object_name} #{environment_gist}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def after_environmentedit
|
32
|
+
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
33
|
+
hipchat "#{organization}#{current_user} edited environment #{object_name} #{environment_gist}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def after_environmentcreate
|
37
|
+
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
38
|
+
hipchat "#{organization}#{current_user} created environment #{object_name} #{environment_gist}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def after_environmentdelete
|
42
|
+
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
43
|
+
hipchat "#{organization}#{current_user} deleted environment #{object_name} #{environment_gist}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def after_rolefromfile
|
47
|
+
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
48
|
+
hipchat "#{organization}#{current_user} uploaded role #{object_name} #{role_gist}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def after_roleedit
|
52
|
+
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
53
|
+
hipchat "#{organization}#{current_user} edited role #{object_name} #{role_gist}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def after_rolecreate
|
57
|
+
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
58
|
+
hipchat "#{organization}#{current_user} created role #{object_name} #{role_gist}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def after_roledelete
|
62
|
+
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
63
|
+
hipchat "#{organization}#{current_user} deleted role #{object_name} #{role_gist}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def after_databagedit
|
67
|
+
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
68
|
+
hipchat "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name} #{databag_gist}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def after_databagcreate
|
72
|
+
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
73
|
+
hipchat "#{organization}#{current_user} created data bag #{object_name} #{databag_gist}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def after_databagdelete
|
77
|
+
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
78
|
+
hipchat "#{organization}#{current_user} deleted data bag item #{object_name} #{databag_gist}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def after_databagitemdelete
|
82
|
+
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
83
|
+
hipchat "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name} #{databag_gist}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def after_databagfromfile
|
87
|
+
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
88
|
+
hipchat "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name} #{databag_gist}"
|
89
|
+
end
|
90
|
+
|
91
|
+
def after_nodeedit
|
92
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
93
|
+
hipchat "#{organization}#{current_user} edited node #{object_name} #{node_gist}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def after_nodedelete
|
97
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
98
|
+
hipchat "#{organization}#{current_user} deleted node #{object_name} #{node_gist}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def after_nodecreate
|
102
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
103
|
+
hipchat "#{organization}#{current_user} created node #{object_name} #{node_gist}"
|
104
|
+
end
|
105
|
+
|
106
|
+
def after_nodefromfile
|
107
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
108
|
+
hipchat "#{organization}#{current_user} uploaded node #{object_name} #{node_gist}"
|
109
|
+
end
|
110
|
+
|
111
|
+
def after_noderunlistadd
|
112
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
113
|
+
hipchat "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name} #{node_gist}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def after_noderunlistremove
|
117
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
118
|
+
hipchat "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name} #{node_gist}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def after_noderunlistset
|
122
|
+
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
123
|
+
hipchat "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name} #{node_gist}"
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
private
|
128
|
+
def hipchat(message)
|
129
|
+
safe_require 'hipchat'
|
130
|
+
|
131
|
+
rooms.each do |room_name|
|
132
|
+
begin
|
133
|
+
client = ::HipChat::Client.new(config.api_token, :api_version => config.api_version ||= 'v1', :server_url => config.server_url ||= 'https://api.hipchat.com')
|
134
|
+
client[room_name].send(nickname, message, :notify => notify, :color =>color)
|
135
|
+
rescue Exception => e
|
136
|
+
ui.error 'Something went wrong sending to HipChat.'
|
137
|
+
ui.error e.to_s
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def env_gist(environment, diff)
|
143
|
+
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}"
|
144
|
+
link = %x[ echo "#{msg}" | #{config.gist}]
|
145
|
+
return "<a href=\"#{link}\">Diff</a>" if !link.nil? || !link.empty?
|
146
|
+
end
|
147
|
+
|
148
|
+
def object_gist(object_type, object_name, object_diff)
|
149
|
+
msg = "#{object_type.capitalize} #{object_name} changed at #{Time.now.getutc} by #{current_user}\n\nDiff is as follows:\n\n#{object_diff}"
|
150
|
+
link = %x[ echo "#{msg}" | #{config.gist}]
|
151
|
+
return "<a href=\"#{link}\">Diff</a>" if !link.nil? || !link.empty?
|
152
|
+
end
|
153
|
+
|
154
|
+
def rooms
|
155
|
+
[ config.room || config.rooms ].flatten
|
156
|
+
end
|
157
|
+
|
158
|
+
def nickname
|
159
|
+
config.nickname || 'KnifeSpork'
|
160
|
+
end
|
161
|
+
|
162
|
+
def notify
|
163
|
+
config.notify.nil? ? true : config.notify
|
164
|
+
end
|
165
|
+
|
166
|
+
def color
|
167
|
+
config.color || 'yellow'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|