Module: Plankton::EnvVars

Defined in:
lib/plankton/env_vars.rb

Instance Method Summary collapse

Instance Method Details

#confirm?Boolean



36
37
38
# File 'lib/plankton/env_vars.rb', line 36

def confirm?
  opts.confirm
end

#hostnameObject



3
4
5
6
7
8
9
10
# File 'lib/plankton/env_vars.rb', line 3

def hostname
  host = (ENV.fetch('REGISTRY_CLI_HOSTNAME', nil) || opts.hostname)
  if host.nil? || host == 'hostname'
    raise EnvVarNotFoundError, 'Docker Registry hostname'
  end
  host = host.dup.prepend('https://') unless %r{^https?://} =~ host
  host.gsub(%r{/*$}, '').strip
end

#passwordObject



22
23
24
25
26
# File 'lib/plankton/env_vars.rb', line 22

def password
  pass = (ENV.fetch('REGISTRY_CLI_PASSWORD', nil) || opts.password)
  return nil if pass.nil?
  pass.gsub(%r{/*$}, '').strip
end

#password?Boolean



28
29
30
# File 'lib/plankton/env_vars.rb', line 28

def password?
  !password.nil?
end

#usernameObject



12
13
14
15
16
# File 'lib/plankton/env_vars.rb', line 12

def username
  user = (ENV.fetch('REGISTRY_CLI_USERNAME', nil) || opts.username)
  return nil if user.nil?
  user.gsub(%r{/*$}, '').strip
end

#username?Boolean



18
19
20
# File 'lib/plankton/env_vars.rb', line 18

def username?
  !username.nil?
end

#verbose?Boolean



32
33
34
# File 'lib/plankton/env_vars.rb', line 32

def verbose?
  opts.verbose
end