-
Notifications
You must be signed in to change notification settings - Fork 1
cmd: add two new command line programs. #136
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
Conversation
…alidate. This commit adds two new command line utilities backed by go-fluentbit-config: * fluentbit-validate: validates the format of a fluentbit configuration file. * fluentbit-convert: converts configurations from and to json, classic and yaml. Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
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.
nice, LGTM
/fluentbit-convert | ||
/fluentbit-validate |
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.
need to update this to the new fluentbit-config
binary
os.Exit(1) | ||
} | ||
|
||
ext := filepath.Ext(args[0]) |
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.
very tiny nit, generally in go, recommend declaring variables close to use, so I'd move this to the line before getFormatFromExt
fmt.Printf("ERROR: %s\n", err) | ||
os.Exit(1) |
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.
for future, since we have a lot of this duplicated, it's worth DRYing this up by using a pattern like:
func main() {
if err := run(); err != nil {
fmt.Printf("ERROR: %s\n", err)
os.Exit(1)
}
}
and then putting all the logic into a run() error
function so we can do if err != nil { return err }
schema, err = fluent.GetSchema(schemaVersion) | ||
if err != nil { | ||
fmt.Printf("ERROR: %s\n", err) | ||
os.Exit(2) |
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.
curious why Exit(2)
here, but Exit(1)
for other cases (probably worth a comment in the code too)
"output format, one of: json, yaml (yml), ini or conf") | ||
pflag.StringVarP(&outputFilename, "output", "o", "", | ||
"output file (optional, default is stdout)") | ||
pflag.BoolVarP(&checkSchema, "schema", "s", false, |
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.
this seems like something we should enable by default, so maybe we flip it to no-schema-check
or something?
cmd: add new command line programs; fluentbit-convert and fluentbit-validate.
This PR adds
twoa new command line utilities backed by go-fluentbit-config:fluentbit-validate: validates the format of a fluentbit configuration file.fluentbit-convert: converts configurations from and to json, classic and yaml.