class Mcrain::Mysql
Constants
- DB_DIR_ON_CONTAINER
Attributes
database[RW]
db_dir[RW]
password[RW]
username[RW]
Public Instance Methods
build_docker_options()
click to toggle source
Calls superclass method
Mcrain::ContainerController#build_docker_options
# File lib/mcrain/mysql.rb, line 41 def build_docker_options r = super username = self.username || "root" # overwrite locally key_user = (username == "root") ? nil : "MYSQL_USER" key_pw = (username == "root") ? "MYSQL_ROOT_PASSWORD" : "MYSQL_PASSWORD" envs = [] envs << (password.blank? ? "MYSQL_ALLOW_EMPTY_PASSWORD=yes" : "#{key_pw}=#{password}") envs << "#{key_user}=#{username}" if key_user envs << "MYSQL_DATABASE=#{database}" if database add_volume_options(r, DB_DIR_ON_CONTAINER, File.expand_path(db_dir)) if db_dir && !db_dir.empty? r['Env'] = envs unless envs.empty? return r end
client_class()
click to toggle source
# File lib/mcrain/mysql.rb, line 16 def client_class ::Mysql2::Client end
client_init_args()
click to toggle source
# File lib/mcrain/mysql.rb, line 20 def client_init_args options = { host: host, port: port, username: username || "root" } options[:password] = password if password.present? options[:database] = database if database.present? return [options] end
client_require()
click to toggle source
# File lib/mcrain/mysql.rb, line 12 def client_require 'mysql2' end
wait_for_ready()
click to toggle source
# File lib/mcrain/mysql.rb, line 31 def wait_for_ready client.query("show databases").to_a end