Class: MinioRunner::McManager

Inherits:
Object
  • Object
show all
Defined in:
lib/minio_runner/mc_manager.rb

Class Method Summary collapse

Class Method Details

.bucket_exists?(alias_name, name) ⇒ Boolean



10
11
12
13
14
15
# File 'lib/minio_runner/mc_manager.rb', line 10

def bucket_exists?(alias_name, name)
  system(
    *command.concat(["ls", "#{alias_name}/#{name}"]),
    out: MinioServerManager.log_file_path,
  )
end

.commandObject



6
7
8
# File 'lib/minio_runner/mc_manager.rb', line 6

def command
  ["#{MinioRunner::McBinary.binary_file_path}"]
end

.create_bucket(alias_name, name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/minio_runner/mc_manager.rb', line 17

def create_bucket(alias_name, name)
  MinioRunner.logger.debug("Creating bucket #{alias_name}/#{name}...")
  if !bucket_exists?(alias_name, name)
    system(
      *command.concat(["mb", "#{alias_name}/#{name}"]),
      out: MinioServerManager.log_file_path,
    )
    MinioRunner.logger.debug("Created  #{alias_name}/#{name}.")
  else
    MinioRunner.logger.debug("Bucket #{alias_name}/#{name} already exists, doing nothing.")
  end
end

.set_alias(name, url) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/minio_runner/mc_manager.rb', line 30

def set_alias(name, url)
  MinioRunner.logger.debug("Setting alias #{name} to #{url}...")
  system(
    *command.concat(
      [
        "alias",
        "set",
        name,
        url,
        MinioRunner.config.minio_root_user,
        MinioRunner.config.minio_root_password,
      ],
    ),
    out: MinioServerManager.log_file_path,
  )
  MinioRunner.logger.debug("Set alias #{name} to #{url}.")
end

.set_anon(alias_name, bucket, policy) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/minio_runner/mc_manager.rb', line 48

def set_anon(alias_name, bucket, policy)
  MinioRunner.logger.debug(
    "Setting anonymous access for #{alias_name}/#{bucket} to policy #{policy}...",
  )
  system(
    *command.concat(["anonymous", "set", policy, "#{alias_name}/#{bucket}"]),
    out: MinioServerManager.log_file_path,
  )
  MinioRunner.logger.debug("Anonymous access set for #{alias_name}/#{bucket}.")
end