Module: Satorix::CI::Test::Shared::Database
Instance Method Summary
collapse
#colorize, #colors, #humanize_time, #log, #log_bench, #log_command, #log_duration, #log_error, #log_error_and_abort, #log_header, #run_command, #source_env_from
Instance Method Details
#host ⇒ Object
14
15
16
|
# File 'lib/satorix/CI/test/shared/database.rb', line 14
def host
ENV['DB_HOST'].to_s
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/satorix/CI/test/shared/database.rb', line 19
def name
name_key.empty? ? '' : ENV[name_key].to_s
end
|
#name_key ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/satorix/CI/test/shared/database.rb', line 24
def name_key
{
mariadb: 'MYSQL_DATABASE',
mysql: 'MYSQL_DATABASE',
postgres: 'POSTGRES_DB'
}[host.to_sym].to_s
end
|
#password ⇒ Object
33
34
35
|
# File 'lib/satorix/CI/test/shared/database.rb', line 33
def password
password_key.empty? ? '' : ENV[password_key].to_s
end
|
#password_key ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/satorix/CI/test/shared/database.rb', line 38
def password_key
{
mariadb: 'MYSQL_ROOT_PASSWORD',
mysql: 'MYSQL_ROOT_PASSWORD',
postgres: 'POSTGRES_PASSWORD'
}[host.to_sym].to_s
end
|
#url ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/satorix/CI/test/shared/database.rb', line 47
def url
unset = [host, user, password, name].select(&:empty?)
if unset.empty?
"#{ host }://#{ user }:#{ password }@#{ host }/#{ name }"
else
log 'No database has been configured.'
log 'If you would like to use a database for this job, ensure that your gitlab-config.yml is configured.'
log 'Most databases require you to specify a type, host, database, username, and password.'
nil
end
end
|
#user ⇒ Object
60
61
62
|
# File 'lib/satorix/CI/test/shared/database.rb', line 60
def user
(ENV[user_key] || 'root').to_s
end
|
#user_key ⇒ Object
65
66
67
|
# File 'lib/satorix/CI/test/shared/database.rb', line 65
def user_key
"#{ host.upcase }_USER"
end
|