-
Notifications
You must be signed in to change notification settings - Fork 14
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
refactor plugin interface to take PluginRequest rather than obj and args #76
Conversation
e903012
to
679eecc
Compare
Going to follow this as I may need to make changes based on this |
@cooktheryan This is to deal with the issue around needing to explicitly send ctrl-D when invoking a plugin without args. This PR replaces the expectation of two separate stdin transmissions of an unstructured obj and (optionally) an extras map with a single PluginRequest, which is a struct with an (anonymous/inline) unstructured obj and an extras map. In the "no extras provided" case, this restores the original behavior where piping a single kubernetes resource object json to the plugin will execute without needing ctrl-D, but when you do need args, the "extras" field is added as another top level entry to the unstructured map. |
@cooktheryan Once this merges, the changes you'll need to make will be minimal. The Run func will take a struct containing the unstructured obj and extras map rather than two different args. See transform/binary-plugin/examples/route/route.go for an example of a plugin that needs the unstructured obj from the new method arg and transform/binary-plugin/examples/test/annotation/annotation.go for an example of a plugin that uses the extras field. |
Return value of Run is unchanged. |
Do we need to consider making a release before we do this for gi tops primer to pin to? @jmontleon as you are helping get that settled do you have thoughts? |
@shawn-hurley A release might make sense since we're changing APIs here. If anyone is using main builds, then having a tag before this is merged could be helpful. |
as @alaypatel07 pointed out, this PR needs to update the plugin README as well. |
fixes #49 |
Updated binary-plugin/README.md and rebased to pull in recent main commits. |
Refactor plugin interface to take PluginRequest rather than separate obj and args. This allows for sending raw object json to a binary plugin for testing without an expected separate line of entry for optional args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VISACK
/lgtm
@@ -73,16 +73,16 @@ func Run(u *unstructured.Unstructured, extras map[string]string) (transform.Plug | |||
whiteOut = true | |||
case "BuildConfig": | |||
logger.Info("found build config, processing") | |||
patch, err = UpdateBuildConfig(*u, inputFields) | |||
patch, err = UpdateBuildConfig(u, inputFields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on removal of sending patches
Refactor plugin interface to take PluginRequest rather than separate obj and args.
This allows for sending raw object json to a binary plugin for testing without
an expected separate line of entry for optional args.