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

docs: plugin concept docu #1122

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mandelsoft
Copy link
Contributor

What this PR does / why we need it

Provide documentation for the library's plugin concept and how it is used in the library.

Which issue(s) this PR fixes

@mandelsoft mandelsoft requested a review from a team as a code owner November 21, 2024 15:50
@github-actions github-actions bot added the size/m Medium label Nov 21, 2024
@mandelsoft mandelsoft changed the title Plugin concept docu docs: plugin concept docu Nov 22, 2024
@github-actions github-actions bot added the component/github-actions Changes on GitHub Actions or within `.github/` directory label Nov 22, 2024
The commands and their interface are described in the [plugin reference](../../../docs/pluginreference/plugin.md).

Every plugin must provide the [`info`](../../../docs/pluginreference/plugin_info.md) command. It has to provide information
about the supported features as JSOn document on standard output.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
about the supported features as JSOn document on standard output.
about the supported features as JSON document on standard output.

about the supported features as JSOn document on standard output.
The structure of this document is described by the descriptor type in package [`api/ocm/plugin/descriptor`](descriptor/descriptor.go)

Plugin are searched in a plugin folder (typically `.ocm/plugins`), This default location can be changed by the `plugincachedir` attribute.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Plugin are searched in a plugin folder (typically `.ocm/plugins`), This default location can be changed by the `plugincachedir` attribute.
Plugins are searched in a plugin folder (typically `.ocm/plugins`), This default location can be changed by the `plugincachedir` attribute.

Could you add an example on how this attribute can be changed?


## Support for writing Plugins

To write an OCM plugin in Go, the provided [support library](ppi) can be used.
Copy link
Contributor

@jakobmoellerdev jakobmoellerdev Nov 22, 2024

Choose a reason for hiding this comment

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

is this link to ppi working?

checked the relative link, thats working

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this library inside the OCM core? That means that every go plugin has to compile the entirety of OCM itself while building, making the Plugins quite big.

Copy link
Contributor

Choose a reason for hiding this comment

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

This go section deserves its own README.md just about the ppi and is not really part of a concept imo. Happy to hear other opinions

Copy link
Contributor

@jakobmoellerdev jakobmoellerdev left a comment

Choose a reason for hiding this comment

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

The general high level overview of what a plugin is is shown, however its missing important flow charts and the technical packages are not well explained, thus making it hard for future maintainers to come back to this document to properly understand how it was envisioned.

Comment on lines +3 to +5
The ocm library supports a plugin mechanism to provide further variants
for OCM and library extension points without the need of extending and recompiling
the OCM CLI (and other applications using this library).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The ocm library supports a plugin mechanism to provide further variants
for OCM and library extension points without the need of extending and recompiling
the OCM CLI (and other applications using this library).
The OCM library supports a plugin mechanism to provide further library extension points without the need of extending and recompiling OCM (and other applications using this library).

- Uploaders
- Downloaders
- Actions
- Value sets (for example for routing slip entries)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have routing slips in OCM?

- Actions
- Value sets (for example for routing slip entries)
- Config types
- Value Merge Handler (for example for label values in delta transports)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean? I am missing explanation on what these points should be able to do. Is that available somewhere else? if so we should link it here I think

- CLI Commands (for OCM CLI)
- (transfer handlers)
- (signing tools)
- (input types for component version composition)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- (input types for component version composition)
- (new input types to compose component versions)

- Value sets (for example for routing slip entries)
- Config types
- Value Merge Handler (for example for label values in delta transports)
- CLI Commands (for OCM CLI)
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont understand why we can add CLI Commands to a plugin infrastructure that is supposedly an interface of the library. To me that means the plugin system is not confined to the library, but to the entire codebase.
For me that means either that

  • the whole plugin system is across the entirety of the OCM codebase
  • we have 2 separate plugin systems that need to be documented separately and be detached from each other

### Extension Proxies

Regardless, whether it is a static type proxy or handler proxy, the proxy implementation keeps track of it plugin and extension name and maps
the extension point functionality to the Go interface of the plugin representation, which the calls the appropriate CLI command of the plugin executable.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence is convoluted and basically only says:

"An Extension Proxy uses the Plugin & Extension name to call the go interface for the plugin that in turn calls the CLI command on the Plugin Executable"

Also im missing flow diagrams for this (and many other) interactions here.

the registration handler registration feature of those extension points
to register an appropriate registration handler using the namespace prefix `plugin`. This handler evaluate sub names to determine the plugin name and extension name in this plugin to provide an extension handler implementation proxy to for ward the handler functionality to the appropriate plugin.

### Extension Proxies
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont understand the need for an extension proxy because that mapping should be resolvable without it imo. It isnt clear to me from the concept


The proxy implementation are found in `plugin` packages below the extension point package (for example the [access method plugin proxy](../extensions/accessmethods/plugin)).

The registration handler registries are typically found in the extension point packages in (for example)) [registrations.go](../extensions/download/registration.go). The general registration handler registration handling is implemented in package [api/utils/registrations](../../utils/registrations).
Copy link
Contributor

Choose a reason for hiding this comment

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

registration handler registries and dynamic registrations are not covered well in this document imo and need additional explanation.

The proxy implementation are found in `plugin` packages below the extension point package (for example the [access method plugin proxy](../extensions/accessmethods/plugin)).

The registration handler registries are typically found in the extension point packages in (for example)) [registrations.go](../extensions/download/registration.go). The general registration handler registration handling is implemented in package [api/utils/registrations](../../utils/registrations).
It is called registration handler registry, because it is a registry which provides a namespace to name the types of handlers. It is possible to register registration handlers for a sub namespace, which then handle the registration (and creation) of handlers for a particular extension point (for example download handler).
Copy link
Contributor

Choose a reason for hiding this comment

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

If that is really why it is called, then this is a very strange concept.

Why cant the registration be done natively on the underlying registry?

It is called registration handler registry, because it is a registry which provides a namespace to name the types of handlers. It is possible to register registration handlers for a sub namespace, which then handle the registration (and creation) of handlers for a particular extension point (for example download handler).

The `command` extension point is implemented by the CLI package [cmds/ocm/commands/ocmcmds/plugins](../../../cmds/ocm/commands/ocmcmds/plugins).
Command extensions can be registered for any verb and object type name (even those not yet existing) and are automatically added to the command tree of the CLI.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

@hilmarf hilmarf added kind/chore chore, maintenance, etc. area/documentation Documentation related and removed chore labels Nov 27, 2024
@jakobmoellerdev jakobmoellerdev self-assigned this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Documentation related component/github-actions Changes on GitHub Actions or within `.github/` directory kind/chore chore, maintenance, etc. size/m Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants