Skip to content

Commit

Permalink
Add boot_config to api output so frontend can use it
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 committed Aug 26, 2024
1 parent b395f11 commit 24050f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion supervisor/api/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
PwnedSecret,
)
from ..validate import docker_ports
from .const import ATTR_REMOVE_CONFIG, ATTR_SIGNED
from .const import ATTR_BOOT_CONFIG, ATTR_REMOVE_CONFIG, ATTR_SIGNED
from .utils import api_process, api_validate, json_loads

_LOGGER: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -218,6 +218,7 @@ async def info(self, request: web.Request) -> dict[str, Any]:
ATTR_VERSION_LATEST: addon.latest_version,
ATTR_PROTECTED: addon.protected,
ATTR_RATING: rating_security(addon),
ATTR_BOOT_CONFIG: addon.boot_config,
ATTR_BOOT: addon.boot,
ATTR_OPTIONS: addon.options,
ATTR_SCHEMA: addon.schema_ui,
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ATTR_ATTRIBUTES = "attributes"
ATTR_AVAILABLE_UPDATES = "available_updates"
ATTR_BACKGROUND = "background"
ATTR_BOOT_CONFIG = "boot_config"
ATTR_BOOT_SLOT = "boot_slot"
ATTR_BOOT_SLOTS = "boot_slots"
ATTR_BOOT_TIMESTAMP = "boot_timestamp"
Expand Down
7 changes: 7 additions & 0 deletions tests/api/test_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ async def test_addon_options_boot_mode_forced_invalid(
api_client: TestClient, install_addon_example: Addon
):
"""Test changing boot mode is invalid if set to manual forced."""
install_addon_example.data["ingress"] = False
resp = await api_client.get("/addons/local_example/info")
assert resp.status == 200
body = await resp.json()
assert body["data"]["boot"] == "manual"
assert body["data"]["boot_config"] == "manual_forced"

resp = await api_client.post("/addons/local_example/options", json={"boot": "auto"})
assert resp.status == 400
body = await resp.json()
Expand Down

0 comments on commit 24050f5

Please sign in to comment.