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: Extend plugin API to support transfer handlers #937

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

Conversation

mandelsoft
Copy link
Contributor

@mandelsoft mandelsoft commented Sep 23, 2024

What this PR does / why we need it

The OCM library already provides an extension point to provide transfer handlers
controlling the transport of component versions from one environment into another one.

A transfer handler controls:

  • how to handle changes in component versions when re-transporting them
  • how to resolve component references and whether they should be transported, also
  • whether sources and resources should be transported by value or by reference.

So far, there were two implementations:

  • a standard implementation working on the standard transfer options, like --recursive or --copy-resources
  • a spiff++ based implementation based on the standard handler adding the capability to influence
    the behaviour based on a spiff script.

On the command line interface always the spiff handler was used which works like the standard handler if no script
is configured.

This PR adds three new features:

  • it supports a hierarchical naming scheme to denote transfer handlers (like for download and upload handlers),
    which can be used un the command line to select and configure supported transfer handler types.
  • it extends the Plugin API to support transfer handler. This way a plugin may implement the transfer handler interface to
    provide an arbitrary rule set controlling the transport process.
  • A general configuration option for handlers allows for passing additional handler configuration

Similar to the uploaders and downloaders the naming scheme for transfer handlers looks as follows:

  • ocm/<builtin handlers>: used for the already existing standard and spiff handlers.
    Additional handlers may now add themselves to appropriate names to be usable from the command line.
  • plugin/' A dedicated handler maps plugin provided transfer handlers into the naming scheme.
    It uses the sub scheme <plugin name>[/<handler name>]. A plugin may provide multiple (named) handlers.

Which issue(s) this PR fixes

@mandelsoft mandelsoft force-pushed the plugins branch 5 times, most recently from 1c0a15f to 7c7bdfb Compare September 26, 2024 10:57
@mandelsoft mandelsoft marked this pull request as ready for review September 30, 2024 15:41
@mandelsoft mandelsoft requested a review from a team as a code owner September 30, 2024 15:41
@hilmarf hilmarf added this to the 2024-Q4 milestone Oct 1, 2024
@mandelsoft mandelsoft requested a review from fabianburth October 1, 2024 07:21
@mandelsoft mandelsoft force-pushed the plugins branch 2 times, most recently from e25337f to 93d164c Compare October 14, 2024 13:26
api/ocm/plugin/ppi/utils.go Outdated Show resolved Hide resolved
api/tech/access.go Outdated Show resolved Hide resolved
api/ocm/plugin/ppi/interface.go Outdated Show resolved Hide resolved
@fabianburth
Copy link
Contributor

fabianburth commented Oct 29, 2024

Since I've been struggling to see the plugin architecture since it is quite scattered throughout the library, is there documentation providing an overview?
Thus, the plugin implementer side including the role of the Plugin Descriptor and the plugin implementation support library (Plugin Programming Interface (PPI)) or a raw command implementation, as well as the plugin caller side including Plugin Adapter , the registrations (RegisterExtensions() / RegistrationHandler()) and the individual extension point specific plugin packages AND how all these parts fit together.

return NewDecisionHandler(Q_UPDATE_VERSION, desc, ForComponentReferenceQuestion(h))
}

func NewOUpdateVersionDecision(desc string, h ComponentReferenceQuestionFunc, labels ...string) DecisionHandler {
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
func NewOUpdateVersionDecision(desc string, h ComponentReferenceQuestionFunc, labels ...string) DecisionHandler {
func NewUpdateVersionDecision(desc string, h ComponentReferenceQuestionFunc, labels ...string) DecisionHandler {

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, duplicate function with typo in name. (removed)

return NewDecisionHandler(Q_ENFORCE_TRANSPORT, desc, ForComponentReferenceQuestion(h))
}

func NewTransferversionDecision(desc string, h ComponentReferenceQuestionFunc, labels ...string) DecisionHandler {
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
func NewTransferversionDecision(desc string, h ComponentReferenceQuestionFunc, labels ...string) DecisionHandler {
func NewTransferVersionDecision(desc string, h ComponentReferenceQuestionFunc, labels ...string) DecisionHandler {

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +19 to +22
type configOption struct {
config []byte
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it is confusing that the type configOption is not the type that's supposed to be implementing the interface ConfigOption.

Copy link
Contributor Author

@mandelsoft mandelsoft Dec 9, 2024

Choose a reason for hiding this comment

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

It is supposed as option (like the other structs). In this case an option to feed the ConfigOption interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to ConfigOptionConsumer and added more docu.

@hilmarf hilmarf added kind/epic Large multi-story topic kind/feature new feature, enhancement, improvement, extension component/ocm-cli OCM Command Line Interface component/ocm-core Open Component Model Core aka. go API labels Nov 28, 2024
@mandelsoft mandelsoft changed the title Extend plugin API to support transfer handlers feat: Extend plugin API to support transfer handlers Dec 9, 2024
@github-actions github-actions bot added the area/documentation Documentation related label Dec 9, 2024
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 component/ocm-cli OCM Command Line Interface component/ocm-core Open Component Model Core aka. go API kind/epic Large multi-story topic kind/feature new feature, enhancement, improvement, extension size/l Large
Projects
Status: 🔍 Review
Development

Successfully merging this pull request may close these issues.

3 participants