Skip to content
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

output/csv: Remove the support for snake_case options #3390

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 3 additions & 10 deletions output/csv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import (

// Config is the config for the csv output
type Config struct {
// Samples.
FileName null.String `json:"file_name" envconfig:"K6_CSV_FILENAME"`
SaveInterval types.NullDuration `json:"save_interval" envconfig:"K6_CSV_SAVE_INTERVAL"`
TimeFormat null.String `json:"time_format" envconfig:"K6_CSV_TIME_FORMAT"`
FileName null.String `json:"fileName" envconfig:"K6_CSV_FILENAME"`
SaveInterval types.NullDuration `json:"saveInterval" envconfig:"K6_CSV_SAVE_INTERVAL"`
TimeFormat null.String `json:"timeFormat" envconfig:"K6_CSV_TIME_FORMAT"`
Comment on lines +18 to +20
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we use the json encoding on this anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not aware of it, I changed it mostly for consistency

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm this is used in the config file ... Can we revert this as this is another breaking change.

I have no idea if somebody is using this, but breaking it seems bad to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Specifically here

Collectors map[string]json.RawMessage `json:"collectors"`

}

// TimeFormat custom enum type
Expand Down Expand Up @@ -75,17 +74,11 @@ func ParseArg(arg string, logger logrus.FieldLogger) (Config, error) {
return c, fmt.Errorf("couldn't parse %q as argument for csv output", arg)
}
switch r[0] {
case "save_interval":
logger.Warnf("CSV output argument '%s' is deprecated, please use 'saveInterval' instead.", r[0])
fallthrough
case "saveInterval":
err := c.SaveInterval.UnmarshalText([]byte(r[1]))
if err != nil {
return c, err
}
case "file_name":
logger.Warnf("CSV output argument '%s' is deprecated, please use 'fileName' instead.", r[0])
fallthrough
case "fileName":
c.FileName = null.StringFrom(r[1])
case "timeFormat":
Expand Down
33 changes: 1 addition & 32 deletions output/csv/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,45 +80,14 @@ func TestParseArg(t *testing.T) {
TimeFormat: null.NewString("unix", false),
},
},
"save_interval=5s": {
config: Config{
FileName: null.NewString("file.csv", false),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
expectedLogEntries: []string{
"CSV output argument 'save_interval' is deprecated, please use 'saveInterval' instead.",
},
},
"saveInterval=5s": {
config: Config{
FileName: null.NewString("file.csv", false),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
},
"file_name=test.csv,save_interval=5s": {
config: Config{
FileName: null.StringFrom("test.csv"),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
expectedLogEntries: []string{
"CSV output argument 'file_name' is deprecated, please use 'fileName' instead.",
"CSV output argument 'save_interval' is deprecated, please use 'saveInterval' instead.",
},
},
"fileName=test.csv,save_interval=5s": {
config: Config{
FileName: null.StringFrom("test.csv"),
SaveInterval: types.NullDurationFrom(5 * time.Second),
TimeFormat: null.NewString("unix", false),
},
expectedLogEntries: []string{
"CSV output argument 'save_interval' is deprecated, please use 'saveInterval' instead.",
},
},
"filename=test.csv,save_interval=5s": {
"filename=test.csv,saveInterval=5s": {
expectedErr: true,
},
"fileName=test.csv,timeFormat=rfc3339": {
Expand Down