Add MysqlConfig protocol option (#2161)

Enables configuring MySQL to run with unix domain sockets.
Closes #2160
This commit is contained in:
Max Bigras 2019-12-04 09:48:24 -08:00 committed by Zachary Wasserman
parent 6580fe1c5a
commit b524d813ca
2 changed files with 6 additions and 1 deletions

View file

@ -17,6 +17,7 @@ const (
// MysqlConfig defines configs related to MySQL
type MysqlConfig struct {
Protocol string
Address string
Username string
Password string
@ -135,6 +136,8 @@ type KolideConfig struct {
// filled into the KolideConfig struct
func (man Manager) addConfigs() {
// MySQL
man.addConfigString("mysql.protocol", "tcp",
"MySQL server communication protocol (tcp,unix,...)")
man.addConfigString("mysql.address", "localhost:3306",
"MySQL server address (host:port)")
man.addConfigString("mysql.username", "kolide",
@ -253,6 +256,7 @@ func (man Manager) LoadConfig() KolideConfig {
return KolideConfig{
Mysql: MysqlConfig{
Protocol: man.getConfigString("mysql.protocol"),
Address: man.getConfigString("mysql.address"),
Username: man.getConfigString("mysql.username"),
Password: man.getConfigString("mysql.password"),

View file

@ -274,9 +274,10 @@ func registerTLS(config config.MysqlConfig) error {
func generateMysqlConnectionString(conf config.MysqlConfig) string {
tz := url.QueryEscape("'-00:00'")
dsn := fmt.Sprintf(
"%s:%s@(%s)/%s?charset=utf8mb4&parseTime=true&loc=UTC&time_zone=%s&clientFoundRows=true&allowNativePasswords=true",
"%s:%s@%s(%s)/%s?charset=utf8mb4&parseTime=true&loc=UTC&time_zone=%s&clientFoundRows=true&allowNativePasswords=true",
conf.Username,
conf.Password,
conf.Protocol,
conf.Address,
conf.Database,
tz,