Class: Indocker::Containers::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/indocker/containers/container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Container

Returns a new instance of Container.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/indocker/containers/container.rb', line 7

def initialize(name)
  @name = name
  @daemonize = true
  @parent_containers = []
  @dependent_containers = []
  @soft_dependent_containers = []
  @volumes = []
  @networks = []
  @servers = []
  @start_options = {}
  @build_args = {}
  @redeploy_schedule = nil
end

Instance Attribute Details

#after_deploy_procObject (readonly)

Returns the value of attribute after_deploy_proc.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def after_deploy_proc
  @after_deploy_proc
end

#after_start_procObject (readonly)

Returns the value of attribute after_start_proc.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def after_start_proc
  @after_start_proc
end

#before_start_procObject (readonly)

Returns the value of attribute before_start_proc.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def before_start_proc
  @before_start_proc
end

#build_argsObject (readonly)

Returns the value of attribute build_args.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def build_args
  @build_args
end

#dependent_containersObject (readonly)

Returns the value of attribute dependent_containers.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def dependent_containers
  @dependent_containers
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def name
  @name
end

#networksObject (readonly)

Returns the value of attribute networks.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def networks
  @networks
end

#parent_containersObject (readonly)

Returns the value of attribute parent_containers.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def parent_containers
  @parent_containers
end

#redeploy_scheduleObject (readonly)

Returns the value of attribute redeploy_schedule.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def redeploy_schedule
  @redeploy_schedule
end

#serversObject (readonly)

Returns the value of attribute servers.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def servers
  @servers
end

#soft_dependent_containersObject (readonly)

Returns the value of attribute soft_dependent_containers.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def soft_dependent_containers
  @soft_dependent_containers
end

#start_commandObject (readonly)

Returns the value of attribute start_command.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def start_command
  @start_command
end

#start_optionsObject (readonly)

Returns the value of attribute start_options.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def start_options
  @start_options
end

#volumesObject (readonly)

Returns the value of attribute volumes.



2
3
4
# File 'lib/indocker/containers/container.rb', line 2

def volumes
  @volumes
end

Instance Method Details

#add_dependent_container(container) ⇒ Object



86
87
88
89
# File 'lib/indocker/containers/container.rb', line 86

def add_dependent_container(container)
  container.add_parent_container(self)
  @dependent_containers.push(container) if !@dependent_containers.include?(container)
end

#add_parent_container(container) ⇒ Object



82
83
84
# File 'lib/indocker/containers/container.rb', line 82

def add_parent_container(container)
  @parent_containers.push(container) if !@parent_containers.include?(container)
end

#add_soft_dependent_container(container) ⇒ Object



91
92
93
# File 'lib/indocker/containers/container.rb', line 91

def add_soft_dependent_container(container)
  @soft_dependent_containers.push(container) if !@soft_dependent_containers.include?(container)
end

#daemonize(flag) ⇒ Object



69
70
71
72
# File 'lib/indocker/containers/container.rb', line 69

def daemonize(flag)
  @daemonize = flag
  @attach = false
end

#get_start_option(name, default: nil) ⇒ Object



99
100
101
# File 'lib/indocker/containers/container.rb', line 99

def get_start_option(name, default: nil)
  @start_options.fetch(name) { default }
end

#imageObject



61
62
63
# File 'lib/indocker/containers/container.rb', line 61

def image
  @image || (raise ArgumentError.new("image not defined for container :#{@name}"))
end

#is_daemonized?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/indocker/containers/container.rb', line 74

def is_daemonized?
  @daemonize
end

#set_after_deploy_proc(proc) ⇒ Object



33
34
35
# File 'lib/indocker/containers/container.rb', line 33

def set_after_deploy_proc(proc)
  @after_deploy_proc = proc
end

#set_after_start_proc(proc) ⇒ Object



29
30
31
# File 'lib/indocker/containers/container.rb', line 29

def set_after_start_proc(proc)
  @after_start_proc = proc
end

#set_attachedObject



49
50
51
# File 'lib/indocker/containers/container.rb', line 49

def set_attached
  @daemonize = false
end

#set_before_start_proc(proc) ⇒ Object



25
26
27
# File 'lib/indocker/containers/container.rb', line 25

def set_before_start_proc(proc)
  @before_start_proc = proc
end

#set_build_args(opts) ⇒ Object



21
22
23
# File 'lib/indocker/containers/container.rb', line 21

def set_build_args(opts)
  @build_args = opts
end

#set_image(image) ⇒ Object



57
58
59
# File 'lib/indocker/containers/container.rb', line 57

def set_image(image)
  @image = image
end

#set_networks(networks) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/indocker/containers/container.rb', line 107

def set_networks(networks)
  @networks = networks

  networks.each do |network|
    network.add_container(self)
  end
end

#set_redeploy_schedule(schedule) ⇒ Object



115
116
117
# File 'lib/indocker/containers/container.rb', line 115

def set_redeploy_schedule(schedule)
  @redeploy_schedule = schedule
end

#set_scale(count) ⇒ Object



45
46
47
# File 'lib/indocker/containers/container.rb', line 45

def set_scale(count)
  @start_options[:scale] = count
end

#set_servers(servers) ⇒ Object



78
79
80
# File 'lib/indocker/containers/container.rb', line 78

def set_servers(servers)
  @servers = servers
end

#set_start_command(name) ⇒ Object



37
38
39
# File 'lib/indocker/containers/container.rb', line 37

def set_start_command(name)
  @start_command = name
end

#set_start_options(opts) ⇒ Object



95
96
97
# File 'lib/indocker/containers/container.rb', line 95

def set_start_options(opts)
  @start_options = opts
end

#set_tags(tag_list) ⇒ Object



41
42
43
# File 'lib/indocker/containers/container.rb', line 41

def set_tags(tag_list)
  @tags = tag_list
end

#set_volumes(volumes) ⇒ Object



103
104
105
# File 'lib/indocker/containers/container.rb', line 103

def set_volumes(volumes)
  @volumes = volumes
end

#tagsObject



53
54
55
# File 'lib/indocker/containers/container.rb', line 53

def tags
  @tags || (raise ArgumentError.new("tags not defined for container :#{@name}"))
end