Class: Stacco::Orchestrator
- Inherits:
-
Object
- Object
- Stacco::Orchestrator
- Defined in:
- lib/stacco/orchestrator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #define_stack(config_body) ⇒ Object
-
#initialize(config) ⇒ Orchestrator
constructor
A new instance of Orchestrator.
- #stack_bucket_prefix ⇒ Object
- #stacks ⇒ Object
Constructor Details
#initialize(config) ⇒ Orchestrator
Returns a new instance of Orchestrator.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/stacco/orchestrator.rb', line 12 def initialize(config) @config = config @services = {} @services[:s3] = AWS::S3.new( access_key_id: @config['aws']['access_key_id'], secret_access_key: @config['aws']['secret_access_key'], region: @config['aws']['region'] ) end |
Class Method Details
.from_config(config_body) ⇒ Object
7 8 9 10 |
# File 'lib/stacco/orchestrator.rb', line 7 def self.from_config(config_body) config_body = config_body.read if config_body.respond_to?(:read) self.new YAML.load(config_body) end |
Instance Method Details
#define_stack(config_body) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/stacco/orchestrator.rb', line 31 def define_stack(config_body) config_body = config_body.read if config_body.respond_to?(:read) config = YAML.load(config_body) stack_name = config['name'] bucket_name = "stacco-#{self.stack_bucket_prefix}-stack-#{stack_name}" bucket = @services[:s3].buckets[bucket_name] unless bucket.exists? @services[:s3].buckets.create(bucket_name) end bucket.objects['stack.yml'].write(config.to_yaml) Stacco::Stack.new(bucket) end |
#stack_bucket_prefix ⇒ Object
23 24 25 |
# File 'lib/stacco/orchestrator.rb', line 23 def stack_bucket_prefix @config['organization'].gsub(/[^\w]/, '') end |