-
Notifications
You must be signed in to change notification settings - Fork 101
action: Implement planning and invoking of actions #1185
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
Conversation
// SendProgress will immediately send a progress update to Terraform core during action invocation. | ||
// This function is provided by the framework and can be called multiple times while action logic is running. | ||
// | ||
// TODO:Actions: More documentation about when you should use this / when you shouldn't | ||
SendProgress func(event InvokeProgressEvent) |
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.
It didn't feel beneficial to expose much more than this function to provider developers. Open to discussion on any other ideas for improving this UX
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.
I think this design makes sense, we only need to expose progress events for now and if we want to expose other types, we can incrementally add callback functions for those types later. I doubt that we will need to expose every event type.
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.
LGTM!
// SendProgress will immediately send a progress update to Terraform core during action invocation. | ||
// This function is provided by the framework and can be called multiple times while action logic is running. | ||
// | ||
// TODO:Actions: More documentation about when you should use this / when you shouldn't | ||
SendProgress func(event InvokeProgressEvent) |
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.
I think this design makes sense, we only need to expose progress events for now and if we want to expose other types, we can incrementally add callback functions for those types later. I doubt that we will need to expose every event type.
Related Issue
N/A
Description
This PR introduces the implementation of the
PlanAction
andInvokeAction
RPCs. Currently planning actions has one hookModifyPlan
(the same asModifyPlan
in managed resources, so I named it as such), and invoking has one hookInvoke
(which always ends with a completed event)The actual streaming mechanism of the protocol is hidden here since the provider always needs to respond with a single completed event, with multiple (optional) progress events in-between. To keep the interface of
Invoke
simple, we are just providing a function (InvokeResponse.SendProgress
) for providers to call whenever they want to stream a progress event back to Terraform. Once the invoke method has finished, and the provider has set the proper data on the response, then framework automatically sends the completed event and returns.Rollback Plan
Changes to Security Controls
No