-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(cli): Add validate sub command #1064
Conversation
The syntax for this subcommand is `vector -c ./foo.toml validate`, which is potentially a little confusing. Please refer to discussion within #98. We also need to separate out the topology validation so that data directory checks are done separately. Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
The logic for walking and verifying a topology config has been extracted and moved into its own function. This allows the validate subcommand to check a config topology without attempting to create the underlying components. The checks for >0 sources and >0 sinks have also been moved from config parsing into topology building. The reason for this is to accomodate config parsing and validation of snippets (which might only contain partial topologies) in future work. Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
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.
Looking great!
Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
For the betterment of society this commit allows users to specify the target config path of the validate command after the command itself, e.g. `vector validate -c ./foo.toml`. In order for that to be safe we need to deny users the ability to specify the path at the root (as it will be ignored). To solve this I've added a check at the beginning of the command to ensure that the root config flag is not default. This solution is pretty gross so I'm hoping there's a more elegant way to do this. Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
For the betterment of society I've added a commit that allows users to specify the target config path of the validate command after the command itself, e.g. To solve this I've added a check at the beginning of the command to ensure that the root config flag is not default. This solution is pretty gross as we have to copy/paste our default config path several times and ensure they have parity. Ideally I would like to have a const defined with this path, but it doesn't appear as though you can reference a variable within the StructOpt attribute. Alternatively, maybe we could reference the default_value attribute of the struct field within the validate implementation, but I'm not sure that's possible. Help me. |
Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
fe09cee
to
2152564
Compare
@Jeffail I think your approach is looking great, let me know once this is out of a draft PR and ill give it a final review :) if you have specific things you'd like me to look at let me know. |
@LucioFranco thanks, I'd say the only thing left outstanding is whether you have an idea as to how the strings defined https://github.com/timberio/vector/pull/1064/files#diff-639fbc4ef05b315af92b4d836c31b023R101 and https://github.com/timberio/vector/pull/1064/files#diff-639fbc4ef05b315af92b4d836c31b023R369 could be forced to have parity. My worry is that one day we might choose to change the default path but forget to update the check within |
Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
@LucioFranco think I'm ready for a final review now. |
Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
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.
Well I thought I approved this already...but I guess it didn't go through but LGTM!
@Jeffail do you want to attempt to add documentation for this? I think it would make sense here: |
Signed-off-by: Ashley Jeffs <ash@jeffail.uk>
23fbbfb
to
7e130d8
Compare
Adds a sub command
validate
that performs linting of target configs.The syntax for this subcommand is
vector -c ./foo.toml validate
, which is potentially a little confusing. Please refer to discussion within #98.