-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix: change streams
to be a SetNestedAttribute
#128
fix: change streams
to be a SetNestedAttribute
#128
Conversation
This commit modifies the connection resource's `streams` attribute to be a `SetNestedAttribute` instead of a List. This is so that we can properly compute plan's that treat re-ordering of elements (streams) as a noop (if no attributes of the stream have been changed). Previously if you added a new stream to a connection resource in the middle of the list, or changed the order, the provider would compute that as a change that had to be applied. Additionally, we use a customer SetPlanModifier that may be parameterized with a `key` which is used to uniquely identify the elements in the set. NOTE: the current implementation of the plan modifier `uniqueByKey` assumes that the elements of the set are Objects. Since this is the only use case for this modifier, this seems reasonable for now.
@@ -0,0 +1,2 @@ | |||
internal/provider/connection_resource.go |
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.
Since these files have been manually modified, we need to exclude them from generation.
NestedObject: schema.NestedAttributeObject{ | ||
Attributes: map[string]schema.Attribute{ | ||
"cursor_field": schema.ListAttribute{ | ||
Computed: true, | ||
PlanModifiers: []planmodifier.List{ |
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'm not entirely certain that we need to remove these plan modifiers, so I defer to someone with more background to correct me here if this is not the right approach
There are some SpeakEasy SDK/Provider generation configurations that need to be in place so that when the code gets generated it doesn't clobber the changes (see: |
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.
Tested and works well for me! I've run this through the set of tests with reordering streams that I tried when it was just a SetNestedAttribute and everything looks good; infrastructure gets to a stable state.
This commit modifies the connection resource's
streams
attribute to be aSetNestedAttribute
instead of a List. This is so that we can properly compute plan's that treat re-ordering of elements (streams) as a noop (if no attributes of the stream have been changed).Previously if you added a new stream to a connection resource in the middle of the list, or changed the order, the provider would compute that as a change that had to be applied.
Additionally, we use a customer SetPlanModifier that may be parameterized with a
key
which is used to uniquely identify the elements in the set.NOTE: the current implementation of the plan modifier
uniqueByKey
assumes that the elements of the set are Objects. Since this is the only use case for this modifier, this seems reasonable for now.Testing
If you would like to verify these changes yourself, and do not have access to our SpeakEasy account, you can checkout this branch and run the provider locally in debug mode.
NOTE: This will output instructions for exporting a
TF_REATTACH_PROVIDERS
env var that you must set when invoking terraform so that it uses the local instance of the provider.