-
Notifications
You must be signed in to change notification settings - Fork 88
Support extra flags for mysqld_exporter #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GuptaManan100
merged 5 commits into
planetscale:main
from
stankevich:support-extra-flags-in-mysqld-exporter
Jul 1, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7197624
Support extra flags for mysqld_exporter
stankevich 32feb5e
Update year in license header
stankevich 1283719
Regenerate operator.yaml
stankevich 5796a5e
Make mysqldExporter.resources optional
stankevich 9b78217
Add mysqld_exporter flags to the upgrade test
stankevich 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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
stankevich marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| /* | ||
| Copyright 2024 PlanetScale Inc. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package vitess | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| // TestFormatArgs tests the FormatArgs method of the Flags type. | ||
| func TestFormatArgs(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| flags Flags | ||
| want []string | ||
| }{ | ||
| { | ||
| name: "empty flags", | ||
| flags: Flags{}, | ||
| want: []string{}, | ||
| }, | ||
| { | ||
| name: "single flag", | ||
| flags: Flags{ | ||
| "flag1": "value1", | ||
| }, | ||
| want: []string{"--flag1=value1"}, | ||
| }, | ||
| { | ||
| name: "multiple flags", | ||
| flags: Flags{ | ||
| "flag2": "value2", | ||
| "flag3": "value3", | ||
| }, | ||
| want: []string{"--flag2=value2", "--flag3=value3"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := tt.flags.FormatArgs() | ||
| assert.Equal(t, tt.want, got) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // TestFormatArgsConvertBoolean tests the FormatArgsConvertBoolean method of the Flags type. | ||
| func TestFormatArgsConvertBoolean(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| flags Flags | ||
| want []string | ||
| }{ | ||
| { | ||
| name: "empty flags", | ||
| flags: Flags{}, | ||
| want: []string{}, | ||
| }, | ||
| { | ||
| name: "boolean flag true", | ||
| flags: Flags{ | ||
| "flag1": "true", | ||
| }, | ||
| want: []string{"--flag1"}, | ||
| }, | ||
| { | ||
| name: "boolean flag false", | ||
| flags: Flags{ | ||
| "flag2": "false", | ||
| }, | ||
| want: []string{"--no-flag2"}, | ||
| }, | ||
| { | ||
| name: "non-boolean flag", | ||
| flags: Flags{ | ||
| "flag3": "value3", | ||
| }, | ||
| want: []string{"--flag3=value3"}, | ||
| }, | ||
| { | ||
| name: "multiple flags", | ||
| flags: Flags{ | ||
| "flag4": "true", | ||
| "flag5": "false", | ||
| "flag6": "value6", | ||
| }, | ||
| want: []string{"--flag4", "--no-flag5", "--flag6=value6"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := tt.flags.FormatArgsConvertBoolean() | ||
| assert.Equal(t, tt.want, got) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // TestMerge tests the Merge method of the Flags type. | ||
| func TestMerge(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| flags Flags | ||
| merge Flags | ||
| result Flags | ||
| }{ | ||
| { | ||
| name: "merge empty flags", | ||
| flags: Flags{ | ||
| "flag1": "value1", | ||
| }, | ||
| merge: Flags{}, | ||
| result: Flags{ | ||
| "flag1": "value1", | ||
| }, | ||
| }, | ||
| { | ||
| name: "merge non-empty flags", | ||
| flags: Flags{ | ||
| "flag1": "value1", | ||
| }, | ||
| merge: Flags{ | ||
| "flag2": "value2", | ||
| }, | ||
| result: Flags{ | ||
| "flag1": "value1", | ||
| "flag2": "value2", | ||
| }, | ||
| }, | ||
| { | ||
| name: "merge duplicate flags", | ||
| flags: Flags{ | ||
| "flag1": "value1", | ||
| }, | ||
| merge: Flags{ | ||
| "flag1": "value2", | ||
| }, | ||
| result: Flags{ | ||
| "flag1": "value2", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := tt.flags.Merge(tt.merge) | ||
| assert.Equal(t, tt.result, got) | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
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.