-
Notifications
You must be signed in to change notification settings - Fork 204
nit: remove double validation on folder when register flag #2173
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
base: reboot
Are you sure you want to change the base?
nit: remove double validation on folder when register flag #2173
Conversation
Signed-off-by: SamYuan1990 <[email protected]>
@sthaha , I am confused with the code logic in config pkg, as there many times validation been invoked. I hope we can make it clean as a Validation function in public or a validation function as hook. To follow single response, or KISS. |
// Validate config before run | ||
if err := cfg.Validate(); err != nil { | ||
logger.Error("Error validate command line flags", "error", err.Error()) | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not make it the responsibility of the caller to validate the config.
if err := cfg.Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load should validate
hostSysFS := app.Flag(HostSysFSFlag, "Host sysfs path").Default("/sys").ExistingDir() | ||
hostProcFS := app.Flag(HostProcFSFlag, "Host procfs path").Default("/proc").ExistingDir() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not make it String since we must ensure the that the directory exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double validation is fine since config can be loaded through yaml which can be the overriden by flags.
but wait, if For instance, on Mac OS, |
I agree that if |
I suppose we double validate
/sys
or/proc
folder if we follow the default settings, or if we set up another folder other than/sys
or/proc
we still validate those folder during flag reg process and we have another validation function to check if the config is validated. So in this PR, just remove validation in flag reg process.