bcome 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bcome.rb +1 -1
- data/lib/bcome/version.rb +1 -1
- data/lib/become_object.rb +2 -1
- data/lib/command.rb +2 -2
- data/lib/context_functions.rb +5 -5
- data/lib/functions.rb +7 -7
- data/lib/helpers/selections.rb +6 -3
- data/lib/nodes/estate.rb +1 -1
- data/lib/orchestrator/recipe.rb +1 -1
- data/lib/patches/string.rb +64 -30
- data/lib/render_irb.rb +34 -20
- data/lib/ssh.rb +1 -1
- data/lib/stack/base.rb +8 -6
- data/lib/stack/environment.rb +4 -3
- data/lib/stack/instance.rb +6 -6
- data/lib/stack/platform.rb +4 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92514554431fdc1960b632453544f789e138ef72
|
4
|
+
data.tar.gz: 7b5a1c6dbbcacdd86c210233b1614b613f482f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec948cd860c212fdfc30e51376e5a3eb85d48073ed1cc06d5fb57cddd24a68d1dceb9d049813c584798763e7e9f14da08c8d0ebc6ea2c082681422751306f8be
|
7
|
+
data.tar.gz: 9a137c66c9afa2e40288eeab9a5955e307766455d35e29727896909b1865bde55946ec2c1afbcb4a2d8c5f14dd4ddf3233a56cac91acf2985da146c8eef9484c
|
data/lib/bcome.rb
CHANGED
data/lib/bcome/version.rb
CHANGED
data/lib/become_object.rb
CHANGED
@@ -75,7 +75,8 @@ module ::Bcome::BecomeObject
|
|
75
75
|
if responds_to_list?
|
76
76
|
::RENDER.list_items(collection_key, resources)
|
77
77
|
else
|
78
|
-
puts "\
|
78
|
+
puts "\n" + "No list function at this level".warning + "\n\n"
|
79
|
+
puts "Enter 'menu' for all available options".menu_item_white + "\n\n"
|
79
80
|
end
|
80
81
|
end
|
81
82
|
alias :ls :list
|
data/lib/command.rb
CHANGED
data/lib/context_functions.rb
CHANGED
@@ -18,11 +18,11 @@ module Bcome::ContextFunctions
|
|
18
18
|
|
19
19
|
def context_commands
|
20
20
|
if context_cmd_functions && context_cmd_functions.any?
|
21
|
-
|
22
|
-
|
23
|
-
puts context_function[:description].
|
24
|
-
puts "
|
25
|
-
puts "
|
21
|
+
puts "\n\n\s\s" + "Context Commands".menu_title_green + "\n\n"
|
22
|
+
context_cmd_functions.each_with_index do |context_function, index|
|
23
|
+
puts "\n\t#{index+1}. #{context_function[:description].menu_item_green}" + "\n"
|
24
|
+
puts "\tExecuted command:".menu_item_cyan + "\s#{context_function[:executed_command]} bcome_context=\"#{context_breadcrumb}\""
|
25
|
+
puts "\tUsage:".menu_item_cyan + "\s#{context_function[:command].command}"
|
26
26
|
puts
|
27
27
|
end
|
28
28
|
else
|
data/lib/functions.rb
CHANGED
@@ -4,14 +4,14 @@ module Bcome::Functions
|
|
4
4
|
|
5
5
|
def functions
|
6
6
|
unless cmd_functions
|
7
|
-
puts "You don't yet have any custom functions defined. Have a read of the docs and define some. They're pretty useful.".
|
7
|
+
puts "\n\n" + "You don't yet have any custom functions defined. Have a read of the docs and define some. They're pretty useful.".warning + "\n\n"
|
8
8
|
else
|
9
|
-
puts
|
9
|
+
puts "\n\n\s\s" + "Functions".menu_title_green + "\n\n"
|
10
10
|
cmd_functions.each_with_index do |cmd_function, i|
|
11
|
-
puts "#{cmd_function[:ref].informational}"
|
12
|
-
puts "
|
13
|
-
puts "
|
14
|
-
puts "
|
11
|
+
puts "\tShortcut: ".menu_item_cyan + "\s#{cmd_function[:ref].informational}"
|
12
|
+
puts "\tDescription:".menu_item_cyan + "\s#{cmd_function[:description]}"
|
13
|
+
puts "\tCommand:".menu_item_cyan + "\s#{cmd_function[:command]}"
|
14
|
+
puts "\tUsage:".menu_item_cyan + "\sF \"#{cmd_function[:ref]}\""
|
15
15
|
puts
|
16
16
|
end
|
17
17
|
end
|
@@ -20,7 +20,7 @@ module Bcome::Functions
|
|
20
20
|
|
21
21
|
def F(reference)
|
22
22
|
if self.is_a?(Bcome::Stack::Environment) && no_selections?
|
23
|
-
puts "You are an an Environment level, and have not selected any nodes to workon.".
|
23
|
+
puts "\n\n" + "You are an an Environment level, and have not selected any nodes to workon.".warning + "\n\n"
|
24
24
|
else
|
25
25
|
command = cmd_for_ref(reference)
|
26
26
|
if command
|
data/lib/helpers/selections.rb
CHANGED
@@ -90,15 +90,17 @@ module ::Bcome::Selections
|
|
90
90
|
def add_object(object)
|
91
91
|
return if object_in_selections?(object)
|
92
92
|
@objects = @objects ? (@objects << object) : [object]
|
93
|
+
puts "\n" + "#{object.identifier} added.".menu_item_cyan + "\sType 'selections' to see currently selections instances.'".menu_item_white
|
93
94
|
return
|
94
95
|
end
|
95
96
|
|
96
97
|
def remove_object(object)
|
97
98
|
return if no_selections?
|
98
99
|
unless object_in_selections?(object)
|
99
|
-
|
100
|
+
puts "\n#{object.identifier} is not within selections".headsup
|
100
101
|
else
|
101
102
|
@objects = @objects - [object]
|
103
|
+
puts "\n" + "#{object.identifier} removed.".menu_item_cyan + "\sType 'selections' to see currently selections instances.'".menu_item_white
|
102
104
|
end
|
103
105
|
return
|
104
106
|
end
|
@@ -110,9 +112,10 @@ module ::Bcome::Selections
|
|
110
112
|
|
111
113
|
def selections
|
112
114
|
if no_selections?
|
113
|
-
|
115
|
+
puts "\n" + "No added nodes.".headsup + "\n"
|
114
116
|
else
|
115
|
-
|
117
|
+
puts "\n\s\s" + "Selected nodes:".menu_title_green + "\n\n"
|
118
|
+
puts @objects.collect {|o| o.do_describe }.join + "\n"
|
116
119
|
end
|
117
120
|
end
|
118
121
|
|
data/lib/nodes/estate.rb
CHANGED
data/lib/orchestrator/recipe.rb
CHANGED
@@ -16,7 +16,7 @@ module ::Bcome::Orchestrator
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def as_menu_items(stack_level_instance)
|
19
|
-
stack_level_instance.recipes.collect {|recipe| { :command => recipe.recipe_identifier, :description =>
|
19
|
+
stack_level_instance.recipes.collect {|recipe| { :command => recipe.recipe_identifier, :description => recipe.description } }
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
data/lib/patches/string.rb
CHANGED
@@ -1,47 +1,81 @@
|
|
1
1
|
class String
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# with thanks to http://simianuprising.com/wp-content/uploads/2012/08/solarized-reference-horizontal.png
|
4
|
+
def colour_codes
|
5
|
+
{
|
6
|
+
:yellow => "#b58900",
|
7
|
+
:orange => "#cb4b16",
|
8
|
+
:red => "#dc322f",
|
9
|
+
:magenta => "#d33682",
|
10
|
+
:violet => "#6c71c4",
|
11
|
+
:blue => "#268bd2",
|
12
|
+
:cyan => "#2aa198",
|
13
|
+
:green => "#859900",
|
14
|
+
:white => "#ffffff"
|
15
|
+
}
|
5
16
|
end
|
6
17
|
|
7
|
-
def
|
8
|
-
|
18
|
+
def highlight_colour_codes
|
19
|
+
{
|
20
|
+
:yellow => "#002b36",
|
21
|
+
:orange => "#073642",
|
22
|
+
:red => "#586e75",
|
23
|
+
:magenta => "#657b83",
|
24
|
+
:violet => "#839496",
|
25
|
+
:blue => "#93a1a1",
|
26
|
+
:cyan => "#eee8d5",
|
27
|
+
:green => "#fdf6e3"
|
28
|
+
}
|
9
29
|
end
|
10
30
|
|
11
|
-
def
|
12
|
-
|
31
|
+
def colours
|
32
|
+
{
|
33
|
+
:informational => { :colour => :yellow },
|
34
|
+
:failure => { :colour => :red },
|
35
|
+
:success => { :colour => :green },
|
36
|
+
:title => { :colour => :green },
|
37
|
+
:success => { :colour => :green },
|
38
|
+
:command => { :colour => :cyan, :highlight => true },
|
39
|
+
:danger => { :colour => :red },
|
40
|
+
:warning => { :colour => :orange },
|
41
|
+
:friendly => { :colour => :green },
|
42
|
+
:menu_item_green => { :colour => :green },
|
43
|
+
:menu_title_orange => { :colour => :orange, :highlight => true },
|
44
|
+
:menu_item_orange => { :colour => :orange },
|
45
|
+
:menu_title_green => { :colour => :green, :highlight => true },
|
46
|
+
:menu_item_white => { :colour => :white },
|
47
|
+
:menu_item_yellow => { :colour => :yellow },
|
48
|
+
:menu_item_cyan => { :colour => :cyan },
|
49
|
+
:selections => { :colour => :cyan },
|
50
|
+
:menu_title_cyan => { :colour => :cyan, :highlight => true },
|
51
|
+
:headsup => { :colour => :orange, :highlight => true },
|
52
|
+
:menu_item_magenta => { :colour => :magenta },
|
53
|
+
:cyan => { :colour => :cyan }
|
54
|
+
}
|
13
55
|
end
|
14
56
|
|
15
|
-
def
|
16
|
-
|
57
|
+
def has_colour?(colour_key)
|
58
|
+
colours.has_key?(colour_key)
|
17
59
|
end
|
18
60
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def friendly
|
24
|
-
self.colorize(:black).on_green
|
25
|
-
end
|
26
|
-
|
27
|
-
def warning
|
28
|
-
self.colorize(:orange).on_black
|
29
|
-
end
|
61
|
+
def method_missing(method_sym, *arguments, &black)
|
62
|
+
super unless has_colour?(method_sym)
|
63
|
+
colour_data = colours[method_sym]
|
30
64
|
|
31
|
-
|
32
|
-
self.colorize(:yellow).on_black
|
33
|
-
end
|
34
|
-
|
35
|
-
def headsup
|
36
|
-
self.colorize(:yellow).on_black
|
37
|
-
end
|
65
|
+
colour = colour_codes[colour_data[:colour]]
|
38
66
|
|
39
|
-
|
40
|
-
|
67
|
+
unless colour_data[:highlight]
|
68
|
+
return Rainbow(self).color(colour)
|
69
|
+
else
|
70
|
+
highlight_colour = highlight_colour_codes[colour_data[:colour]]
|
71
|
+
return Rainbow(self).color(highlight_colour).bg(colour)
|
72
|
+
end
|
41
73
|
end
|
42
74
|
|
43
|
-
def
|
44
|
-
|
75
|
+
def swatch
|
76
|
+
colours.each { |colour_key, colour_attributes|
|
77
|
+
puts "#{colour_key} : #{send(colour_key)}"
|
78
|
+
}
|
45
79
|
end
|
46
80
|
|
47
81
|
end
|
data/lib/render_irb.rb
CHANGED
@@ -2,36 +2,50 @@ class ::Bcome::RenderIrb
|
|
2
2
|
|
3
3
|
def list_items(parent_collection, items)
|
4
4
|
if !items || !items.any?
|
5
|
-
print "\
|
5
|
+
print "\n\sNo resources collections found. Maybe you forgot to add any?".headsup
|
6
6
|
else
|
7
|
-
print
|
7
|
+
print "\n\s"
|
8
|
+
puts "#{parent_collection.to_s.menu_title_green}\n\n".menu_title_green
|
8
9
|
items.each do |item|
|
9
|
-
|
10
|
-
print
|
10
|
+
puts "\t*/added".danger + "\n" if item.highlight?
|
11
|
+
print item.do_describe
|
11
12
|
end
|
13
|
+
print "\n\s\sUse cd [node identifier], e.g. cd \"#{items.first.identifier}\" to work on a given node.\n\n"
|
12
14
|
end
|
13
|
-
print "\n"
|
14
15
|
end
|
15
16
|
|
16
17
|
def menu(menu_items, stack_level_instance)
|
17
|
-
|
18
|
-
menu_items
|
19
|
-
|
20
|
-
|
21
|
-
menu_str = "\n\The following commands are available: \n\n"
|
22
|
-
menu_items.each do |item|
|
23
|
-
command = item[:command]
|
24
|
-
description = item[:description]
|
25
|
-
usage = item[:usage]
|
26
|
-
|
27
|
-
menu_str += "> #{command}\n"
|
28
|
-
menu_str += "- #{description}\n"
|
29
|
-
menu_str += "e.g. #{usage}\n" if usage
|
18
|
+
menu_str = "\n\s#{"Standard Menu".menu_title_green}\n\n"
|
19
|
+
menu_items.each_with_index do |item, index|
|
20
|
+
menu_str += construct_menu_item_string(item, index, :menu_item_green)
|
21
|
+
end
|
30
22
|
|
31
|
-
|
23
|
+
recipe_menu_items = ::Bcome::Orchestrator::Recipe.as_menu_items(stack_level_instance)
|
24
|
+
if recipe_menu_items.any?
|
25
|
+
menu_str += "\n\s#{"Orchestration Menu".menu_title_orange}\n\n"
|
26
|
+
recipe_menu_items.each_with_index do |item, index|
|
27
|
+
menu_str += construct_menu_item_string(item, index, :menu_item_orange)
|
28
|
+
end
|
32
29
|
end
|
30
|
+
|
33
31
|
menu_str += "\n\n"
|
34
|
-
print menu_str
|
32
|
+
print menu_str
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
def construct_menu_item_string(item, index, colour)
|
37
|
+
command = item[:command]
|
38
|
+
description = item[:description]
|
39
|
+
usage = item[:usage]
|
40
|
+
menu_str = "#{tab}#{index+1}. #{description}".send(colour) + "\n"
|
41
|
+
menu_str += "#{tab}" + "Command: ".menu_item_cyan + "#{command}\n".menu_item_white
|
42
|
+
menu_str += "#{tab}" + "Usage: ".menu_item_cyan + "#{usage}\n".menu_item_white if usage
|
43
|
+
menu_str += "\n"
|
44
|
+
return menu_str
|
45
|
+
end
|
46
|
+
|
47
|
+
def tab
|
48
|
+
"\s\s\s"
|
35
49
|
end
|
36
50
|
|
37
51
|
end
|
data/lib/ssh.rb
CHANGED
@@ -14,7 +14,7 @@ class ::Bcome::Ssh
|
|
14
14
|
proxy = command.proxy
|
15
15
|
|
16
16
|
::Net::SSH.start(instance.ip_address, ssh_user, :proxy => proxy, :keys => ssh_keys, :paranoid => false) do |ssh|
|
17
|
-
puts "(#{instance.identifier})$ #{command.command}"
|
17
|
+
puts "(#{instance.identifier})$".cyan + "\s#{command.command}"
|
18
18
|
ssh_exec!(ssh, command)
|
19
19
|
puts command.output
|
20
20
|
print command.pretty_result
|
data/lib/stack/base.rb
CHANGED
@@ -27,6 +27,7 @@ module ::Bcome::Stack
|
|
27
27
|
puts "Executing Command Recipe #{recipe.recipe_identifier}".informational
|
28
28
|
puts "Description: #{recipe.description}".command
|
29
29
|
recipe.execute!(machines)
|
30
|
+
return
|
30
31
|
else
|
31
32
|
super
|
32
33
|
end
|
@@ -70,9 +71,10 @@ module ::Bcome::Stack
|
|
70
71
|
resource = resource_for_identifier(identifier)
|
71
72
|
|
72
73
|
unless resource
|
73
|
-
puts "
|
74
|
+
puts "\nNo matching #{collection_key} for identifier '#{identifier}'.".failure + "\n\n#{available_resources_options_string}" + "\n\n"
|
74
75
|
else
|
75
|
-
puts "
|
76
|
+
puts "\nFrom #{resource.reference_key}, working on '#{identifier}'.".informational + "\n\n"
|
77
|
+
puts "Hit 'menu' or 'ls' to see what you can do here.\n\n"
|
76
78
|
become(resource)
|
77
79
|
end
|
78
80
|
end
|
@@ -87,7 +89,7 @@ module ::Bcome::Stack
|
|
87
89
|
[
|
88
90
|
{ :command => "list / ls", :description => "List all available resources at the current context." },
|
89
91
|
{ :command => "describe", :description => "Describe the resource object at the current context." },
|
90
|
-
{ :command => "cd
|
92
|
+
{ :command => "cd [Node Name]", :description => "Select a resource object, and switch to its context.", :usage => "cd 'YourServerName'" },
|
91
93
|
{ :command => "exit", :description => "Return to the previous context" },
|
92
94
|
{ :command => "exit!", :description => "Close all contexts, and exit Become."},
|
93
95
|
{ :command => "local", :description => "Execute a shell command on your local machine.", :usage => 'local "command"'},
|
@@ -101,14 +103,14 @@ module ::Bcome::Stack
|
|
101
103
|
end
|
102
104
|
|
103
105
|
def available_resources_options_string
|
104
|
-
"Please select from one of
|
106
|
+
"Please select from one of: #{all_items.join(', ')}'"
|
105
107
|
end
|
106
108
|
|
107
109
|
def describe
|
108
110
|
if self.respond_to?(:do_describe)
|
109
|
-
message = "\
|
111
|
+
message = "\n\tCollection Key:".menu_item_cyan + "\s#{reference_key}\n\n#{self.do_describe}"
|
110
112
|
else
|
111
|
-
message = "\nNothing to describe. Use 'list' to see namespace options".headsup unless self.respond_to?(:do_describe)
|
113
|
+
message = "\nNothing to describe. Use 'ls' or 'list' to see namespace options".headsup unless self.respond_to?(:do_describe)
|
112
114
|
end
|
113
115
|
puts message
|
114
116
|
end
|
data/lib/stack/environment.rb
CHANGED
@@ -60,9 +60,10 @@ module ::Bcome::Stack
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def do_describe
|
63
|
-
desc = "#{node.identifier}"
|
64
|
-
desc += "\
|
65
|
-
desc += "\
|
63
|
+
desc = "\tNode Id:".menu_item_cyan + "\s#{node.identifier}".menu_item_green + "\n"
|
64
|
+
desc += "\tNet Lookup:".menu_item_cyan + "\s#{node.network_lookup_type}".menu_item_white + "\n"
|
65
|
+
desc += "\tSSH Mode:".menu_item_cyan + "\s#{node.ssh_mode_type}".menu_item_white
|
66
|
+
return desc + "\n\n"
|
66
67
|
end
|
67
68
|
|
68
69
|
def collection_klass
|
data/lib/stack/instance.rb
CHANGED
@@ -99,11 +99,12 @@ module ::Bcome::Stack
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def do_describe
|
102
|
-
description = "#{node.identifier}
|
103
|
-
description += "\n\
|
104
|
-
description += "\n\t
|
105
|
-
description += "\n\t
|
106
|
-
description += "\n"
|
102
|
+
description = "\tNode Id:".menu_item_cyan + "\s\s#{node.identifier.menu_item_yellow}"
|
103
|
+
description += "\n\tsudo: ".menu_item_cyan + (is_sudo? ? "on".danger : "off" )
|
104
|
+
description += "\n\t" + "Internal IP: ".menu_item_cyan + "#{@meta_data[:external_network_interface_address]}".menu_item_white
|
105
|
+
description += "\n\t" + "External IP: ".menu_item_cyan + "#{node.public_ip_address}".menu_item_white if node.public_ip_address
|
106
|
+
description += "\n\t" + "Role: ".menu_item_cyan + "#{node.role}".menu_item_white if node.role
|
107
|
+
description += "\n\n"
|
107
108
|
return description
|
108
109
|
end
|
109
110
|
|
@@ -111,6 +112,5 @@ module ::Bcome::Stack
|
|
111
112
|
::Bcome::Node::Instance
|
112
113
|
end
|
113
114
|
|
114
|
-
|
115
115
|
end
|
116
116
|
end
|
data/lib/stack/platform.rb
CHANGED
@@ -27,7 +27,10 @@ module ::Bcome::Stack
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def do_describe
|
30
|
-
|
30
|
+
description = "\n"
|
31
|
+
description += "\t#{identifier.menu_item_green}\n"
|
32
|
+
description += "\t" + "Description: ".menu_item_cyan + @meta_data[:description].menu_item_white + "\n"
|
33
|
+
return description
|
31
34
|
end
|
32
35
|
|
33
36
|
def config_path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Roderick (Webzakimbo)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rainbow
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 2.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 2.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: net-scp
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|