Class: Pygmy::Amazee
Class Method Summary
collapse
container_exists?, delete, has_docker_client?, ps, pull, running?, start, start_cmd, stop
Class Method Details
.ignore_list ⇒ Object
12
13
14
|
# File 'lib/pygmy/amazee.rb', line 12
def self.ignore_list
%w(none ssh-agent haproxy)
end
|
.ls_cmd ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/pygmy/amazee.rb', line 27
def self.ls_cmd
cmd = 'docker image ls --format "{{.Repository}}:{{.Tag}}"'
list = Sh.run_command(cmd)
containers = list.stdout.split("\n")
amazee_containers = []
containers.each do |container|
if container.include?(self.prefix)
include_container = true
self.ignore_list.each do |item|
if container.include?(item)
include_container = false
end
end
amazee_containers.push(container) if include_container
end
end
amazee_containers
end
|
.prefix ⇒ Object
8
9
10
|
# File 'lib/pygmy/amazee.rb', line 8
def self.prefix
"amazeeio/"
end
|
.pull(image_name) ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/pygmy/amazee.rb', line 16
def self.pull(image_name)
puts "Pulling Docker Image #{Shellwords.escape(image_name)}".yellow
pull_cmd = "docker pull #{Shellwords.escape(image_name)}"
success = Sh.run_command(pull_cmd).success?
unless success
raise RuntimeError.new(
"Failed to update #{self.container_name}. Command #{pull_cmd} failed"
)
end
end
|
.pull_all ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/pygmy/amazee.rb', line 52
def self.pull_all
list = self.ls_cmd
unless list.nil?
list.each do |image|
self.pull(image)
end
end
end
|