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

feat: ui plugin management #354

Merged
merged 61 commits into from
Apr 26, 2024
Merged

feat: ui plugin management #354

merged 61 commits into from
Apr 26, 2024

Conversation

reubenmiller
Copy link
Owner

@reubenmiller reubenmiller commented Mar 10, 2024

Introducing support for management of Cumulocity IoT Plugins. Management of UI plugins is much easier now and can be easily integrated into CI/CD pipelines.

The introduction of a new group command called ui, which will be the future grouping of all UI related tasks, though currently only the UI plugin related functionality has been added, however in the future some of the other command like createHostedApplication will be moved to the ui group as well.

The following command groups have been added:

  • c8y ui plugins - Commands to manage UI plugins (upload new plugin version, delete version etc.)
  • c8y ui applications plugins - Commands to manage the UI plugins used by a UI application (e.g. install a plugin to an application)
  • c8y application versions - Commands to interact with the Application Versions api. (e.g. the raw API calls for power users who don't want any cli abstractions)

Examples

Checkout the new doc page which goes through the examples in more detail, but the following are some examples of some of the new commands.

c8y ui plugins

Installing a new version of a plugin

# Using a file
c8y ui plugins create --file ./my_plugin.zip --tags latest

# Using a url to a file
c8y ui plugins create --file "https://github.com/thin-edge/tedge-container-plugin/releases/download/1.2.3/tedge-container-plugin-ui_1.0.2.zip" --tags latest

List plugins

# local extensions
c8y ui plugins list --pageSize 100

# shared extensions
c8y ui plugins list --pageSize 100 --availability SHARED

Update/Replace tags

c8y ui plugins versions update --plugin myplugin --version "1.0.0" --tags latest,other

Delete a version

# by tag
c8y ui plugins versions delete --plugin myplugin --tag other

# by version
c8y ui plugins versions delete --plugin myplugin --version "1.0.0"

c8y ui applications plugins

Install latest version of a plugin

# implicit latest versions
c8y ui applications plugins install --application devicemanagement --plugin myplugin --plugin otherplugin

# explicit latest version
c8y ui applications plugins install --application devicemanagement --plugin myplugin@latest

Install specific version of a plugin

c8y ui applications plugins install --application devicemanagement --plugin myplugin@1.0.0

Update all plugins to latest versions

c8y ui applications plugins update --application devicemanagement --all

Or update plugins for all applications

c8y applications list --type HOSTED --pageSize 10 \
| c8y ui applications plugins update --all

Replace all existing plugins with a new set

c8y ui applications plugins replace --application devicemanagement --plugin myplugin --plugin another --plugin cloud-http-proxy

Remove orphaned or revoked plugins from an application

c8y ui applications plugins delete --application devicemanagement --invalid

Or run the same as above but for all applications matching some criteria:

c8y applications list --type HOSTED --name "devicemanagement*" \
| c8y ui applications plugins delete --application devicemanagement --invalid

Remove all plugins

c8y ui applications plugins delete --application devicemanagement --all

@reubenmiller reubenmiller force-pushed the feat-application-versions branch 2 times, most recently from df02889 to 7572c6b Compare April 2, 2024 17:56
@reubenmiller reubenmiller changed the title feat: add application versions command group feat: ui plugin management Apr 26, 2024
@reubenmiller
Copy link
Owner Author

reubenmiller commented Apr 26, 2024

Update All of the points below have been fixed/addressed.

After writing some more tests, I've come across the following potential problems which I'll need to work out if the behaviour is correct, and if not adjust it...feel free to provide feedback on what handling should be done.

  1. When should the activeVersionId be set? Currently it set when uploading a new plugin version (regardless if it is really newer or not). Would it make more sense to only activate it on the latest tag, or only if the user opts into it (e.g. via a new flag --activate)

    c8y ui plugins create --file myfile.zip --version 2.0.0     # <= the .activeVersionId will be updated
    c8y ui plugins create --file myfile.zip --version 1.0.0     # <= the .activeVersionId will again be updated

    Fix:

    • If the tag includes "latest" then set the .activeVersionId property as well.
  2. Should install/update the plugin in a UI application which does not exist fail?

    c8y ui applications plugins install --application "$NAME" --plugin "Invalid Plugin Example" --dry
    c8y ui applications plugins update --application "$NAME" --plugin "Invalid Plugin Example"
    

    Fix:

    • Fail if a given plugin is not found
  3. Listing an application's plugins (includes name and version) is a bit complicated as there isn't any api call.

    Currently the following commands just looks up the plugins from the .config.remotes and then does another lookup to retrieve the plugin, however the plugin details does not actually define which version is currently activated...

    c8y ui applications plugins list --application devicemanagement
    

    The only option would be to add a "fake" property to the output which stores the currently activated version, though modifying the api response is a bit weird (and generally I try to avoid such things if possible)

    Fix:

    • Add a new field to the data output object which includes the version as noted in the config.remotes property

@reubenmiller reubenmiller marked this pull request as ready for review April 26, 2024 12:40
…ing the reference and the plugin data models
@reubenmiller reubenmiller merged commit 61fd14f into v2 Apr 26, 2024
4 checks passed
@reubenmiller reubenmiller deleted the feat-application-versions branch April 26, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant