bcome 0.1.8 → 0.1.9

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: ca55cba00e34827423b0c13cb08afb515a45b970
4
- data.tar.gz: 0146b318a88f735248b22c88be09c6c5454c8af0
3
+ metadata.gz: 613edda110e0f6d9a425088ae6d81ea97c085c27
4
+ data.tar.gz: f589219de99e684a05e8381ec4b4c1955c8f54b8
5
5
  SHA512:
6
- metadata.gz: ec473e4f8d718b9fe79f8813b8bb2364b0ca2b41af5a98acbb605b44158488358102f12da93b47a48c6d5f574d609c4db5e3585e6c93343d7616145ad39cc9ed
7
- data.tar.gz: 124dc53be5a4f3798447b9c2de77f05a218d18fc5b3746238e62757a2871326c3938dfc0c0adf182a2ce740e8dbbe7106d04dd857417148729fa764f982144f8
6
+ metadata.gz: cfcb9cd3d9bfff842663a09f0e702ce7acf40f31022360727dde257f9f22190fde6a148f28e7976a2acf5ee9bf1b4ec53e39290f902b7cf7ddcd2c61f261af3d
7
+ data.tar.gz: 38e06ddb8491f634c6fe5472e8f6a5ae30c2169819ea15ea108166ebc946999c20338458bccfed7e583d3cc5184237891aa514e5f14752e75ed467b39a9b7e8b
@@ -1,3 +1,3 @@
1
1
  module Bcome
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -18,17 +18,15 @@ module Bcome::ContextFunctions
18
18
 
19
19
  def context_commands
20
20
  if context_cmd_functions && context_cmd_functions.any?
21
- puts "\n\n\s\s" + "Context Commands".menu_title_green + "\n\n"
21
+ description = "\n\s\s" + "Context Commands".menu_title_green + "\n"
22
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
- puts
23
+ description += "\n\s\s\s#{index+1}. #{context_function[:description].menu_item_green}"
24
+ description += "\n\s\s\sExecuted command:".menu_item_cyan + "\s#{context_function[:executed_command]} bcome_context=\"#{context_breadcrumb}\""
25
+ description += "\n\s\s\sUsage:".menu_item_cyan + "\s#{context_function[:command].command}"
26
+ description += "\n"
27
27
  end
28
- else
29
- puts "You don't have any context specific functions defined yet."
30
28
  end
31
- return
29
+ return description
32
30
  end
33
31
 
34
32
  def context_cmd_functions
@@ -1,12 +1,13 @@
1
1
  module Bcome::Orchestrator
2
2
  class Loader
3
3
 
4
- def initialize(machines)
4
+ def initialize(machines, registry_for_context)
5
5
  config_path = "#{Dir.pwd}/bcome/config/orchestration"
6
- @recipes_path = "#{config_path}/command_recipes.yml"
6
+ @recipes_path = "#{config_path}/recipes.yml"
7
7
  @machine_targets_path = "#{config_path}/node_target_selectors.yml"
8
8
  @direct_commands_path = "#{config_path}/direct_command_sets.yml"
9
9
  @machines = machines
10
+ @registry_for_context = registry_for_context
10
11
  end
11
12
 
12
13
  def recipes
@@ -22,7 +23,7 @@ module Bcome::Orchestrator
22
23
  end
23
24
 
24
25
  def do_load_recipes
25
- return json_from_file(@recipes_path)
26
+ return json_from_file(@recipes_path).select{|r| @registry_for_context.include?(r[:recipe_identifier]) }
26
27
  end
27
28
 
28
29
  def do_load_direct_commands
@@ -0,0 +1,37 @@
1
+ module Bcome::Orchestrator::Registry
2
+
3
+ CONFIGS_PATH = "bcome/config/orchestration"
4
+
5
+ def do_load_recipes
6
+ return [] unless config_for_registry.any?
7
+ ::Bcome::Orchestrator::Loader.new(machines, config_for_registry).recipes
8
+ end
9
+
10
+ def config_for_registry
11
+ return [] unless has_registry_config?
12
+
13
+ matching_keys = []
14
+ recipe_registry.keys.each {|registry_key|
15
+ matching_keys << registry_key if /^#{registry_key}$/.match(context_breadcrumb)
16
+ }
17
+
18
+ return matching_keys.collect{|registry_key| recipe_registry[registry_key] }.flatten
19
+ end
20
+
21
+ def recipe_registry
22
+ load_recipe_registry
23
+ end
24
+
25
+ def load_recipe_registry
26
+ return YAML.load_file(registry_configs_path)
27
+ end
28
+
29
+ def registry_configs_path
30
+ "#{CONFIGS_PATH}/registry.yml"
31
+ end
32
+
33
+ def has_registry_config?
34
+ File.exist?(registry_configs_path)
35
+ end
36
+
37
+ end
@@ -28,6 +28,8 @@ class ::Bcome::RenderIrb
28
28
  end
29
29
  end
30
30
 
31
+ menu_str += stack_level_instance.context_commands if stack_level_instance.context_commands
32
+
31
33
  menu_str += "\n\n"
32
34
  print menu_str
33
35
  return
@@ -3,6 +3,7 @@ module ::Bcome::Stack
3
3
 
4
4
  include ::Bcome::ContextFunctions
5
5
  include ::Bcome::CommandHelper
6
+ include ::Bcome::Orchestrator::Registry
6
7
 
7
8
  def machines
8
9
  node.machines
@@ -12,12 +13,12 @@ module ::Bcome::Stack
12
13
  ## Construction & Initialisation
13
14
  ##
14
15
 
15
- def node
16
- @node ||= construct_node
16
+ def recipes
17
+ @recipes ||= do_load_recipes
17
18
  end
18
19
 
19
- def recipes
20
- []
20
+ def node
21
+ @node ||= construct_node
21
22
  end
22
23
 
23
24
  def method_missing(method_sym, *arguments, &block)
@@ -93,8 +94,7 @@ module ::Bcome::Stack
93
94
  { :command => "exit", :description => "Return to the previous context" },
94
95
  { :command => "exit!", :description => "Close all contexts, and exit Become."},
95
96
  { :command => "local", :description => "Execute a shell command on your local machine.", :usage => 'local "command"'},
96
- { :command => "machines", :description => "Return all servers below the current level to the console. These objects can be manipulated directly" },
97
- { :command => "context_commands", :description => "List all shell commands for invoking non-shell processes, in the current bcome context" },
97
+ { :command => "machines", :description => "Return all servers below the current level to the console. These objects can be manipulated directly" }
98
98
  ]
99
99
  end
100
100
 
@@ -40,10 +40,6 @@ module ::Bcome::Stack
40
40
  ]
41
41
  end
42
42
 
43
- def recipes
44
- @recipes ||= ::Bcome::Orchestrator::Loader.new(machines).recipes
45
- end
46
-
47
43
  def do_load_resources
48
44
  if dynamic_network_lookup?
49
45
  return collection_klass.collection_from_fog_data(self, servers)
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.8
4
+ version: 0.1.9
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-05 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -158,6 +158,7 @@ files:
158
158
  - lib/orchestrator/node_target/base.rb
159
159
  - lib/orchestrator/node_target/single.rb
160
160
  - lib/orchestrator/recipe.rb
161
+ - lib/orchestrator/registry.rb
161
162
  - lib/orchestrator/validate_and_set.rb
162
163
  - lib/patches/string.rb
163
164
  - lib/render_irb.rb