mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
Add MysqlConfig protocol option (#2161)
Enables configuring MySQL to run with unix domain sockets. Closes #2160
This commit is contained in:
parent
6580fe1c5a
commit
b524d813ca
2 changed files with 6 additions and 1 deletions
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue