Class: Kaiser::Databases::Mysql

Inherits:
Object
  • Object
show all
Defined in:
lib/kaiser/databases/mysql.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Mysql

Returns a new instance of Mysql.



6
7
8
# File 'lib/kaiser/databases/mysql.rb', line 6

def initialize(options)
  @options = options
end

Instance Method Details

#image_nameObject



39
40
41
42
# File 'lib/kaiser/databases/mysql.rb', line 39

def image_name
  version = @options[:version] || '5.6'
  "mysql:#{version}"
end

#options_hashObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kaiser/databases/mysql.rb', line 10

def options_hash
  testpass = @options[:root_password] || 'testpassword'
  parameters = @options[:parameters] || ''
  port = @options[:port] || 3306

  {
    port: port,
    data_dir: '/var/lib/mysql',
    params: "-e MYSQL_ROOT_PASSWORD=#{testpass}",
    commands: parameters,
    waitscript_params: "
      -e MYSQL_ADDR=<%= db_container_name %>
      -e MYSQL_PORT=#{port}
      -e MYSQL_ROOT_PASSWORD=#{testpass}",
    waitscript: "      #!/bin/bash\n\n      echo \"Waiting for mysql to start.\"\n      until mysql -h\"$MYSQL_ADDR\" -P\"$MYSQL_PORT\" -uroot -p\"$MYSQL_ROOT_PASSWORD\" -e \"SELECT 1\"\n      do\n        printf \".\"\n        sleep 1\n      done\n\n      echo -e \"\\nmysql started.\"\n    SCRIPT\n  }\nend\n"