knife-role-spaghetti 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/features/cli.feature +1 -1
- data/features/graphing.feature +12 -0
- data/lib/chef/knife/spaghetti.rb +16 -5
- data/lib/knife-role-spaghetti.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -69,10 +69,14 @@ Running through the neato renderer (with the `-N` switch) produces this image:
|
|
69
69
|
|
70
70
|
## Changelog
|
71
71
|
|
72
|
+
### v0.0.2
|
73
|
+
* Updated CLI banner to reflect that filename is not required, renamed for clarity
|
74
|
+
* Improved handling cases where a role contains recipes named the same as the role
|
75
|
+
* Added handling for roles in JSON format
|
76
|
+
|
72
77
|
### v0.0.1
|
73
78
|
* Initial commit
|
74
79
|
|
75
|
-
|
76
80
|
## License
|
77
81
|
|
78
82
|
Author:: Mike Fiedler (<miketheman@gmail.com>)
|
data/features/cli.feature
CHANGED
@@ -23,7 +23,7 @@ Scenario Outline: Running with Help flags produces the correct result
|
|
23
23
|
When I run `knife role spaghetti <HelpFlag>`
|
24
24
|
Then the output should contain:
|
25
25
|
"""
|
26
|
-
knife role spaghetti
|
26
|
+
knife role spaghetti [ OUTFILE.PNG -G FORMAT [-N] ]
|
27
27
|
"""
|
28
28
|
And the exit status should be 1
|
29
29
|
Examples:
|
data/features/graphing.feature
CHANGED
@@ -39,6 +39,18 @@ Scenario: Running against a directory with multiple roles succeeds
|
|
39
39
|
"recipe[mysql]"
|
40
40
|
)
|
41
41
|
"""
|
42
|
+
And a file named "roles/base.json" with:
|
43
|
+
"""
|
44
|
+
{
|
45
|
+
"name" : "base",
|
46
|
+
"description" : "Sample base json role",
|
47
|
+
"run_list" : [
|
48
|
+
"recipe[yum]",
|
49
|
+
"recipe[apt]",
|
50
|
+
"recipe[ntp]"
|
51
|
+
]
|
52
|
+
}
|
53
|
+
"""
|
42
54
|
When I successfully run `knife role spaghetti multirole.png`
|
43
55
|
Then the exit status should be 0
|
44
56
|
|
data/lib/chef/knife/spaghetti.rb
CHANGED
@@ -8,7 +8,7 @@ module KnifeRoleSpaghetti
|
|
8
8
|
require 'graphviz'
|
9
9
|
end
|
10
10
|
|
11
|
-
banner "knife role spaghetti
|
11
|
+
banner "knife role spaghetti [ OUTFILE.PNG -G FORMAT [-N] ]"
|
12
12
|
|
13
13
|
option :graphformat,
|
14
14
|
:short => "-G FORMAT",
|
@@ -23,6 +23,8 @@ module KnifeRoleSpaghetti
|
|
23
23
|
:boolean => true,
|
24
24
|
:description => "Specify to render the graph in the neato engine"
|
25
25
|
|
26
|
+
# OPTIMIZE: Add an option to display cookbooks instead of recipes?
|
27
|
+
|
26
28
|
def run
|
27
29
|
|
28
30
|
self.config = Chef::Config.merge!(config)
|
@@ -58,16 +60,25 @@ module KnifeRoleSpaghetti
|
|
58
60
|
:compound => "true"
|
59
61
|
)
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
+
Dir.glob(File.join(Chef::Config.role_path, '*.{rb,json}')) do |role_file|
|
64
|
+
|
63
65
|
role = Chef::Role.new
|
64
|
-
|
66
|
+
|
67
|
+
if File.extname(role_file) == '.rb'
|
68
|
+
role.from_file(role_file)
|
69
|
+
elsif File.extname(role_file) == '.json'
|
70
|
+
js_file = Chef::JSONCompat.from_json(IO.read(role_file))
|
71
|
+
role = Chef::Role.json_create(js_file)
|
72
|
+
else
|
73
|
+
ui.error("This shouldn't happen, the file must be either rb or json")
|
74
|
+
end
|
75
|
+
|
65
76
|
# OPTIMIZE: Handle environment run_lists
|
66
77
|
|
67
78
|
g.node[:shape] = "box"
|
68
79
|
g.node[:style] = "rounded"
|
69
80
|
g.node[:color] = "red"
|
70
|
-
role_node = g.add_nodes(role.name)
|
81
|
+
role_node = g.add_nodes("#{role.name}_role", :label => role.name)
|
71
82
|
|
72
83
|
# This logic is to ensure that an embedded role doesn't change color
|
73
84
|
role.run_list.each do |rli|
|
data/lib/knife-role-spaghetti.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-role-spaghetti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|