Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

clay-lake
Copy link
Contributor

This PR introduces the yaml_check CLI utility (also known and executable as clayaml, @rebornplusplus), which I use for QC activities in oci-factory. Check out the read me for a brief overview.

Copy link
Member

@rebornplusplus rebornplusplus left a 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
Copy link
Member

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.

Comment on lines +67 to +72
# 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.
Copy link
Member

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.

Comment on lines +28 to +29
# Lets cat a demonstration file for comparison.
$ cat yaml_checker/demo/slice.yaml
Copy link
Member

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
Copy link
Member

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.

Comment on lines +3 to +4
An internal CLI util for formatting and validating YAML files. This project
relies on Pydantic and Ruamel libraries.
Copy link
Member

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.

Comment on lines +16 to +22
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
Copy link
Member

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
Copy link
Member

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.

Suggested change
--config CONFIG CheckYAML subclass to load
--config CONFIG Use pre-defined YAML configurations (e.g. Chisel)

Comment on lines +12 to +13
```
usage: yaml_checker [-h] [-v] [-w] [--config CONFIG] [files ...]
Copy link
Member

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
Copy link
Member

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):
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants