-
Notifications
You must be signed in to change notification settings - Fork 2
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: yaml_check internal CLI utility #22
base: main
Are you sure you want to change the base?
Conversation
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 is a great initiative Clay, thanks! I left a bunch of comments and suggestions.
@@ -0,0 +1,2 @@ | |||
pydantic==2.8.2 | |||
ruamel.yaml==0.18.6 |
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.
nit: Let's add a line break at the end here.
# Note: Missing new line at EOF | ||
|
||
# Now we can run the yaml_checker to format the same file. | ||
# Note how comments are preserved during sorting of lists and | ||
# dict type objects. If you want to test the validator, | ||
# uncomment the hello field. |
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.
Let's end the previous code block before line 67, have this text as normal text in the markdown and start another code block after line 72.
# Lets cat a demonstration file for comparison. | ||
$ cat yaml_checker/demo/slice.yaml |
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.
Let's have this as a bash
block and the following yaml as a yaml
block for better syntax.
# Note how comments are preserved during sorting of lists and | ||
# dict type objects. If you want to test the validator, | ||
# uncomment the hello field. | ||
$ yaml_checker --config=Chisel yaml_checker/demo/slice.yaml |
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.
Like the previous comment, let's have this as a bash
block and the rest as an yaml
block for better syntax highlighting.
An internal CLI util for formatting and validating YAML files. This project | ||
relies on Pydantic and Ruamel libraries. |
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.
I guess the second line is not necessary, since there is a requirement.txt
which lists those.
files Additional files to process (optional). | ||
|
||
options: | ||
-h, --help show this help message and exit | ||
-v, --verbose Enable verbose output. | ||
-w, --write Write yaml output to disk. | ||
--config CONFIG CheckYAML subclass to load |
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.
nit: let's be consistent with the trailing dots. Usually we don't have trailing dots in help.
-h, --help show this help message and exit | ||
-v, --verbose Enable verbose output. | ||
-w, --write Write yaml output to disk. | ||
--config CONFIG CheckYAML subclass to load |
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.
How about the following? Or, something like that.
--config CONFIG CheckYAML subclass to load | |
--config CONFIG Use pre-defined YAML configurations (e.g. Chisel) |
``` | ||
usage: yaml_checker [-h] [-v] [-w] [--config CONFIG] [files ...] |
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.
Would it be possible to add the following line here?
An internal CLI util for formatting and validating YAML files.
@@ -0,0 +1,111 @@ | |||
# YAML Checker |
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.
suggestion: let's stick with clayaml since this is an internal tool anyway.
root: Dict[str, Any] | ||
|
||
|
||
class SDF(BaseModel): |
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.
How about SliceDef
instead of SDF
?
This PR introduces the
yaml_check
CLI utility (also known and executable asclayaml
, @rebornplusplus), which I use for QC activities in oci-factory. Check out the read me for a brief overview.