diff --git a/tljh/config-schema.json b/tljh/config-schema.json new file mode 100644 index 0000000..15591da --- /dev/null +++ b/tljh/config-schema.json @@ -0,0 +1 @@ +file:///home/bradfojb/Desktop/Personal-Repos/the-littlest-jupyterhub/schema.json \ No newline at end of file diff --git a/tljh/config.py b/tljh/config.py index d308e9e..09ecef0 100644 --- a/tljh/config.py +++ b/tljh/config.py @@ -154,6 +154,13 @@ def remove_item_from_config(config, property_path, value): return config_copy +def validate_config(config): + import json + import jsonschema + config_schema = json.load("config-schema.json") + jsonschema.validate(instance=config, schema=config_schema) + + def show_config(config_path): """ Pretty print config from given config_path @@ -180,6 +187,7 @@ def set_config_value(config_path, key_path, value): config = {} config = set_item_in_config(config, key_path, value) + validate_config(config) with open(config_path, "w") as f: yaml.dump(config, f) diff --git a/tljh/requirements-hub-env.txt b/tljh/requirements-hub-env.txt index 62f39f4..cde66e4 100644 --- a/tljh/requirements-hub-env.txt +++ b/tljh/requirements-hub-env.txt @@ -17,6 +17,8 @@ jupyterhub-tmpauthenticator>=1.0.0,<2 oauthenticator[azuread]>=16.0.4,<17 jupyterhub-idle-culler>=1.2.1,<2 +jsonschema + # pycurl is installed to improve reliability and performance for when JupyterHub # makes web requests. JupyterHub will use tornado's CurlAsyncHTTPClient when # making requests over tornado's SimpleHTTPClient automatically if pycurl is