Conversation
fulghum
left a comment
There was a problem hiding this comment.
Looks good! Just a couple minor suggestions.
go/cmd/dolt/commands/config.go
Outdated
| var ConfigOptions = map[string]string{ | ||
| config.UserEmailKey: "", | ||
| config.UserNameKey: "", | ||
| config.UserCreds: "", | ||
| config.DoltEditor: "", | ||
| config.InitBranchName: "", | ||
| config.RemotesApiHostKey: "", | ||
| config.RemotesApiHostPortKey: "", | ||
| config.AddCredsUrlKey: "", | ||
| config.DoltLabInsecureKey: "", | ||
| config.MetricsDisabled: "", | ||
| config.MetricsHost: "", | ||
| config.MetricsPort: "", | ||
| config.MetricsInsecure: "", | ||
| config.PushAutoSetupRemote: "", | ||
| config.ProfileKey: "", | ||
| } |
There was a problem hiding this comment.
Since anytime a new config value constant is added it'll need to be added to this map (i.e. high coupling), it's a good hint that these two pieces of code might benefit from being very close together. Try moving this map into the same file as where the config constants are defined.
There's another common Go trick for maps where you don't care about the values... you'll often see them written as:
var Foo = map[string]struct{}{
"bar": {},
}
The advantage to that form is that it's unambiguous to future code readers (once you know this pattern at least) that the value of the map is ignored. If you use bool or string, then future code readers may think that the value has some meaning. It is also slightly more efficient for the runtime to store these, because there's an optimization where Go knows empty structs don't need to be allocated anywhere, as opposed to a bool or a string, which does require allocation, even if they are empty/false. It's a small efficiency gain, but worth knowing about, especially since you'll see this pattern fairly often.
go/cmd/dolt/dolt.go
Outdated
| } | ||
|
|
||
| globalConfig.Iter(func(name, val string) (stop bool) { | ||
| if _, ok := commands.ConfigOptions[name]; !ok && !strings.HasPrefix(name, env.SqlServerGlobalsPrefix) { |
There was a problem hiding this comment.
(minor) Might be worth running strings.ToLower on name here and for the local config section below. It does look like the current code always lowercases the names, but older versions may not have, plus people could always manually edit the config file.
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
Prints a warning if any nonsense variables are found in global or local config files whenever any CLI command is run. Also restricts users from adding any nonsense variables with
dolt config --addordolt config --set.Resolves: #7165