-
Notifications
You must be signed in to change notification settings - Fork 22
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
Support for CLI Extensions by OCM Plugins #815
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mandelsoft
force-pushed
the
command
branch
2 times, most recently
from
June 17, 2024 16:24
0cb4933
to
6bc33eb
Compare
mandelsoft
force-pushed
the
command
branch
3 times, most recently
from
June 19, 2024 14:10
0271ad3
to
5da689e
Compare
mandelsoft
force-pushed
the
command
branch
2 times, most recently
from
June 24, 2024 10:01
5158927
to
144b3cb
Compare
hilmarf
reviewed
Jun 24, 2024
hilmarf
reviewed
Jun 24, 2024
hilmarf
previously approved these changes
Jun 25, 2024
- verb creation - additional topic help template - capability summay in get plugins
Co-authored-by: Hilmar Falkenberg <[email protected]>
Just rebased and fixed the linter issues |
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
The OCM Plugin framework now supports two new features:
Additionally it is possible to consume logging configuration from the OCM CLI for all
plugin feature commands.
Examples see coding in
cmds/cliplugin
Config Types
Config types are just registered at the Plugin Object;
The argument is just the config type as registered at the ocm library, for example:
CLI Commands
CLI commands are simple configured
cobra.Command
objects.They are registered at the plugin object with
with coding similar to
The plugin programming interface supports the generation of an extension command directly from a
cobra command object using the method
NewCLICommand
from theppi.clicmd
package.Otherwise the
ppi.Command
interface can be implemented without requiring a cobra command..If the code wants to use the config framework, for example to
the appropriate command feature must be set.
For the cobra support this is implemented by the option
WithCLIConfig
.If set to true, the OCM CLI configuration is available for the config context used in the
CLI code.
The command can be a top-level command or attached to a dedicated verb (and optionally a realm like
ocm
oroci
).For the cobra support this can be requested by the option
WithVerb(...)
.If the config framework is used just add the following anonymoud import
for an automated configuration:
The plugin code is then configured with the configuration of the OCM CLI and the config framework
can be used.
If the configuration should be handled by explicit plugin code a handler can be registered with
It gets a config yaml according to the config objects used by the OCM library.
Logging
To get the logging configuration from the OCM CLI the plugin has be configured with
If the standard mandelsoft logging from the OCM library is used the configuration can
be implemented directly with an anonymous import of
The plugin code is then configured with the logging configuration of the OCM CLI and the mandelsoft logging frame work
can be used.
If the logging configuration should be handled by explicit plugin code a handler can be registered with
It gets a logging configuration yaml according to the logging config used by the OCM library (
github.com/mandelsoft/logging/config
).Using Plugin command extensions from the OCM library.
The plugin command extensions can also be called without the OCM CLI directly from the OCM library.
Therefore the plugin objects provided by the library can be used.
Logging information and config information must explicitly be configured to be passed to the
plugin.
Therefore the context attribute
clicfgattr.Get(ctx)
is used. It can be set viaclicfgattr.Set(...)
.The logging configuration is extracted from the configured configuration object with target type
*logging.LoggingConfiguration
.If the code uses an OCM context configured with a
(ocm)utils.ConfigureXXX
function, the cli config attribute is set accordingly.Which issue(s) this PR fixes: