Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[marketplace] Add a 3rd Party marketplace #2592

Merged
merged 9 commits into from
Dec 11, 2021
Merged

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Dec 5, 2021

This adds a new AddonService implementation that allows to add marketplaces maintained by 3rd party individuals (similar to alternative app stores on the smartphone).

The configuration allows one or multiple marketplaces which provide their addons via JSON files (instead of a topic in the community forum). Installation is done by re-using the already present .jar, .kar, .json, .yaml bundle installers (same as community marketplace).

The JSON referenced by the URL encapsulates an array of one or more addon definitions like

[
  {
    "id": "tld-johndoe-binding-foo",
    "type": "binding",
    "title": "Foo Binding",
    "description": "This binding integrates Foo smarthome devices with openHAB",
    "link": "https://johndoe.tld/foodoc.html",
    "version": "1.0.0",
    "author": "John Doe",
    "maturity": "stable",
    "content_type": "application/vnd.openhab.feature;type=karfile",
    "url": "https://johndoe.tld/tld.johndoe.binding.foo-1.0.0.kar"
  },
  {
    ...
  }
]

This could also be used to distribute version-specific (by using different JSON files) bindings with back ported feature or bugfixes.

Signed-off-by: Jan N. Klug jan.n.klug@rub.de

This adds a new marketplace addon provider which allows to add marketplaces maintained by 3rd party organizations (similar to alternative app stores on your smartphone). The configuration allows one or multiple marketplaces which provide their addons via JSON files (instead of a topic in the community forum).

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@J-N-K J-N-K requested a review from a team as a code owner December 5, 2021 17:21
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@clinique
Copy link
Contributor

clinique commented Dec 8, 2021

I wish this will be accepted.

Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with this new service. From my pov we should call is just JsonAddonService without the phrase "Marketplace".

Comment on lines 67 to 74
private static final Map<String, AddonType> TAG_ADDON_TYPE_MAP = Map.of( //
"automation", new AddonType("automation", "Automation"), //
"binding", new AddonType("binding", "Bindings"), //
"misc", new AddonType("misc", "Misc"), //
"persistence", new AddonType("persistence", "Persistence"), //
"transformation", new AddonType("transformation", "Transformations"), //
"ui", new AddonType("ui", "User Interfaces"), //
"voice", new AddonType("voice", "Voice"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be refactored to be a global constant for all AddonServices? Or do we expect different capabillties of those?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy, but the question is what the correct place would be. In general an AddonService is not required to supply all AddonTypes, however each AddonService could pick what is available. We do not have an AddonConstants class or something similar which would be a good fit. Another solution would be to make the map public in the CommunityMarketplaceAddonService but that would mix different AddonServices which should IMO be avoided.

I hate duplicated code, but IMO here it seems the best solution.

@cweitkamp cweitkamp added the enhancement An enhancement or new feature of the Core label Dec 9, 2021
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@J-N-K
Copy link
Member Author

J-N-K commented Dec 10, 2021

@cweitkamp Thanks for the review. I have addressed all but one comment (the refactoring of the duplicated map).

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
*/
@Component(immediate = true, configurationPid = "org.openhab.core.marketplace.json", //
property = Constants.SERVICE_PID + "=org.openhab.core.marketplace.json")
@ConfigurableService(category = "system", label = "JSON 3rd Party Addon Service", description_uri = JsonAddonService.CONFIG_URI)
Copy link
Member

@ghys ghys Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an UX perspective - it's the 3rd configurable service related to add-ons that will appear under "Settings > System Services" with barely any parameter which is beginning to become a lot and quite messy. If anything we should really think about reducing this proliferation and merging related configurations (I've talked about this before).

  • Add-on Management + Community Marketplace + JSON 3rd Party Addon Service (also note the difference in spelling of Add-on/Addon + JSON/Json in the existing "Json Storage"!) => Add-on Management
  • Regional Settings + Ephemeris => Regional Settings
  • Audio + Voice => Audio & Voice
  • Maybe also Sitemap + Charts => ?

Maybe have configurable services for the sole purposes of providing the configuration and have the actual services inject them?

Copy link
Member Author

@J-N-K J-N-K Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, too. The problem is that we - at least I know of no way to do it - can't group in the UI within a category. If we merge everything under e.g. system:addon (which in general would be preferred IMO), it's not easily visible to the user which parameter affects which service.

I'll fix the spelling.

Copy link
Member Author

@J-N-K J-N-K Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to introduce another level in der config description URI? E.g. system:addon:management, system:addon:marketplace and system:addon:json? The UI could then group by the second level (if present).

The good thing to this approach is that it is fully backward compatible since the service PID stays the same and therefore the configuration is also used after the config description URI changed. This also leaves us time to decide what the best approach is, since it would not create a problem if it is changed after the release.

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

I agree on the grouping of settings in the UI. This PR does not need to wait for a solution for that as we obviously have to change other ConfigurableServices too to reach that goal.

@cweitkamp cweitkamp merged commit 8a29b07 into openhab:main Dec 11, 2021
@wborn wborn added this to the 3.2 milestone Dec 13, 2021
@wborn wborn changed the title [marketplace] add a 3rd Party marketplace [marketplace] Add a 3rd Party marketplace Dec 18, 2021
@J-N-K J-N-K deleted the marketplace branch February 25, 2022 07:50
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
* [marketplace] add a 3rd Party compatible marketplace

This adds a new marketplace addon provider which allows to add marketplaces maintained by 3rd party organizations (similar to alternative app stores on your smartphone). The configuration allows one or multiple marketplaces which provide their addons via JSON files (instead of a topic in the community forum).

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
GitOrigin-RevId: 8a29b07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants