Fix `store addons`
Without this:
~ $ ha store addons
json: cannot unmarshal array into Go struct field Response.data of type map[string]interface {}
Plain ha store works and is the same, but as the addons subcommand exists, I suppose we should make it work, too.
That is an bug at supervisor
@pvizeli you're right but changing this in supervisor would break the frontend. Since we'd have to change this to return a dictionary and that's a breaking change in the API.
I looked into supporting the API as is in the CLI and honestly I don't think we can. We can make a ResponseList struct and a ShowJSONResponseList helper but it will break doubly on errors. The problem is data is only a list if the response is successful, if status is error then data will have an object and fail to unmarshal.
I think we have two workaround options here for now:
- Merge this PR. Possibly adjust it first to pull out the
addonsfield from the response intead of simply showing it but that might be more effort then its worth. - Add a new parameter to
/store/addonsthat causes it to return a dictionary response without changing the default response and breaking backwards compatibility
Either way we should follow that up with a breaking change plan to the supervisor API. So eventually we can remove the workaround and fix the API. But I think our process requires at least 6 months to make a change like that.
Closing as this is addressed with https://github.com/home-assistant/supervisor/pull/4589.