knife-draw 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10c630368dd7753fd1b0154f4c676c6f45d29732
4
- data.tar.gz: fde0dfc7d2a46b2631c1de4e0aab6c02ef471040
3
+ metadata.gz: 44f2b0f02a6f729eba72b64658d0416a07597aed
4
+ data.tar.gz: f1aaca343239a4e07f346a40c1ea84c97cebd1ee
5
5
  SHA512:
6
- metadata.gz: 1184dc42b610177b3f092126e38dabe616b771f753f7c0c6ed2af93e564a7b0d7b0905bb98333ffafdbcf3578e56117477dd80c125f4aab1f61eb276b3fd5238
7
- data.tar.gz: de8d3d0c0e6077d95277d385df786d7981ebf6c52a0fb2e5fea008d2cc47db86db0c3aa44fdbac46b20778e741114c753c8ae801569390876f8e3c13fdfe4e4f
6
+ metadata.gz: 6a56f9c3af69377d1ffeff77366dc6ada5b4403e06b53b337ded72a887a9ed576e7dbc233b0e7c7254fa99a58fded6bc12af094eb053f8d331e0ab058c365eb0
7
+ data.tar.gz: dd8db3e1d96e796e2321637316051334dda70858018a5254ee0076a12ea823ac65966689451ef508c3c05548a313851231c938d803bf152435dd477629b3e623
data/knife-draw.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["joshuaflanagan@gmail.com"]
11
11
  spec.summary = %q{Draws pictures using your Chef data}
12
12
  spec.description = %q{Generates GraphViz diagrams based on your Chef environment}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/joshuaflanagan/knife-draw"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
data/lib/knife/draw.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'chef/knife'
2
2
 
3
3
  require "knife_draw/version"
4
+ require 'knife_draw/verbose_output'
4
5
  require 'knife_draw/draw_roles'
5
6
  require 'knife_draw/draw_nodes'
6
7
  require 'knife_draw/chef_graph'
@@ -41,9 +41,9 @@ module KnifeDraw
41
41
  graph.add_edge(source, target, color: EDGE_COLOR)
42
42
  end
43
43
 
44
- def draw!(outputfile="output.png")
44
+ def draw!(outputfile)
45
45
  filename=outputfile
46
- format = File.extname(filename)[1..-1]
46
+ format = File.extname(filename)[1..-1] || :png
47
47
  graph.output format => filename
48
48
  end
49
49
  end
@@ -1,36 +1,40 @@
1
1
  module KnifeDraw
2
2
  class DrawNodes < Chef::Knife
3
+ include VerboseOutput
4
+
3
5
  deps do
4
6
  require 'graphviz'
5
7
  end
6
8
 
7
- banner "knife draw nodes [ENVIRONMENT]"
9
+ banner "knife draw nodes [FILENAME]"
8
10
 
9
11
  def run
10
- environment = name_args.first if name_args.size > 0
12
+ filename = name_args.size > 0 ? name_args.first : "output.png"
13
+ environment = config[:environment]
11
14
 
12
15
  graph = ChefGraph.new cluster_environments: environment.nil?
13
16
  source = ChefServerSource.new
14
17
 
15
- source.nodes.each do |name, node|
18
+ source.nodes(environment).each do |name, node|
16
19
  node_box = graph.draw_node(name, node.chef_environment)
17
- ui.msg "name: #{name} env: #{node.chef_environment}"
20
+ verbose_out "name: #{name} env: #{node.chef_environment}"
18
21
  source.roles_for_node(node).each do |role_name|
22
+ verbose_out "\trole: #{role_name}"
19
23
  role_box = graph.draw_role(role_name)
20
24
  graph.connect(node_box, role_box)
21
25
 
22
26
  source.runlist_for_role(role_name).each do |run_list|
23
27
  runlist_box = graph.draw_runlist run_list.to_s
24
28
  graph.connect(role_box, runlist_box)
25
- ui.msg "\t\trunlist: #{run_list}"
29
+ verbose_out "\t\trunlist: #{run_list}"
26
30
  end
27
31
  end
28
32
  end
29
- graph.draw!
33
+ graph.draw! filename
30
34
  end
31
35
  end
32
36
 
33
37
  class NodeDraw < DrawNodes
34
- banner "knife node draw [ENVIRONMENT]"
38
+ banner "knife node draw"
35
39
  end
36
40
  end
@@ -1,24 +1,27 @@
1
1
  module KnifeDraw
2
2
  class DrawRoles < Chef::Knife
3
+ include VerboseOutput
4
+
3
5
  deps do
4
6
  require 'graphviz'
5
7
  end
6
8
 
7
- banner "knife draw roles"
9
+ banner "knife draw roles [FILENAME]"
8
10
 
9
11
  def run
12
+ filename = name_args.size > 0 ? name_args.first : "output.png"
10
13
  graph = ChefGraph.new
11
14
  source = ChefServerSource.new
12
15
  source.roles.each do |role_name, role|
13
- ui.msg "name: #{role_name}"
16
+ verbose_out "name: #{role_name}"
14
17
  role_box = graph.draw_role(role_name)
15
18
  source.runlist_for_role(role_name).each do |run_list|
16
19
  runlist_box = graph.draw_runlist run_list.to_s
17
20
  graph.connect(role_box, runlist_box)
18
- ui.msg "\t\trunlist: #{run_list}"
21
+ verbose_out "\t\trunlist: #{run_list}"
19
22
  end
20
23
  end
21
- graph.draw!
24
+ graph.draw! filename
22
25
  end
23
26
  end
24
27
 
@@ -0,0 +1,7 @@
1
+ module KnifeDraw
2
+ module VerboseOutput
3
+ def verbose_out(message)
4
+ ui.msg(message) if config[:verbosity] >= 1
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module KnifeDraw
2
- VERSION = "0.9.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-draw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Flanagan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-31 00:00:00.000000000 Z
11
+ date: 2014-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -84,8 +84,9 @@ files:
84
84
  - lib/knife_draw/chef_server_source.rb
85
85
  - lib/knife_draw/draw_nodes.rb
86
86
  - lib/knife_draw/draw_roles.rb
87
+ - lib/knife_draw/verbose_output.rb
87
88
  - lib/knife_draw/version.rb
88
- homepage: ''
89
+ homepage: https://github.com/joshuaflanagan/knife-draw
89
90
  licenses:
90
91
  - MIT
91
92
  metadata: {}