Class: Gitlab::QA::Component::Alpine

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/qa/component/alpine.rb

Overview

Generic helper component running alpine linux image Useful for populating volumes beforehand or running any other action that requires a running container and has to be performed before main component containers are started

Constant Summary collapse

DOCKER_IMAGE =
"alpine/curl"
DOCKER_IMAGE_TAG =
"latest"

Constants inherited from Base

Base::CERTIFICATES_PATH

Instance Attribute Summary

Attributes inherited from Base

#additional_hosts, #airgapped_network, #docker, #environment, #logger, #network, #network_aliases, #ports, #runner_network, #volumes

Instance Method Summary collapse

Methods inherited from Base

#add_network_alias, #hostname, #image, #initialize, #instance, #ip_address, #prepare_airgapped_network, #prepare_docker_container, #prepare_docker_image, #prepare_network, #prepare_runner_network, #process_exec_commands, #pull, #restart, #start_instance, #tag, #teardown, #teardown!

Methods included from Scenario::Actable

#act, included

Constructor Details

This class inherits a constructor from Gitlab::QA::Component::Base

Instance Method Details

#nameObject



16
17
18
# File 'lib/gitlab/qa/component/alpine.rb', line 16

def name
  @name ||= "alpine-#{SecureRandom.hex(4)}"
end

#prepareObject



31
32
33
# File 'lib/gitlab/qa/component/alpine.rb', line 31

def prepare
  prepare_docker_container
end

#startObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/qa/component/alpine.rb', line 20

def start
  docker.run(image: image, tag: tag, args: ["tail", "-f", "/dev/null"]) do |command|
    command << "-d"
    command << "--name #{name}"
    command << "--network #{network}" if network

    volumes.each { |to, from| command.volume(to, from, 'Z') }
    environment.each { |key, value| command.env(key, value) }
  end
end