Skip to content

Commit

Permalink
feat: Generate schema, but currently seems to break flexlate
Browse files Browse the repository at this point in the history
  • Loading branch information
nickderobertis committed May 28, 2022
1 parent c51471a commit d9e5705
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ flake8 = "*"
watchdog = "*"
typer = "*"
rich = "*"
py-app-conf = "*"
py-app-conf = "==0.6.0a1"
jinja2 = "*"

[pipenv]
allow_prereleases = true
12 changes: 6 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions flexlate_dev/config_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import Any, Dict

from flexlate_dev.config import FlexlateDevConfig


def create_config_schema() -> str:
return FlexlateDevConfig.schema_json(indent=2)


def main():
print(create_config_schema())


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@
INPUT_CONFIGS_DIR / "with_pre_check_create_command.yaml"
)
IGNORES_AND_EXTEND_DATA_PATH = INPUT_CONFIGS_DIR / "ignores_and_extend_data.yaml"

SCHEMA_PATH = INPUT_FILES_DIR / "schema.json"
13 changes: 13 additions & 0 deletions tests/gen_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pathlib import Path

from flexlate_dev.config_schema import create_config_schema
from tests.config import SCHEMA_PATH


def main(path: Path = SCHEMA_PATH):
schema = create_config_schema()
path.write_text(schema)


if __name__ == "__main__":
main()
251 changes: 251 additions & 0 deletions tests/input_files/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
{
"title": "FlexlateDevConfig",
"description": "Base class for settings, allowing values to be overridden by environment variables.\n\nThis is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose),\nHeroku and any 12 factor app design.",
"type": "object",
"properties": {
"data": {
"title": "Data",
"env_names": [
"data"
],
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/UserDataConfiguration"
}
},
"commands": {
"title": "Commands",
"env_names": [
"commands"
],
"type": "array",
"items": {
"$ref": "#/definitions/UserCommand"
}
},
"run_configs": {
"title": "Run Configs",
"env_names": [
"run_configs"
],
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/UserRootRunConfiguration"
}
}
},
"additionalProperties": false,
"definitions": {
"UserDataConfiguration": {
"title": "UserDataConfiguration",
"type": "object",
"properties": {
"data": {
"title": "Data",
"type": "object"
},
"folder_name": {
"title": "Folder Name",
"type": "string"
},
"ignore": {
"title": "Ignore",
"type": "array",
"items": {
"type": "string"
}
},
"extends": {
"title": "Extends",
"type": "string"
}
}
},
"UserCommand": {
"title": "UserCommand",
"type": "object",
"properties": {
"run": {
"title": "Run",
"type": "string"
},
"name": {
"title": "Name",
"type": "string"
},
"background": {
"title": "Background",
"type": "boolean"
},
"id": {
"title": "Id",
"type": "string"
}
}
},
"UserRunConfiguration": {
"title": "UserRunConfiguration",
"type": "object",
"properties": {
"pre_check": {
"title": "Pre Check",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"post_init": {
"title": "Post Init",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"pre_update": {
"title": "Pre Update",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"post_update": {
"title": "Post Update",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"data_name": {
"title": "Data Name",
"type": "string"
},
"out_root": {
"title": "Out Root",
"type": "string",
"format": "path"
},
"auto_commit_message": {
"title": "Auto Commit Message",
"type": "string"
},
"extends": {
"title": "Extends",
"type": "string"
}
}
},
"UserRootRunConfiguration": {
"title": "UserRootRunConfiguration",
"type": "object",
"properties": {
"pre_check": {
"title": "Pre Check",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"post_init": {
"title": "Post Init",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"pre_update": {
"title": "Pre Update",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"post_update": {
"title": "Post Update",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserCommand"
},
{
"type": "string"
}
]
}
},
"data_name": {
"title": "Data Name",
"type": "string"
},
"out_root": {
"title": "Out Root",
"type": "string",
"format": "path"
},
"auto_commit_message": {
"title": "Auto Commit Message",
"type": "string"
},
"extends": {
"title": "Extends",
"type": "string"
},
"publish": {
"$ref": "#/definitions/UserRunConfiguration"
},
"serve": {
"$ref": "#/definitions/UserRunConfiguration"
}
}
}
}
}

0 comments on commit d9e5705

Please sign in to comment.