Class: Pygmy::Amazee

Inherits:
Object
  • Object
show all
Extended by:
DockerService
Defined in:
lib/pygmy/amazee.rb

Class Method Summary collapse

Methods included from DockerService

container_exists?, delete, has_docker_client?, ps, pull, running?, start, start_cmd, stop

Class Method Details

.ls_cmdObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pygmy/amazee.rb', line 18

def self.ls_cmd
  cmd = 'docker image ls --format "{{.Repository}}:{{.Tag}}"'
  list = Sh.run_command(cmd)

  # For better handling of containers, we should compare our
  # results against a whitelist instead of preferential
  # treatment of linux pipes.
  containers = list.stdout.split("\n")
  amazee_containers = []
  containers.each do |container|
    # Selectively target amazeeio/* images.
    if container.include?('amazeeio/')
      # Filter out items which we don't want.
      unless container.include?("none") || container.include?("ssh-agent") || container.include?("haproxy")
        amazee_containers.push(container)
      end
    end
  end
  amazee_containers
end

.pull(image_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/pygmy/amazee.rb', line 7

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_allObject



39
40
41
42
43
44
45
46
# File 'lib/pygmy/amazee.rb', line 39

def self.pull_all
  list = self.ls_cmd
  unless list.nil?
    list.each do |image|
      pull(image)
    end
  end
end