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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +35 -35
  3. data/lib/chef/knife/spork-bump.rb +100 -100
  4. data/lib/chef/knife/spork-check.rb +165 -161
  5. data/lib/chef/knife/spork-databag-create.rb +54 -54
  6. data/lib/chef/knife/spork-databag-delete.rb +51 -51
  7. data/lib/chef/knife/spork-databag-edit.rb +54 -54
  8. data/lib/chef/knife/spork-databag-fromfile.rb +88 -88
  9. data/lib/chef/knife/spork-delete.rb +132 -132
  10. data/lib/chef/knife/spork-environment-check.rb +90 -90
  11. data/lib/chef/knife/spork-environment-create.rb +63 -63
  12. data/lib/chef/knife/spork-environment-delete.rb +38 -38
  13. data/lib/chef/knife/spork-environment-edit.rb +40 -40
  14. data/lib/chef/knife/spork-environment-fromfile.rb +46 -46
  15. data/lib/chef/knife/spork-info.rb +34 -34
  16. data/lib/chef/knife/spork-node-create.rb +41 -41
  17. data/lib/chef/knife/spork-node-delete.rb +41 -41
  18. data/lib/chef/knife/spork-node-edit.rb +48 -48
  19. data/lib/chef/knife/spork-node-fromfile.rb +46 -46
  20. data/lib/chef/knife/spork-node-runlistadd.rb +51 -51
  21. data/lib/chef/knife/spork-node-runlistremove.rb +44 -44
  22. data/lib/chef/knife/spork-node-runlistset.rb +44 -44
  23. data/lib/chef/knife/spork-omni.rb +112 -112
  24. data/lib/chef/knife/spork-promote.rb +197 -197
  25. data/lib/chef/knife/spork-role-create.rb +46 -46
  26. data/lib/chef/knife/spork-role-delete.rb +50 -50
  27. data/lib/chef/knife/spork-role-edit.rb +40 -40
  28. data/lib/chef/knife/spork-role-fromfile.rb +65 -65
  29. data/lib/chef/knife/spork-upload.rb +151 -151
  30. data/lib/chef/knife/spork-version.rb +12 -12
  31. data/lib/knife-spork.rb +3 -3
  32. data/lib/knife-spork/plugins.rb +27 -27
  33. data/lib/knife-spork/plugins/campfire.rb +219 -219
  34. data/lib/knife-spork/plugins/eventinator.rb +329 -329
  35. data/lib/knife-spork/plugins/foodcritic.rb +46 -46
  36. data/lib/knife-spork/plugins/git.rb +393 -399
  37. data/lib/knife-spork/plugins/graphite.rb +25 -25
  38. data/lib/knife-spork/plugins/grove.rb +167 -167
  39. data/lib/knife-spork/plugins/hipchat.rb +171 -171
  40. data/lib/knife-spork/plugins/influxdb.rb +28 -28
  41. data/lib/knife-spork/plugins/irccat.rb +332 -332
  42. data/lib/knife-spork/plugins/jabber.rb +133 -133
  43. data/lib/knife-spork/plugins/plugin.rb +117 -117
  44. data/lib/knife-spork/plugins/rubocop.rb +56 -56
  45. data/lib/knife-spork/plugins/slack.rb +125 -125
  46. data/lib/knife-spork/plugins/statusnet.rb +122 -122
  47. data/lib/knife-spork/runner.rb +342 -342
  48. data/lib/knife-spork/version.rb +5 -5
  49. metadata +4 -51
  50. data/.gitignore +0 -21
  51. data/.ruby-gemset +0 -1
  52. data/.ruby-version +0 -1
  53. data/.travis.yml +0 -3
  54. data/CHANGELOG.md +0 -445
  55. data/Gemfile +0 -3
  56. data/README.md +0 -544
  57. data/Rakefile +0 -35
  58. data/knife-spork.gemspec +0 -28
  59. data/plugins/Campfire.md +0 -43
  60. data/plugins/Eventinator.md +0 -30
  61. data/plugins/Foodcritic.md +0 -53
  62. data/plugins/Git.md +0 -53
  63. data/plugins/Graphite.md +0 -30
  64. data/plugins/Grove.md +0 -31
  65. data/plugins/HipChat.md +0 -69
  66. data/plugins/Influxdb.md +0 -25
  67. data/plugins/Irccat.md +0 -50
  68. data/plugins/Jabber.md +0 -61
  69. data/plugins/README.md +0 -70
  70. data/plugins/Rubocop.md +0 -110
  71. data/plugins/Slack.md +0 -48
  72. data/plugins/StatusNet.md +0 -41
  73. data/plugins/Template.md +0 -34
  74. data/spec/spec_helper.rb +0 -10
  75. data/spec/test_helpers.rb +0 -46
  76. data/spec/unit/fixtures/config/spork-config.yml +0 -1
  77. data/spec/unit/fixtures/cookbooks/example/metadata.rb +0 -8
  78. data/spec/unit/fixtures/environments/example.json +0 -12
  79. data/spec/unit/fixtures/knife.rb +0 -6
  80. data/spec/unit/fixtures/test_client.pem +0 -27
  81. data/spec/unit/spork_bump_spec.rb +0 -75
  82. data/spec/unit/spork_info_spec.rb +0 -40
  83. data/spec/unit/spork_promote_spec.rb +0 -77
  84. data/spec/unit/spork_upload_spec.rb +0 -46
@@ -1,133 +1,133 @@
1
- require 'knife-spork/plugins/plugin'
2
-
3
- module KnifeSpork
4
- module Plugins
5
- class Jabber < Plugin
6
- name :jabber
7
-
8
- def perform; end
9
-
10
- def after_upload
11
- jabber "#{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
- jabber "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
16
- end
17
-
18
- def after_promote_remote
19
- jabber "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
20
- end
21
-
22
- def after_environmentfromfile
23
- jabber "#{organization}#{current_user} uploaded environment #{object_name}"
24
- end
25
-
26
- def after_environmentedit
27
- jabber "#{organization}#{current_user} edited environment #{object_name}"
28
- end
29
-
30
- def after_environmentcreate
31
- jabber "#{organization}#{current_user} created environment #{object_name}"
32
- end
33
-
34
- def after_environmentdelete
35
- jabber "#{organization}#{current_user} deleted environment #{object_name}"
36
- end
37
-
38
- def after_rolefromfile
39
- jabber "#{organization}#{current_user} uploaded role #{object_name}"
40
- end
41
-
42
- def after_roleedit
43
- jabber "#{organization}#{current_user} edited role #{object_name}"
44
- end
45
-
46
- def after_rolecreate
47
- jabber "#{organization}#{current_user} created role #{object_name}"
48
- end
49
-
50
- def after_roledelete
51
- jabber "#{organization}#{current_user} deleted role #{object_name}"
52
- end
53
-
54
- def after_databagedit
55
- jabber "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}"
56
- end
57
-
58
- def after_databagcreate
59
- jabber "#{organization}#{current_user} created data bag #{object_name}"
60
- end
61
-
62
- def after_databagdelete
63
- jabber "#{organization}#{current_user} deleted data bag #{object_name}"
64
- end
65
-
66
- def after_databagitemdelete
67
- jabber "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}"
68
- end
69
-
70
- def after_databagfromfile
71
- jabber "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}"
72
- end
73
-
74
- def after_nodeedit
75
- jabber "#{organization}#{current_user} edited node #{object_name}"
76
- end
77
-
78
- def after_nodedelete
79
- jabber "#{organization}#{current_user} deleted node #{object_name}"
80
- end
81
-
82
- def after_nodecreate
83
- jabber "#{organization}#{current_user} created node #{object_name}"
84
- end
85
-
86
- def after_nodefromfile
87
- jabber "#{organization}#{current_user} uploaded node #{object_name}"
88
- end
89
-
90
- def after_noderunlistadd
91
- jabber "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}"
92
- end
93
-
94
- def after_noderunlistremove
95
- jabber "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}"
96
- end
97
-
98
- def after_noderunlistset
99
- jabber "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}"
100
- end
101
-
102
- private
103
-
104
- def jabber(message)
105
- safe_require 'xmpp4r'
106
- safe_require 'xmpp4r/muc/helper/simplemucclient'
107
-
108
- client = ::Jabber::Client.new(config.username)
109
- client.connect(host = config.server_name, port = config.server_port ||= '5222')
110
- client.auth(config.password)
111
-
112
- rooms.each do |room_name|
113
- begin
114
- conference = ::Jabber::MUC::SimpleMUCClient.new(client)
115
- conference.join("#{room_name}/#{nickname}")
116
- conference.say(message)
117
- rescue Exception => e
118
- ui.error 'Something went wrong sending to Jabber.'
119
- ui.error e.to_s
120
- end
121
- end
122
- end
123
-
124
- def rooms
125
- [ config.room || config.rooms ].flatten
126
- end
127
-
128
- def nickname
129
- config.nickname || 'KnifeSpork'
130
- end
131
- end
132
- end
133
- end
1
+ require 'knife-spork/plugins/plugin'
2
+
3
+ module KnifeSpork
4
+ module Plugins
5
+ class Jabber < Plugin
6
+ name :jabber
7
+
8
+ def perform; end
9
+
10
+ def after_upload
11
+ jabber "#{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
+ jabber "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
16
+ end
17
+
18
+ def after_promote_remote
19
+ jabber "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
20
+ end
21
+
22
+ def after_environmentfromfile
23
+ jabber "#{organization}#{current_user} uploaded environment #{object_name}"
24
+ end
25
+
26
+ def after_environmentedit
27
+ jabber "#{organization}#{current_user} edited environment #{object_name}"
28
+ end
29
+
30
+ def after_environmentcreate
31
+ jabber "#{organization}#{current_user} created environment #{object_name}"
32
+ end
33
+
34
+ def after_environmentdelete
35
+ jabber "#{organization}#{current_user} deleted environment #{object_name}"
36
+ end
37
+
38
+ def after_rolefromfile
39
+ jabber "#{organization}#{current_user} uploaded role #{object_name}"
40
+ end
41
+
42
+ def after_roleedit
43
+ jabber "#{organization}#{current_user} edited role #{object_name}"
44
+ end
45
+
46
+ def after_rolecreate
47
+ jabber "#{organization}#{current_user} created role #{object_name}"
48
+ end
49
+
50
+ def after_roledelete
51
+ jabber "#{organization}#{current_user} deleted role #{object_name}"
52
+ end
53
+
54
+ def after_databagedit
55
+ jabber "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}"
56
+ end
57
+
58
+ def after_databagcreate
59
+ jabber "#{organization}#{current_user} created data bag #{object_name}"
60
+ end
61
+
62
+ def after_databagdelete
63
+ jabber "#{organization}#{current_user} deleted data bag #{object_name}"
64
+ end
65
+
66
+ def after_databagitemdelete
67
+ jabber "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}"
68
+ end
69
+
70
+ def after_databagfromfile
71
+ jabber "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}"
72
+ end
73
+
74
+ def after_nodeedit
75
+ jabber "#{organization}#{current_user} edited node #{object_name}"
76
+ end
77
+
78
+ def after_nodedelete
79
+ jabber "#{organization}#{current_user} deleted node #{object_name}"
80
+ end
81
+
82
+ def after_nodecreate
83
+ jabber "#{organization}#{current_user} created node #{object_name}"
84
+ end
85
+
86
+ def after_nodefromfile
87
+ jabber "#{organization}#{current_user} uploaded node #{object_name}"
88
+ end
89
+
90
+ def after_noderunlistadd
91
+ jabber "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}"
92
+ end
93
+
94
+ def after_noderunlistremove
95
+ jabber "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}"
96
+ end
97
+
98
+ def after_noderunlistset
99
+ jabber "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}"
100
+ end
101
+
102
+ private
103
+
104
+ def jabber(message)
105
+ safe_require 'xmpp4r'
106
+ safe_require 'xmpp4r/muc/helper/simplemucclient'
107
+
108
+ client = ::Jabber::Client.new(config.username)
109
+ client.connect(host = config.server_name, port = config.server_port ||= '5222')
110
+ client.auth(config.password)
111
+
112
+ rooms.each do |room_name|
113
+ begin
114
+ conference = ::Jabber::MUC::SimpleMUCClient.new(client)
115
+ conference.join("#{room_name}/#{nickname}")
116
+ conference.say(message)
117
+ rescue Exception => e
118
+ ui.error 'Something went wrong sending to Jabber.'
119
+ ui.error e.to_s
120
+ end
121
+ end
122
+ end
123
+
124
+ def rooms
125
+ [ config.room || config.rooms ].flatten
126
+ end
127
+
128
+ def nickname
129
+ config.nickname || 'KnifeSpork'
130
+ end
131
+ end
132
+ end
133
+ end
@@ -1,117 +1,117 @@
1
- module KnifeSpork
2
- module Plugins
3
- class Plugin
4
- # This is the name of the plugin. It must correspond to the name in the yaml configuration
5
- # file in order to load this plugin. If an attribute is passed in, the name is set to that
6
- # given value. Otherwise, the name is returned.
7
- def self.name(name = nil)
8
- if name.nil?
9
- class_variable_get(:@@name)
10
- else
11
- class_variable_set(:@@name, name)
12
- end
13
- end
14
-
15
- # This is a convenience method for defining multiple hooks in a single call.
16
- def self.hooks(*the_hooks)
17
- [the_hooks].flatten.each{ |the_hook| hook(the_hook) }
18
- end
19
-
20
- # When defining a hook, we define a method on the instance that corresponds to that
21
- # hook. That will be fired when the hook is fired.
22
- def self.hook(the_hook)
23
- self.send(:define_method, the_hook.to_sym) do
24
- perform
25
- end
26
- end
27
-
28
- def initialize(options = {})
29
- @options = {
30
- :payload => {}
31
- }.merge(options)
32
- end
33
-
34
- def enabled?
35
- !(config.nil? || config.enabled == false)
36
- end
37
-
38
- private
39
- def config
40
- @options[:config].plugins.send(self.class.name.to_sym) unless @options[:config].nil? || @options[:config].plugins.nil?
41
- end
42
-
43
- def organization
44
- unless ::Chef::Config.chef_server_url.nil?
45
- split_server_url = Chef::Config.chef_server_url.gsub(/http(s)?:\/\//,"").split('/')
46
- if split_server_url.length > 1
47
- return "#{split_server_url.last}: "
48
- end
49
- end
50
-
51
- nil
52
- end
53
-
54
- def cookbooks
55
- @options[:cookbooks]
56
- end
57
-
58
- def environments
59
- @options[:environments]
60
- end
61
-
62
- def environment_diffs
63
- @options[:environment_diffs]
64
- end
65
-
66
- def environment_path
67
- @options[:environment_path]
68
- end
69
-
70
- def cookbook_path
71
- @options[:cookbook_path]
72
- end
73
-
74
- def role_path
75
- File.expand_path(config.role_path.nil? ? "#{cookbook_path}/../roles" : config[:role_path])
76
- end
77
-
78
- def node_path
79
- File.expand_path(config.role_path.nil? ? "#{cookbook_path}/../nodes" : config[:role_path])
80
- end
81
-
82
- def object_name
83
- @options[:object_name]
84
- end
85
-
86
- def object_secondary_name
87
- @options[:object_secondary_name]
88
- end
89
-
90
- def object_difference
91
- @options[:object_difference]
92
- end
93
-
94
- def misc_output
95
- @options[:misc_output]
96
- end
97
-
98
- def ui
99
- @options[:ui]
100
- end
101
-
102
- def current_user
103
- (begin `git config user.name`.chomp; rescue nil; end || ENV['USERNAME'] || ENV['USER']).strip
104
- end
105
-
106
- # Wrapper method around require that attempts to include the associated file. If it does not exist
107
- # or cannot be loaded, an nice error is produced instead of blowing up.
108
- def safe_require(file)
109
- begin
110
- require file
111
- rescue LoadError
112
- raise "You are using a plugin for knife-spork that requires #{file}, but you have not installed it. Please either run \"gem install #{file}\", add #{file} to your Gemfile or remove the plugin from your configuration."
113
- end
114
- end
115
- end
116
- end
117
- end
1
+ module KnifeSpork
2
+ module Plugins
3
+ class Plugin
4
+ # This is the name of the plugin. It must correspond to the name in the yaml configuration
5
+ # file in order to load this plugin. If an attribute is passed in, the name is set to that
6
+ # given value. Otherwise, the name is returned.
7
+ def self.name(name = nil)
8
+ if name.nil?
9
+ class_variable_get(:@@name)
10
+ else
11
+ class_variable_set(:@@name, name)
12
+ end
13
+ end
14
+
15
+ # This is a convenience method for defining multiple hooks in a single call.
16
+ def self.hooks(*the_hooks)
17
+ [the_hooks].flatten.each{ |the_hook| hook(the_hook) }
18
+ end
19
+
20
+ # When defining a hook, we define a method on the instance that corresponds to that
21
+ # hook. That will be fired when the hook is fired.
22
+ def self.hook(the_hook)
23
+ self.send(:define_method, the_hook.to_sym) do
24
+ perform
25
+ end
26
+ end
27
+
28
+ def initialize(options = {})
29
+ @options = {
30
+ :payload => {}
31
+ }.merge(options)
32
+ end
33
+
34
+ def enabled?
35
+ !(config.nil? || config.enabled == false)
36
+ end
37
+
38
+ private
39
+ def config
40
+ @options[:config].plugins.send(self.class.name.to_sym) unless @options[:config].nil? || @options[:config].plugins.nil?
41
+ end
42
+
43
+ def organization
44
+ unless ::Chef::Config.chef_server_url.nil?
45
+ split_server_url = Chef::Config.chef_server_url.gsub(/http(s)?:\/\//,"").split('/')
46
+ if split_server_url.length > 1
47
+ return "#{split_server_url.last}: "
48
+ end
49
+ end
50
+
51
+ nil
52
+ end
53
+
54
+ def cookbooks
55
+ @options[:cookbooks]
56
+ end
57
+
58
+ def environments
59
+ @options[:environments]
60
+ end
61
+
62
+ def environment_diffs
63
+ @options[:environment_diffs]
64
+ end
65
+
66
+ def environment_path
67
+ @options[:environment_path]
68
+ end
69
+
70
+ def cookbook_path
71
+ @options[:cookbook_path]
72
+ end
73
+
74
+ def role_path
75
+ File.expand_path(config.role_path.nil? ? "#{cookbook_path}/../roles" : config[:role_path])
76
+ end
77
+
78
+ def node_path
79
+ File.expand_path(config.role_path.nil? ? "#{cookbook_path}/../nodes" : config[:role_path])
80
+ end
81
+
82
+ def object_name
83
+ @options[:object_name]
84
+ end
85
+
86
+ def object_secondary_name
87
+ @options[:object_secondary_name]
88
+ end
89
+
90
+ def object_difference
91
+ @options[:object_difference]
92
+ end
93
+
94
+ def misc_output
95
+ @options[:misc_output]
96
+ end
97
+
98
+ def ui
99
+ @options[:ui]
100
+ end
101
+
102
+ def current_user
103
+ (begin `git config user.name`.chomp; rescue nil; end || ENV['USERNAME'] || ENV['USER']).strip
104
+ end
105
+
106
+ # Wrapper method around require that attempts to include the associated file. If it does not exist
107
+ # or cannot be loaded, an nice error is produced instead of blowing up.
108
+ def safe_require(file)
109
+ begin
110
+ require file
111
+ rescue LoadError
112
+ raise "You are using a plugin for knife-spork that requires #{file}, but you have not installed it. Please either run \"gem install #{file}\", add #{file} to your Gemfile or remove the plugin from your configuration."
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end