caterer 0.2.0 → 0.3.0

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.
@@ -1,3 +1,6 @@
1
+ require 'oj'
2
+ require 'multi_json'
3
+
1
4
  module Caterer
2
5
  module Command
3
6
  class Base < Vli::Command::Base
@@ -16,6 +19,9 @@ module Caterer
16
19
  opts.on('-P PORT', '--port PORT', 'assumes 22') do |p|
17
20
  options[:port] = p
18
21
  end
22
+ opts.on('-d JSON', '--data JSON', 'json data that the provisioner may use' )do |d|
23
+ options[:data] = d
24
+ end
19
25
  opts.on('-i IMAGE', '--image IMAGE', 'corresponds to a image in Caterfile') do |i|
20
26
  options[:image] = i
21
27
  end
@@ -86,6 +92,14 @@ module Caterer
86
92
  opts[:port] = options[:port] || member.port
87
93
  opts[:images] = image_list(options) || member.images || group.images
88
94
 
95
+ opts[:data] = begin
96
+ data = nil
97
+ if json = options[:data]
98
+ data = MultiJson.load json rescue nil
99
+ end
100
+ data || member.data || group.data
101
+ end
102
+
89
103
  Server.new(@env, opts)
90
104
  end
91
105
 
@@ -3,7 +3,7 @@ module Caterer
3
3
  class Group
4
4
 
5
5
  attr_reader :name
6
- attr_accessor :images, :members, :user, :password
6
+ attr_accessor :images, :members, :user, :password, :data
7
7
 
8
8
  def initialize(name=nil)
9
9
  @name = name
@@ -3,7 +3,7 @@ module Caterer
3
3
  class Member
4
4
 
5
5
  attr_reader :name
6
- attr_accessor :host, :port, :user, :password, :images
6
+ attr_accessor :host, :port, :user, :password, :images, :data
7
7
 
8
8
  def initialize(name=nil)
9
9
  @name = name
@@ -197,7 +197,11 @@ module Caterer
197
197
  end
198
198
 
199
199
  def json_config
200
- MultiJson.dump(config.json.merge({:run_list => config.run_list}))
200
+ MultiJson.dump(config_data)
201
+ end
202
+
203
+ def config_data
204
+ config.json.merge(server.data).merge({:run_list => config.run_list})
201
205
  end
202
206
 
203
207
  def json_config_path
@@ -13,6 +13,7 @@ module Caterer
13
13
  @host = opts[:host]
14
14
  @port = opts[:port]
15
15
  @images = opts[:images] || []
16
+ @data = opts[:data] || {}
16
17
  end
17
18
 
18
19
  def bootstrap(opts={})
@@ -96,6 +97,12 @@ module Caterer
96
97
  @port || 22
97
98
  end
98
99
 
100
+ def data
101
+ @data_hash ||= begin
102
+ (@data.is_a? Hash) ? @data : {}
103
+ end
104
+ end
105
+
99
106
  def run_action(name, options=nil)
100
107
  options = {
101
108
  :server => self,
@@ -1,3 +1,3 @@
1
1
  module Caterer
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: