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

PMM-4879 Added support for defaultsfile parameter. #199

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
8 changes: 6 additions & 2 deletions commands/management/add_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type addMySQLCommand struct {
ServiceName string
Username string
Password string
DefaultsFile string
AgentPassword string
Environment string
Cluster string
Expand Down Expand Up @@ -125,7 +126,8 @@ func (cmd *addMySQLCommand) GetAddress() string {
}

func (cmd *addMySQLCommand) GetDefaultAddress() string {
return "127.0.0.1:3306"
BupycHuk marked this conversation as resolved.
Show resolved Hide resolved
// address may be specified in defaults file
return ""
}

func (cmd *addMySQLCommand) GetSocket() string {
Expand Down Expand Up @@ -201,6 +203,7 @@ func (cmd *addMySQLCommand) Run() (commands.Result, error) {
ReplicationSet: cmd.ReplicationSet,
Username: cmd.Username,
Password: cmd.Password,
DefaultsFile: cmd.DefaultsFile,
AgentPassword: cmd.AgentPassword,
CustomLabels: customLabels,

Expand Down Expand Up @@ -251,8 +254,9 @@ func init() {
AddMySQLC.Flag("node-id", "Node ID (default is autodetected)").StringVar(&AddMySQL.NodeID)
AddMySQLC.Flag("pmm-agent-id", "The pmm-agent identifier which runs this instance (default is autodetected)").StringVar(&AddMySQL.PMMAgentID)

AddMySQLC.Flag("username", "MySQL username").Default("root").StringVar(&AddMySQL.Username)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for username let's use the same logic as for default address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

AddMySQLC.Flag("username", "MySQL username").StringVar(&AddMySQL.Username)
AddMySQLC.Flag("password", "MySQL password").StringVar(&AddMySQL.Password)
AddMySQLC.Flag("defaults-file", "Path to defaults file").StringVar(&AddMySQL.DefaultsFile)
AddMySQLC.Flag("agent-password", "Custom password for /metrics endpoint").StringVar(&AddMySQL.AgentPassword)

querySources := []string{mysqlQuerySourceSlowLog, mysqlQuerySourcePerfSchema, mysqlQuerySourceNone} // TODO add "auto", make it default
Expand Down