Class: KumoDockerCloud::Deployment

Inherits:
Object
  • Object
show all
Defined in:
lib/kumo_dockercloud/deployment.rb

Defined Under Namespace

Classes: DeploymentError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stack_name, version, _ = nil) ⇒ Deployment

Returns a new instance of Deployment.



15
16
17
18
19
20
21
22
# File 'lib/kumo_dockercloud/deployment.rb', line 15

def initialize(stack_name, version, _ = nil)
  @stack_name = stack_name
  @version = version
  @contactable = true

  @health_check_path = 'site_status'
  @version_check_path = "#{health_check_path}/version"
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



12
13
14
# File 'lib/kumo_dockercloud/deployment.rb', line 12

def app_name
  @app_name
end

#contactableObject

Returns the value of attribute contactable.



12
13
14
# File 'lib/kumo_dockercloud/deployment.rb', line 12

def contactable
  @contactable
end

#health_check_pathObject (readonly)

Returns the value of attribute health_check_path.



13
14
15
# File 'lib/kumo_dockercloud/deployment.rb', line 13

def health_check_path
  @health_check_path
end

#stack_nameObject (readonly)

Returns the value of attribute stack_name.



13
14
15
# File 'lib/kumo_dockercloud/deployment.rb', line 13

def stack_name
  @stack_name
end

#versionObject (readonly)

Returns the value of attribute version.



13
14
15
# File 'lib/kumo_dockercloud/deployment.rb', line 13

def version
  @version
end

#version_check_pathObject (readonly)

Returns the value of attribute version_check_path.



13
14
15
# File 'lib/kumo_dockercloud/deployment.rb', line 13

def version_check_path
  @version_check_path
end

Instance Method Details

#validateObject



24
25
26
27
# File 'lib/kumo_dockercloud/deployment.rb', line 24

def validate
  wait_for_running_state
  validate_containers
end

#wait_for_exit_stateObject



38
39
40
41
42
43
44
45
# File 'lib/kumo_dockercloud/deployment.rb', line 38

def wait_for_exit_state
  exit_state_provider = lambda {
    service = docker_cloud_api.services.get(service_uuid)
    { name: service.name, exit_code: service.containers.first.exit_code }
  }

  StateValidator.new(exit_state_provider).wait_for_exit_state(240)
end

#wait_for_running_stateObject



29
30
31
32
33
34
35
36
# File 'lib/kumo_dockercloud/deployment.rb', line 29

def wait_for_running_state
  service_state_provider = lambda {
    service = docker_cloud_api.services.get(service_uuid)
    { name: service.name, state: service.state }
  }

  StateValidator.new(service_state_provider).wait_for_state('Running', 240)
end