This repository was archived by the owner on Jun 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
PMM-4879 Added support for defaultsfile parameter. #199
Open
pkadej
wants to merge
11
commits into
percona:main
Choose a base branch
from
pkadej:PMM-4879-defaults-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7abac2e
PMM-4879 Added support for defaultsfile parameter.
pkadej 5585aa0
PMM-4879 Removing default value for defaults-file.
pkadej d27eb0a
Merge branch 'main' into PMM-4879-defaults-file
ritbl 352922c
PMM-4879 Removing default value for username.
pkadej f07e024
PMM-4879 Removing passing default MySQL address if not specified.
pkadej ccf48d1
Merge branch 'main' into PMM-4879-defaults-file
pkadej 3f9a487
PMM-4879 Code review adjustments.
pkadej 30ab469
Merge branch 'main' into PMM-4879-defaults-file
pkadej 1707775
PMM-4879 Switching API to percona/pmm repository.
pkadej ec016a5
Merge branch 'main' into PMM-4879-defaults-file
pkadej d0081c4
Merge branch 'main' into PMM-4879-defaults-file
pkadej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,7 @@ type addMySQLCommand struct { | |
| ServiceName string | ||
| Username string | ||
| Password string | ||
| DefaultsFile string | ||
| AgentPassword string | ||
| CredentialsSource string | ||
| Environment string | ||
|
|
@@ -126,9 +127,17 @@ func (cmd *addMySQLCommand) GetAddress() string { | |
| } | ||
|
|
||
| func (cmd *addMySQLCommand) GetDefaultAddress() string { | ||
| if cmd.DefaultsFile != "" { | ||
| // address might be specified in defaults file | ||
| return "" | ||
| } | ||
| return "127.0.0.1:3306" | ||
| } | ||
|
|
||
| func (cmd *addMySQLCommand) GetDefaultUsername() string { | ||
| return "root" | ||
| } | ||
|
|
||
| func (cmd *addMySQLCommand) GetSocket() string { | ||
| return cmd.Socket | ||
| } | ||
|
|
@@ -193,6 +202,8 @@ func (cmd *addMySQLCommand) Run() (commands.Result, error) { | |
| return nil, err | ||
| } | ||
|
|
||
| username := defaultsFileUsernameCheck(cmd) | ||
|
|
||
| tablestatsGroupTableLimit := int32(cmd.DisableTablestatsLimit) | ||
| if cmd.DisableTablestats { | ||
| if tablestatsGroupTableLimit != 0 { | ||
|
|
@@ -219,8 +230,9 @@ func (cmd *addMySQLCommand) Run() (commands.Result, error) { | |
| Environment: cmd.Environment, | ||
| Cluster: cmd.Cluster, | ||
| ReplicationSet: cmd.ReplicationSet, | ||
| Username: cmd.Username, | ||
| Username: username, | ||
| Password: cmd.Password, | ||
| DefaultsFile: cmd.DefaultsFile, | ||
| AgentPassword: cmd.AgentPassword, | ||
| CustomLabels: customLabels, | ||
|
|
||
|
|
@@ -272,8 +284,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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| AddMySQLC.Flag("credentials-source", "Credentials provider").ExistingFileVar(&AddMySQL.CredentialsSource) | ||
|
|
||
|
|
@@ -306,3 +319,17 @@ func init() { | |
| AddMySQLC.Flag("disable-collectors", "Comma-separated list of collector names to exclude from exporter").StringVar(&AddMySQL.DisableCollectors) | ||
| addGlobalFlags(AddMySQLC) | ||
| } | ||
|
|
||
| func defaultsFileUsernameCheck(cmd *addMySQLCommand) string { | ||
| // defaults file specified, but passed username has higher priority | ||
| if cmd.Username != "" && cmd.DefaultsFile != "" { | ||
| return cmd.Username | ||
| } | ||
|
|
||
| // username not specified, but can be in defaults files | ||
| if cmd.Username == "" && cmd.DefaultsFile != "" { | ||
| return "" | ||
| } | ||
|
|
||
| return cmd.GetDefaultUsername() | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.