Skip to content
Snippets Groups Projects
Verified Commit e6b358dd authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

remove redundant trailing commas, and reformat

parent ba647a07
Branches
Tags
2 merge requests!72Feature/ignore trailing comma,!71Publish LSO version 1.0
Pipeline #85189 passed
...@@ -6,9 +6,7 @@ import lso ...@@ -6,9 +6,7 @@ import lso
config_filename = os.path.join(os.path.dirname(__file__), "..", "config.json.example") config_filename = os.path.join(os.path.dirname(__file__), "..", "config.json.example")
output_filename = os.path.join( output_filename = os.path.join(os.path.dirname(__file__), "source", "_static", "openapi.json")
os.path.dirname(__file__), "source", "_static", "openapi.json"
)
os.environ["SETTINGS_FILENAME"] = config_filename os.environ["SETTINGS_FILENAME"] = config_filename
app = lso.create_app() app = lso.create_app()
......
...@@ -16,9 +16,7 @@ import json ...@@ -16,9 +16,7 @@ import json
import os import os
import sys import sys
sys.path.insert( sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso")))
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso"))
)
class RenderAsJSON(Directive): class RenderAsJSON(Directive):
...@@ -37,7 +35,7 @@ class RenderAsJSON(Directive): ...@@ -37,7 +35,7 @@ class RenderAsJSON(Directive):
return [ return [
addnodes.desc_name(text=member_name), addnodes.desc_name(text=member_name),
addnodes.desc_content("", literal), addnodes.desc_content("", literal)
] ]
...@@ -57,7 +55,7 @@ extensions = [ ...@@ -57,7 +55,7 @@ extensions = [
"sphinx_rtd_theme", "sphinx_rtd_theme",
"sphinx.ext.autodoc", "sphinx.ext.autodoc",
"sphinx.ext.coverage", "sphinx.ext.coverage",
"sphinx.ext.todo", "sphinx.ext.todo"
] ]
templates_path = ["templates"] templates_path = ["templates"]
...@@ -67,9 +65,7 @@ exclude_patterns = [] ...@@ -67,9 +65,7 @@ exclude_patterns = []
html_theme = "sphinx_rtd_theme" html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"] html_static_path = ["_static"]
html_theme_options = { html_theme_options = {"style_nav_header_background": "rgb(0 63 95)"}
"style_nav_header_background": "rgb(0 63 95)",
}
html_css_files = ["custom.css"] html_css_files = ["custom.css"]
html_logo = "_static/geant_logo_white.svg" html_logo = "_static/geant_logo_white.svg"
......
...@@ -18,11 +18,7 @@ def create_app() -> FastAPI: ...@@ -18,11 +18,7 @@ def create_app() -> FastAPI:
app = FastAPI() app = FastAPI()
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
) )
app.include_router(default_router, prefix="/api") app.include_router(default_router, prefix="/api")
......
...@@ -15,9 +15,7 @@ from pydantic import BaseModel ...@@ -15,9 +15,7 @@ from pydantic import BaseModel
CONFIG_SCHEMA = { CONFIG_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"type": "object", "type": "object",
"properties": { "properties": {"ansible_playbooks_root_dir": {"type": "string"}},
"ansible_playbooks_root_dir": {"type": "string"},
},
"required": ["ansible_playbooks_root_dir"], "required": ["ansible_playbooks_root_dir"],
"additionalProperties": False, "additionalProperties": False,
} }
......
...@@ -15,15 +15,9 @@ LOGGING_DEFAULT_CONFIG = { ...@@ -15,15 +15,9 @@ LOGGING_DEFAULT_CONFIG = {
"level": "DEBUG", "level": "DEBUG",
"formatter": "simple", "formatter": "simple",
"stream": "ext://sys.stdout", "stream": "ext://sys.stdout",
}, }
},
"loggers": {
"resource_management": {
"level": "DEBUG",
"handlers": ["console"],
"propagate": False,
},
}, },
"loggers": {"resource_management": {"level": "DEBUG", "handlers": ["console"], "propagate": False}},
"root": {"level": "INFO", "handlers": ["console"]}, "root": {"level": "INFO", "handlers": ["console"]},
} }
......
...@@ -44,11 +44,7 @@ def playbook_launch_error(reason: str, status_code: int = status.HTTP_400_BAD_RE ...@@ -44,11 +44,7 @@ def playbook_launch_error(reason: str, status_code: int = status.HTTP_400_BAD_RE
def _run_playbook_proc( def _run_playbook_proc(
job_id: str, job_id: str, playbook_path: str, extra_vars: dict, inventory: dict[str, Any] | str, callback: str
playbook_path: str,
extra_vars: dict,
inventory: dict[str, Any] | str,
callback: str,
) -> None: ) -> None:
"""Run a playbook, internal function. """Run a playbook, internal function.
...@@ -58,11 +54,7 @@ def _run_playbook_proc( ...@@ -58,11 +54,7 @@ def _run_playbook_proc(
:param str callback: Callback URL to return output to when execution is completed. :param str callback: Callback URL to return output to when execution is completed.
:param dict[str, Any] | str inventory: Ansible inventory to run the playbook against. :param dict[str, Any] | str inventory: Ansible inventory to run the playbook against.
""" """
ansible_playbook_run = ansible_runner.run( ansible_playbook_run = ansible_runner.run(playbook=playbook_path, inventory=inventory, extravars=extra_vars)
playbook=playbook_path,
inventory=inventory,
extravars=extra_vars,
)
payload = { payload = {
"status": ansible_playbook_run.status, "status": ansible_playbook_run.status,
......
...@@ -18,27 +18,10 @@ def test_playbook_endpoint_dict_inventory_success(client: TestClient, mocked_ans ...@@ -18,27 +18,10 @@ def test_playbook_endpoint_dict_inventory_success(client: TestClient, mocked_ans
"playbook_name": "placeholder.yaml", "playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL, "callback": TEST_CALLBACK_URL,
"inventory": { "inventory": {
"_meta": { "_meta": {"vars": {"host1.local": {"foo": "bar"}, "host2.local": {"hello": "world"}}},
"vars": { "all": {"hosts": {"host1.local": None, "host2.local": None}},
"host1.local": {
"foo": "bar",
},
"host2.local": {
"hello": "world",
},
},
},
"all": {
"hosts": {
"host1.local": None,
"host2.local": None,
},
},
},
"extra_vars": {
"dry_run": True,
"commit_comment": "I am a robot!",
}, },
"extra_vars": {"dry_run": True, "commit_comment": "I am a robot!"},
} }
with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _: with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _:
...@@ -60,11 +43,7 @@ def test_playbook_endpoint_str_inventory_success(client: TestClient, mocked_ansi ...@@ -60,11 +43,7 @@ def test_playbook_endpoint_str_inventory_success(client: TestClient, mocked_ansi
params = { params = {
"playbook_name": "placeholder.yaml", "playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL, "callback": TEST_CALLBACK_URL,
"inventory": { "inventory": {"all": {"hosts": "host1.local\nhost2.local\nhost3.local"}},
"all": {
"hosts": "host1.local\nhost2.local\nhost3.local",
},
},
} }
with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _: with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _:
...@@ -85,19 +64,8 @@ def test_playbook_endpoint_invalid_host_vars(client: TestClient, mocked_ansible_ ...@@ -85,19 +64,8 @@ def test_playbook_endpoint_invalid_host_vars(client: TestClient, mocked_ansible_
"playbook_name": "placeholder.yaml", "playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL, "callback": TEST_CALLBACK_URL,
"inventory": { "inventory": {
"_meta": { "_meta": {"host_vars": {"host1.local": {"foo": "bar"}, "host2.local": {"hello": "world"}}},
"host_vars": { "all": {"hosts": "host1.local\nhost2.local\nhost3.local"},
"host1.local": {
"foo": "bar",
},
"host2.local": {
"hello": "world",
},
},
},
"all": {
"hosts": "host1.local\nhost2.local\nhost3.local",
},
}, },
} }
...@@ -122,16 +90,8 @@ def test_playbook_endpoint_invalid_hosts(client: TestClient, mocked_ansible_runn ...@@ -122,16 +90,8 @@ def test_playbook_endpoint_invalid_hosts(client: TestClient, mocked_ansible_runn
"playbook_name": "placeholder.yaml", "playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL, "callback": TEST_CALLBACK_URL,
"inventory": { "inventory": {
"_meta": { "_meta": {"vars": {"host1.local": {"foo": "bar"}}},
"vars": { "all": {"hosts": ["host1.local", "host2.local", "host3.local"]},
"host1.local": {
"foo": "bar",
},
},
},
"all": {
"hosts": ["host1.local", "host2.local", "host3.local"],
},
}, },
} }
......
...@@ -22,12 +22,7 @@ def test_validate_testenv_config(data_config_filename: str) -> None: ...@@ -22,12 +22,7 @@ def test_validate_testenv_config(data_config_filename: str) -> None:
@pytest.mark.parametrize( @pytest.mark.parametrize(
"bad_config", "bad_config", [{"name": "bad version", "version": 123}, {"name": "missing version"}, {"version": "missing name"}]
[
{"name": "bad version", "version": 123},
{"name": "missing version"},
{"version": "missing name"},
],
) )
def test_bad_config(bad_config: dict) -> None: def test_bad_config(bad_config: dict) -> None:
with tempfile.NamedTemporaryFile(mode="w") as file: with tempfile.NamedTemporaryFile(mode="w") as file:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment