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,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
|