Class: KumoDockerCloud::Environment
- Inherits:
-
Object
- Object
- KumoDockerCloud::Environment
- Extended by:
- Forwardable
- Defined in:
- lib/kumo_dockercloud/environment.rb
Instance Method Summary collapse
- #apply(stack_checker = StackChecker.new) ⇒ Object
- #destroy ⇒ Object
-
#initialize(params = {}) ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize(params = {}) ⇒ Environment
Returns a new instance of Environment.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kumo_dockercloud/environment.rb', line 18 def initialize(params = {}) @env_name = params.fetch(:name) @env_vars = params.fetch(:env_vars, {}) @stack_template_path = params.fetch(:stack_template_path) @timeout = params.fetch(:timeout, 120) @confirmation_timeout = params.fetch(:confirmation_timeout, 30) @app_name = params.fetch(:app_name) @config = EnvironmentConfig.new(app_name: @app_name, env_name: @env_name, config_path: params.fetch(:config_path)) end |
Instance Method Details
#apply(stack_checker = StackChecker.new) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kumo_dockercloud/environment.rb', line 29 def apply(stack_checker = StackChecker.new) if @config.image_tag == 'latest' ConsoleJockey.write_line 'WARNING: Deploying latest. The deployed container version may arbitrarily change' end stack_file = write_stack_config_file(configure_stack(stack_template)) run_command(stack_command(stack_file)) stack_file.unlink run_command("docker-cloud stack redeploy #{stack_name}") stack = Stack.new(@app_name, @env_name) begin stack_checker.verify(stack) rescue StackCheckError raise EnvironmentApplyError.new("The stack is not in the expected state.") end end |
#destroy ⇒ Object
49 50 51 52 53 |
# File 'lib/kumo_dockercloud/environment.rb', line 49 def destroy ConsoleJockey. "Warning! You are about to delete the Docker Cloud Stack #{stack_name}, enter 'yes' to continue." return unless ConsoleJockey.get_confirmation(@confirmation_timeout) run_command("docker-cloud stack terminate --sync #{stack_name}") end |