-
Notifications
You must be signed in to change notification settings - Fork 105
add resource for datastream lifecycle #852
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
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.
Thanks for taking the time to add this in.
Is it possible to have this resource built on the Plugin Framework instead? There's a strong preference here for new code to utilise that framework over the old SDK v2 and we're not re-using any existing SDK code here. This commit is an example of converting to the plugin framework if that helps.
It looks like lint is failing because the generated docs don't match what's committed, which can be fixed by committing the result of make docs-generate
// generate renadom name | ||
dsName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlpha) | ||
|
||
resource.Test(t, resource.TestCase{ |
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.
We'll want to skip these when the backing cluster doesn't support DS lifecycles (example)
) | ||
|
||
func TestAccResourceDataStreamLifecycle(t *testing.T) { | ||
// generate renadom name |
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.
// generate renadom name | |
// generate random name |
|
||
{{ tffile "examples/resources/elasticstack_elasticsearch_data_stream_lifecycle/resource.tf" }} | ||
|
||
{{ .SchemaMarkdown | trimspace }} |
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.
Can we include an import example here as well
}, | ||
}, | ||
}, | ||
"lifecycles": { |
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's not clear what value we get with this block.
Since we're not writing these values back to the top level attributes TF drift detection won't pickup out of band changes. Choosing which value to use when the response includes multiple lifecycles is a challenge, but something we should solve IMO (a simple heuristic would be to use any value which differed from the configured value so drift detection worked, and if no diff was found just use the first).
In reality, I suspect most users will likely target a single data stream.
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.
Originally I had it so that I only detected the value that changed, then I thought it would be nice to have everything in state, but I didn't know that TF couldn't work with it that way.
I will change it back :)
ok, not a problem. |
20c1f15
to
fe15c35
Compare
updated |
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.
Thanks for adding this resource, it's really useful!
One small comment on de-duplicating the Create
/Update
implementations but otherwise LGTM.
"github.com./hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { |
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.
This looks identical to the Create
method. Can we pull this out to a common write
(or some other name if you prefer) method and re-use it in both Create
and Update
?
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.
OK, I did the same as here:
internal/fleet/integration/create.go
internal/fleet/integration/update.go
fe15c35
to
32987b8
Compare
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.
Love it, thanks again for taking the time to get this one added, and for working through the review changes.
* add resource for datastream lifecycle * Just return diags --------- Co-authored-by: Toby Brain <[email protected]>
resolves #838