Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Adding in backwards compatability for those who might not have set EX…
Browse files Browse the repository at this point in the history
…TRA_MY_CNF's correctly

Signed-off-by: Dan Kozlowski <koz@planetscale.com>
  • Loading branch information
Dan Kozlowski committed Sep 10, 2018
1 parent 0d54495 commit 3c8d86f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*.swp
tags

# emacs
*~

# Eclipse files
.classpath
.project
Expand Down Expand Up @@ -72,4 +75,4 @@ releases


# Vagrant
.vagrant
.vagrant
28 changes: 28 additions & 0 deletions go/vt/mysqlctl/mysqld.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,15 @@ func (mysqld *Mysqld) initConfig(root string, cnf *Mycnf, outFile string) error
return ioutil.WriteFile(outFile, []byte(configData), 0664)
}

func contains(haystack []string, needle string) bool {
for _, v := range haystack {
if v == needle {
return true
}
}
return false
}

func getMycnfTemplates(root string) []string {
if *mycnfTemplateFile != "" {
return []string{*mycnfTemplateFile}
Expand All @@ -627,6 +636,25 @@ func getMycnfTemplates(root string) []string {
cnfTemplatePaths = append(cnfTemplatePaths, parts...)
}

switch mysqlFlavor := os.Getenv("MYSQL_FLAVOR"); mysqlFlavor {
case "MariaDB":
path := "config/mycnf/master_mariadb.cnf"
if !contains(cnfTemplatePaths, path) {
cnfTemplatePaths = append(cnfTemplatePaths, "config/mycnf/master_mariadb.cnf")
}
case "MariaDB103":
path := "config/mycnf/master_mariadb103.cnf"
if !contains(cnfTemplatePaths, path) {
cnfTemplatePaths = append(cnfTemplatePaths, "config/mycnf/master_mariadb103.cnf")
}
default:
path := "config/mycnf/master_mysql56.cnf"
// By default we assume Mysql56 compatable
if !contains(cnfTemplatePaths, path) {
cnfTemplatePaths = append(cnfTemplatePaths, "config/mycnf/master_mysql56.cnf")
}
}

return cnfTemplatePaths
}

Expand Down

0 comments on commit 3c8d86f

Please sign in to comment.