Class: Gitlab::QA::Component::Minio

Inherits:
Object
  • Object
show all
Includes:
Scenario::Actable
Defined in:
lib/gitlab/qa/component/minio.rb

Constant Summary collapse

MINIO_IMAGE =
'minio/minio'.freeze
MINIO_IMAGE_TAG =
'latest'.freeze
AWS_ACCESS_KEY =
'AKIAIOSFODNN7EXAMPLE'.freeze
AWS_SECRET_KEY =
'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'.freeze
DATA_DIR =
'/data'.freeze
DEFAULT_PORT =
9000

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Scenario::Actable

#act, included

Constructor Details

#initializeMinio

Returns a new instance of Minio.



23
24
25
26
27
28
# File 'lib/gitlab/qa/component/minio.rb', line 23

def initialize
  @docker = Docker::Engine.new
  @environment = { MINIO_ACCESS_KEY: AWS_ACCESS_KEY, MINIO_SECRET_KEY: AWS_SECRET_KEY }
  @volumes = { host_data_dir => DATA_DIR }
  @buckets = []
end

Instance Attribute Details

#dockerObject (readonly)

Returns the value of attribute docker.



19
20
21
# File 'lib/gitlab/qa/component/minio.rb', line 19

def docker
  @docker
end

#environmentObject

Returns the value of attribute environment.



20
21
22
# File 'lib/gitlab/qa/component/minio.rb', line 20

def environment
  @environment
end

#name=(value) ⇒ Object

Sets the attribute name

Parameters:

  • value

    the value to set the attribute name to.



21
22
23
# File 'lib/gitlab/qa/component/minio.rb', line 21

def name=(value)
  @name = value
end

#networkObject

Returns the value of attribute network.



20
21
22
# File 'lib/gitlab/qa/component/minio.rb', line 20

def network
  @network
end

#volumesObject

Returns the value of attribute volumes.



20
21
22
# File 'lib/gitlab/qa/component/minio.rb', line 20

def volumes
  @volumes
end

Instance Method Details

#add_bucket(name) ⇒ Object



41
42
43
# File 'lib/gitlab/qa/component/minio.rb', line 41

def add_bucket(name)
  @buckets << name
end

#instanceObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/gitlab/qa/component/minio.rb', line 30

def instance
  raise 'Please provide a block!' unless block_given?

  prepare
  start

  yield self
ensure
  teardown
end

#to_configObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gitlab/qa/component/minio.rb', line 45

def to_config
  config = YAML.safe_load <<~CFG
    provider: AWS
    aws_access_key_id: #{AWS_ACCESS_KEY}
    aws_secret_access_key: #{AWS_SECRET_KEY}
    aws_signature_version: 4
    host: #{hostname}
    endpoint: http://#{hostname}:#{port}
    path_style: true
  CFG

  # Quotes get eaten up when the string is set in the environment
  config.to_s.gsub('"', '\\"')
end