-
Notifications
You must be signed in to change notification settings - Fork 881
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: tool to print out the diff between netplan and networkv2 schema #5200
feat: tool to print out the diff between netplan and networkv2 schema #5200
Conversation
Still TODO: current code assumes (a) the user is running from the cloudinit top level directory and (b) has netplan repo cloned into |
d8f14a3
to
5e21354
Compare
d62bd82
to
6ff01b3
Compare
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.
Script overall looks good to me.
Can we not depend on click
though? For such a small tool I don't think there's really any value add for requiring another dependency...though I'll be completely honest in saying that I never think there's a value add with click 😉
Using argparse instead would look something like:
diff --git a/tools/netplan_schema_check.py b/tools/netplan_schema_check.py
index 2dddff358..d85a7985a 100644
--- a/tools/netplan_schema_check.py
+++ b/tools/netplan_schema_check.py
@@ -1,17 +1,10 @@
-import click
+import argparse
import os
import yaml
from jsonschema import Draft4Validator
-@click.command()
-@click.option(
- "--schema_file", required=True, help="path to network v2 schema file"
-)
-@click.option(
- "--netplan_examples", required=True, help="path to netplan examples"
-)
def validate_netplan_against_networkv2(schema_file, netplan_examples):
"""
This script validates netplan example files against the cloud-init
@@ -65,6 +58,23 @@ def validate_netplan_against_networkv2(schema_file, netplan_examples):
print(yaml.dump(error_obj))
-# pylint: disable=no-value-for-parameter
+def parse_args() -> argparse.Namespace:
+ parser = argparse.ArgumentParser(
+ description="Validate netplan examples against networkv2 schema"
+ )
+ parser.add_argument(
+ "--schema-file",
+ required=True,
+ help="path to network v2 schema file",
+ )
+ parser.add_argument(
+ "--netplan-examples",
+ required=True,
+ help="path to netplan examples",
+ )
+ return parser.parse_args()
+
+
if __name__ == "__main__":
- validate_netplan_against_networkv2()
+ args = parse_args()
+ validate_netplan_against_networkv2(args.schema_file, args.netplan_examples)
6ff01b3
to
5f3e623
Compare
@TheRealFalcon I have no real attachment to click; updated with argparse |
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.
LGTM!
Proposed Commit Message
Checklist
--help
Merge type