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,54 +1,54 @@
|
|
1
|
-
require 'chef/knife'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
class SporkDataBagCreate < Chef::Knife
|
5
|
-
|
6
|
-
deps do
|
7
|
-
require 'knife-spork/runner'
|
8
|
-
require 'json'
|
9
|
-
require 'chef/knife/data_bag_create'
|
10
|
-
end
|
11
|
-
|
12
|
-
banner 'knife spork data bag create BAG [ITEM] (options)'
|
13
|
-
|
14
|
-
option :secret,
|
15
|
-
:short => "-s SECRET",
|
16
|
-
:long => "--secret ",
|
17
|
-
:description => "The secret key to use to encrypt data bag item values"
|
18
|
-
|
19
|
-
option :secret_file,
|
20
|
-
:long => "--secret-file SECRET_FILE",
|
21
|
-
:description => "A file containing the secret key to use to encrypt data bag item values"
|
22
|
-
|
23
|
-
def run
|
24
|
-
self.class.send(:include, KnifeSpork::Runner)
|
25
|
-
self.config = Chef::Config.merge!(config)
|
26
|
-
|
27
|
-
if @name_args.nil?
|
28
|
-
ui.error "You must specify a data bag name"
|
29
|
-
ui.error opt_parser
|
30
|
-
exit 1
|
31
|
-
end
|
32
|
-
|
33
|
-
@object_name = @name_args.first
|
34
|
-
@object_secondary_name = @name_args.last
|
35
|
-
|
36
|
-
run_plugins(:before_databagcreate)
|
37
|
-
pre_databag = {}
|
38
|
-
databag_create
|
39
|
-
post_databag = load_databag_item(@object_name, @object_secondary_name)
|
40
|
-
@object_difference = json_diff(pre_databag,post_databag).to_s
|
41
|
-
run_plugins(:after_databagcreate)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def databag_create
|
46
|
-
dbc = Chef::Knife::DataBagCreate.new
|
47
|
-
dbc.name_args = @name_args
|
48
|
-
dbc.config[:editor] = config[:editor]
|
49
|
-
dbc.config[:secret] = config[:secret]
|
50
|
-
dbc.config[:secret_file] = config[:secret_file]
|
51
|
-
dbc.run
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
class SporkDataBagCreate < Chef::Knife
|
5
|
+
|
6
|
+
deps do
|
7
|
+
require 'knife-spork/runner'
|
8
|
+
require 'json'
|
9
|
+
require 'chef/knife/data_bag_create'
|
10
|
+
end
|
11
|
+
|
12
|
+
banner 'knife spork data bag create BAG [ITEM] (options)'
|
13
|
+
|
14
|
+
option :secret,
|
15
|
+
:short => "-s SECRET",
|
16
|
+
:long => "--secret ",
|
17
|
+
:description => "The secret key to use to encrypt data bag item values"
|
18
|
+
|
19
|
+
option :secret_file,
|
20
|
+
:long => "--secret-file SECRET_FILE",
|
21
|
+
:description => "A file containing the secret key to use to encrypt data bag item values"
|
22
|
+
|
23
|
+
def run
|
24
|
+
self.class.send(:include, KnifeSpork::Runner)
|
25
|
+
self.config = Chef::Config.merge!(config)
|
26
|
+
|
27
|
+
if @name_args.nil?
|
28
|
+
ui.error "You must specify a data bag name"
|
29
|
+
ui.error opt_parser
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
@object_name = @name_args.first
|
34
|
+
@object_secondary_name = @name_args.last
|
35
|
+
|
36
|
+
run_plugins(:before_databagcreate)
|
37
|
+
pre_databag = {}
|
38
|
+
databag_create
|
39
|
+
post_databag = load_databag_item(@object_name, @object_secondary_name)
|
40
|
+
@object_difference = json_diff(pre_databag,post_databag).to_s
|
41
|
+
run_plugins(:after_databagcreate)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def databag_create
|
46
|
+
dbc = Chef::Knife::DataBagCreate.new
|
47
|
+
dbc.name_args = @name_args
|
48
|
+
dbc.config[:editor] = config[:editor]
|
49
|
+
dbc.config[:secret] = config[:secret]
|
50
|
+
dbc.config[:secret_file] = config[:secret_file]
|
51
|
+
dbc.run
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require 'chef/knife'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
class SporkDataBagDelete < Chef::Knife
|
5
|
-
|
6
|
-
deps do
|
7
|
-
require 'knife-spork/runner'
|
8
|
-
require 'json'
|
9
|
-
require 'chef/knife/data_bag_delete'
|
10
|
-
end
|
11
|
-
|
12
|
-
banner 'knife spork data bag delete BAG [ITEM] (options)'
|
13
|
-
|
14
|
-
|
15
|
-
def run
|
16
|
-
self.class.send(:include, KnifeSpork::Runner)
|
17
|
-
self.config = Chef::Config.merge!(config)
|
18
|
-
|
19
|
-
if @name_args.length == 2
|
20
|
-
@object_name = @name_args.first
|
21
|
-
@object_secondary_name = @name_args.last
|
22
|
-
run_plugins(:before_databagitemdelete)
|
23
|
-
pre_databag = load_databag_item(@object_name,@object_secondary_name)
|
24
|
-
databag_delete
|
25
|
-
post_databag = {}
|
26
|
-
@object_difference = json_diff(pre_databag,post_databag).to_s
|
27
|
-
run_plugins(:after_databagitemdelete)
|
28
|
-
elsif @name_args.length == 1
|
29
|
-
@object_name = @name_args.first
|
30
|
-
run_plugins(:before_databagdelete)
|
31
|
-
pre_databag = load_databag(@object_name)
|
32
|
-
databag_delete
|
33
|
-
post_databag = {}
|
34
|
-
@object_difference = json_diff(pre_databag,post_databag).to_s
|
35
|
-
run_plugins(:after_databagdelete)
|
36
|
-
else
|
37
|
-
show_usage
|
38
|
-
ui.fatal("You must specify at least a data bag name")
|
39
|
-
exit 1
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def databag_delete
|
45
|
-
dbd = Chef::Knife::DataBagDelete.new
|
46
|
-
dbd.name_args = @name_args
|
47
|
-
dbd.config[:editor] = config[:editor]
|
48
|
-
dbd.run
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
class SporkDataBagDelete < Chef::Knife
|
5
|
+
|
6
|
+
deps do
|
7
|
+
require 'knife-spork/runner'
|
8
|
+
require 'json'
|
9
|
+
require 'chef/knife/data_bag_delete'
|
10
|
+
end
|
11
|
+
|
12
|
+
banner 'knife spork data bag delete BAG [ITEM] (options)'
|
13
|
+
|
14
|
+
|
15
|
+
def run
|
16
|
+
self.class.send(:include, KnifeSpork::Runner)
|
17
|
+
self.config = Chef::Config.merge!(config)
|
18
|
+
|
19
|
+
if @name_args.length == 2
|
20
|
+
@object_name = @name_args.first
|
21
|
+
@object_secondary_name = @name_args.last
|
22
|
+
run_plugins(:before_databagitemdelete)
|
23
|
+
pre_databag = load_databag_item(@object_name,@object_secondary_name)
|
24
|
+
databag_delete
|
25
|
+
post_databag = {}
|
26
|
+
@object_difference = json_diff(pre_databag,post_databag).to_s
|
27
|
+
run_plugins(:after_databagitemdelete)
|
28
|
+
elsif @name_args.length == 1
|
29
|
+
@object_name = @name_args.first
|
30
|
+
run_plugins(:before_databagdelete)
|
31
|
+
pre_databag = load_databag(@object_name)
|
32
|
+
databag_delete
|
33
|
+
post_databag = {}
|
34
|
+
@object_difference = json_diff(pre_databag,post_databag).to_s
|
35
|
+
run_plugins(:after_databagdelete)
|
36
|
+
else
|
37
|
+
show_usage
|
38
|
+
ui.fatal("You must specify at least a data bag name")
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def databag_delete
|
45
|
+
dbd = Chef::Knife::DataBagDelete.new
|
46
|
+
dbd.name_args = @name_args
|
47
|
+
dbd.config[:editor] = config[:editor]
|
48
|
+
dbd.run
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,54 +1,54 @@
|
|
1
|
-
require 'chef/knife'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
class SporkDataBagEdit < Chef::Knife
|
5
|
-
|
6
|
-
deps do
|
7
|
-
require 'knife-spork/runner'
|
8
|
-
require 'json'
|
9
|
-
require 'chef/knife/data_bag_edit'
|
10
|
-
end
|
11
|
-
|
12
|
-
banner 'knife spork data bag edit BAG ITEM (options)'
|
13
|
-
|
14
|
-
option :secret,
|
15
|
-
:short => "-s SECRET",
|
16
|
-
:long => "--secret ",
|
17
|
-
:description => "The secret key to use to encrypt data bag item values"
|
18
|
-
|
19
|
-
option :secret_file,
|
20
|
-
:long => "--secret-file SECRET_FILE",
|
21
|
-
:description => "A file containing the secret key to use to encrypt data bag item values"
|
22
|
-
|
23
|
-
def run
|
24
|
-
self.class.send(:include, KnifeSpork::Runner)
|
25
|
-
self.config = Chef::Config.merge!(config)
|
26
|
-
|
27
|
-
if @name_args.length != 2
|
28
|
-
ui.error "You must supply the data bag and an item to edit!"
|
29
|
-
ui.error opt_parser
|
30
|
-
exit 1
|
31
|
-
end
|
32
|
-
|
33
|
-
@object_name = @name_args.first
|
34
|
-
@object_secondary_name = @name_args.last
|
35
|
-
|
36
|
-
run_plugins(:before_databagedit)
|
37
|
-
pre_databag = load_databag_item(@object_name, @object_secondary_name)
|
38
|
-
databag_edit
|
39
|
-
post_databag = load_databag_item(@object_name, @object_secondary_name)
|
40
|
-
@object_difference = json_diff(pre_databag,post_databag).to_s
|
41
|
-
run_plugins(:after_databagedit)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def databag_edit
|
46
|
-
dbe = Chef::Knife::DataBagEdit.new
|
47
|
-
dbe.name_args = @name_args
|
48
|
-
dbe.config[:editor] = config[:editor]
|
49
|
-
dbe.config[:secret] = config[:secret]
|
50
|
-
dbe.config[:secret_file] = config[:secret_file]
|
51
|
-
dbe.run
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
class SporkDataBagEdit < Chef::Knife
|
5
|
+
|
6
|
+
deps do
|
7
|
+
require 'knife-spork/runner'
|
8
|
+
require 'json'
|
9
|
+
require 'chef/knife/data_bag_edit'
|
10
|
+
end
|
11
|
+
|
12
|
+
banner 'knife spork data bag edit BAG ITEM (options)'
|
13
|
+
|
14
|
+
option :secret,
|
15
|
+
:short => "-s SECRET",
|
16
|
+
:long => "--secret ",
|
17
|
+
:description => "The secret key to use to encrypt data bag item values"
|
18
|
+
|
19
|
+
option :secret_file,
|
20
|
+
:long => "--secret-file SECRET_FILE",
|
21
|
+
:description => "A file containing the secret key to use to encrypt data bag item values"
|
22
|
+
|
23
|
+
def run
|
24
|
+
self.class.send(:include, KnifeSpork::Runner)
|
25
|
+
self.config = Chef::Config.merge!(config)
|
26
|
+
|
27
|
+
if @name_args.length != 2
|
28
|
+
ui.error "You must supply the data bag and an item to edit!"
|
29
|
+
ui.error opt_parser
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
@object_name = @name_args.first
|
34
|
+
@object_secondary_name = @name_args.last
|
35
|
+
|
36
|
+
run_plugins(:before_databagedit)
|
37
|
+
pre_databag = load_databag_item(@object_name, @object_secondary_name)
|
38
|
+
databag_edit
|
39
|
+
post_databag = load_databag_item(@object_name, @object_secondary_name)
|
40
|
+
@object_difference = json_diff(pre_databag,post_databag).to_s
|
41
|
+
run_plugins(:after_databagedit)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def databag_edit
|
46
|
+
dbe = Chef::Knife::DataBagEdit.new
|
47
|
+
dbe.name_args = @name_args
|
48
|
+
dbe.config[:editor] = config[:editor]
|
49
|
+
dbe.config[:secret] = config[:secret]
|
50
|
+
dbe.config[:secret_file] = config[:secret_file]
|
51
|
+
dbe.run
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,88 +1,88 @@
|
|
1
|
-
require 'chef/knife'
|
2
|
-
|
3
|
-
module KnifeSpork
|
4
|
-
class SporkDataBagFromFile < Chef::Knife
|
5
|
-
|
6
|
-
deps do
|
7
|
-
require 'knife-spork/runner'
|
8
|
-
require 'json'
|
9
|
-
require 'chef/knife/data_bag_from_file'
|
10
|
-
end
|
11
|
-
|
12
|
-
banner 'knife spork data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)'
|
13
|
-
|
14
|
-
option :secret,
|
15
|
-
:short => "-s SECRET",
|
16
|
-
:long => "--secret ",
|
17
|
-
:description => "The secret key to use to encrypt data bag item values"
|
18
|
-
|
19
|
-
option :secret_file,
|
20
|
-
:long => "--secret-file SECRET_FILE",
|
21
|
-
:description => "A file containing the secret key to use to encrypt data bag item values"
|
22
|
-
|
23
|
-
option :all,
|
24
|
-
:short => "-a",
|
25
|
-
:long => "--all",
|
26
|
-
:description => "Upload all data bags"
|
27
|
-
|
28
|
-
def run
|
29
|
-
self.class.send(:include, KnifeSpork::Runner)
|
30
|
-
self.config = Chef::Config.merge!(config)
|
31
|
-
|
32
|
-
@object_name = @name_args.first
|
33
|
-
# This should be the data bag name. If it isn't, some poor soul forgot the data bag name.
|
34
|
-
# Check to see if there are any more arguments, and if not, warn about usage.
|
35
|
-
if @name_args.drop(1).size == 0
|
36
|
-
print "USAGE: #{banner}"
|
37
|
-
exit(1)
|
38
|
-
end
|
39
|
-
|
40
|
-
if config[:all] == true
|
41
|
-
test = Chef::Knife::DataBagFromFile.new
|
42
|
-
test.config[:verbosity] = 3
|
43
|
-
databags = test.send(:find_all_data_bags)
|
44
|
-
databags.each do |bag|
|
45
|
-
test.send(:find_all_data_bag_items,bag).each do |item|
|
46
|
-
@object_name = bag
|
47
|
-
@object_secondary_name = item.split("/").last
|
48
|
-
run_plugins(:before_databagfromfile)
|
49
|
-
begin
|
50
|
-
pre_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
51
|
-
rescue
|
52
|
-
pre_databag = {}
|
53
|
-
end
|
54
|
-
databag_from_file([@object_name,@object_secondary_name])
|
55
|
-
post_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
56
|
-
@object_difference = json_diff(pre_databag,post_databag).to_s
|
57
|
-
run_plugins(:after_databagfromfile)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
else
|
62
|
-
@name_args[1..-1].each do |arg|
|
63
|
-
@object_secondary_name = arg.split("/").last
|
64
|
-
run_plugins(:before_databagfromfile)
|
65
|
-
begin
|
66
|
-
pre_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
67
|
-
rescue
|
68
|
-
pre_databag = {}
|
69
|
-
end
|
70
|
-
databag_from_file
|
71
|
-
post_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
72
|
-
@object_difference = json_diff(pre_databag,post_databag).to_s
|
73
|
-
run_plugins(:after_databagfromfile)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
def databag_from_file(data_bag_names=nil)
|
80
|
-
dbff = Chef::Knife::DataBagFromFile.new
|
81
|
-
dbff.name_args = data_bag_names || @name_args
|
82
|
-
dbff.config[:editor] = config[:editor]
|
83
|
-
dbff.config[:secret] = config[:secret]
|
84
|
-
dbff.config[:secret_file] = config[:secret_file]
|
85
|
-
dbff.run
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
module KnifeSpork
|
4
|
+
class SporkDataBagFromFile < Chef::Knife
|
5
|
+
|
6
|
+
deps do
|
7
|
+
require 'knife-spork/runner'
|
8
|
+
require 'json'
|
9
|
+
require 'chef/knife/data_bag_from_file'
|
10
|
+
end
|
11
|
+
|
12
|
+
banner 'knife spork data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)'
|
13
|
+
|
14
|
+
option :secret,
|
15
|
+
:short => "-s SECRET",
|
16
|
+
:long => "--secret ",
|
17
|
+
:description => "The secret key to use to encrypt data bag item values"
|
18
|
+
|
19
|
+
option :secret_file,
|
20
|
+
:long => "--secret-file SECRET_FILE",
|
21
|
+
:description => "A file containing the secret key to use to encrypt data bag item values"
|
22
|
+
|
23
|
+
option :all,
|
24
|
+
:short => "-a",
|
25
|
+
:long => "--all",
|
26
|
+
:description => "Upload all data bags"
|
27
|
+
|
28
|
+
def run
|
29
|
+
self.class.send(:include, KnifeSpork::Runner)
|
30
|
+
self.config = Chef::Config.merge!(config)
|
31
|
+
|
32
|
+
@object_name = @name_args.first
|
33
|
+
# This should be the data bag name. If it isn't, some poor soul forgot the data bag name.
|
34
|
+
# Check to see if there are any more arguments, and if not, warn about usage.
|
35
|
+
if @name_args.drop(1).size == 0
|
36
|
+
print "USAGE: #{banner}"
|
37
|
+
exit(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
if config[:all] == true
|
41
|
+
test = Chef::Knife::DataBagFromFile.new
|
42
|
+
test.config[:verbosity] = 3
|
43
|
+
databags = test.send(:find_all_data_bags)
|
44
|
+
databags.each do |bag|
|
45
|
+
test.send(:find_all_data_bag_items,bag).each do |item|
|
46
|
+
@object_name = bag
|
47
|
+
@object_secondary_name = item.split("/").last
|
48
|
+
run_plugins(:before_databagfromfile)
|
49
|
+
begin
|
50
|
+
pre_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
51
|
+
rescue
|
52
|
+
pre_databag = {}
|
53
|
+
end
|
54
|
+
databag_from_file([@object_name,@object_secondary_name])
|
55
|
+
post_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
56
|
+
@object_difference = json_diff(pre_databag,post_databag).to_s
|
57
|
+
run_plugins(:after_databagfromfile)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
else
|
62
|
+
@name_args[1..-1].each do |arg|
|
63
|
+
@object_secondary_name = arg.split("/").last
|
64
|
+
run_plugins(:before_databagfromfile)
|
65
|
+
begin
|
66
|
+
pre_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
67
|
+
rescue
|
68
|
+
pre_databag = {}
|
69
|
+
end
|
70
|
+
databag_from_file
|
71
|
+
post_databag = load_databag_item(@object_name, @object_secondary_name.gsub(".json",""))
|
72
|
+
@object_difference = json_diff(pre_databag,post_databag).to_s
|
73
|
+
run_plugins(:after_databagfromfile)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
def databag_from_file(data_bag_names=nil)
|
80
|
+
dbff = Chef::Knife::DataBagFromFile.new
|
81
|
+
dbff.name_args = data_bag_names || @name_args
|
82
|
+
dbff.config[:editor] = config[:editor]
|
83
|
+
dbff.config[:secret] = config[:secret]
|
84
|
+
dbff.config[:secret_file] = config[:secret_file]
|
85
|
+
dbff.run
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|