Skip to content
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 transforms #284

Merged
merged 27 commits into from
Mar 19, 2023
Merged

Conversation

Cristigeo
Copy link
Contributor

@Cristigeo Cristigeo commented Mar 7, 2023

This PR is intended to add support for transforms (https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html).

This is my first attempt to contribute to an open-source project; being new to this, I apologize in advance if I inadvertently break some rules/guidelines. Also, full disclaimer, Go is not my main programming language and I haven't done any previous coding for Terraform providers.

Feedback is welcome (obviously). While in its current state the code is functional (at least during the minimal tests I've performed), I'd like to point out a couple of design choices (in the current code) that may not be optimal:

  • most configuration is done through dedicated resources block, but the pivot and latest props are handled as raw json content;
  • the start/stop functionality is mapped through the enabled property. A different (better?) choice might have been a dedicated resource (such as elasticstack_elasticsearch_transform_state), because start/stop is a different API flow (not part of the usual CRUD).

Open points:

  • drift detection
  • support for import functionality
  • improved documentation / acceptance test
  • tests on different ES versions
  • cleanup

Resolves #49

@cla-checker-service
Copy link

cla-checker-service bot commented Mar 7, 2023

💚 CLA has been signed

@tobio
Copy link
Member

tobio commented Mar 8, 2023

the start/stop functionality is mapped through the enabled property. A different (better?) choice might have been a dedicated resource (such as elasticstack_elasticsearch_transform_state), because start/stop is a different API flow (not part of the usual CRUD).

Both approaches will work, and there doesn't seem to be an idiomatic approach here (some providers have a property on the resource, some have a separate resource). If you're happy with the property then we can start with that.

Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Some comments inline.

docs/resources/elasticsearch_transform.md Outdated Show resolved Hide resolved
internal/clients/elasticsearch/index.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/clients/elasticsearch/index.go Outdated Show resolved Hide resolved
internal/clients/elasticsearch/index.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/utils/validation.go Show resolved Hide resolved
internal/utils/validation.go Outdated Show resolved Hide resolved
@tobio
Copy link
Member

tobio commented Mar 9, 2023

Also can we add a changelog entry here in this PR

@Cristigeo
Copy link
Contributor Author

@tobio , thank you for the feedback, really appreciated. As you can tell, I'm still learning Go :) . I made a couple of pushes to fix most (if not all) of the issues. Not really sure about the "Resolve conversation" policy (who should be pushing those buttons), so I left that untouched.

@tobio
Copy link
Member

tobio commented Mar 9, 2023

Not really sure about the "Resolve conversation" policy

It's totally ok for you to hit those buttons. Personally I find that easier since it's clear that you've made changes to address that.

@Cristigeo Cristigeo changed the title WIP: Support for transforms Support for transforms Mar 14, 2023
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform.go Outdated Show resolved Hide resolved
internal/elasticsearch/transform/transform_test.go Outdated Show resolved Hide resolved
Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! There's a lot of code in this contribution, thanks for taking the time to improve the provider :)

@tobio tobio merged commit b134508 into elastic:main Mar 19, 2023
@Cristigeo Cristigeo deleted the 49-support-for-transforms branch March 26, 2023 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Support for Transforms
2 participants