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

Make CustomizableSchema work for Plugin Framework #3819

Merged

Conversation

edwardfeng-db
Copy link
Contributor

@edwardfeng-db edwardfeng-db commented Jul 25, 2024

Changes

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

@edwardfeng-db edwardfeng-db requested review from a team as code owners July 25, 2024 08:23
@edwardfeng-db edwardfeng-db requested review from mgyucht and tanmay-db and removed request for a team July 25, 2024 08:23
Copy link
Contributor

@tanmay-db tanmay-db left a comment

Choose a reason for hiding this comment

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

I think if it's possible to use a common interface, then we can remove lots of redundancy since we are doing the same operation for each attribute type in SetOptional, SetRequired, SetSensitive and SetDeprecated.

func (s *CustomizableSchemaPluginFramework) SetRequired(path ...string) *CustomizableSchemaPluginFramework {
cb := func(a schema.Attribute) schema.Attribute {
switch attr := a.(type) {
case schema.SingleNestedAttribute:
Copy link
Contributor

Choose a reason for hiding this comment

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

since all types perform the same operation, it might be good if we can club them together using a common interface

}

func (s *CustomizableSchemaPluginFramework) SetSensitive(path ...string) *CustomizableSchemaPluginFramework {
cb := func(a schema.Attribute) schema.Attribute {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here


// Helper function for navigating through schema attributes, panics if path does not exist or invalid.
func navigateSchema(s *schema.Attribute, path ...string) (schema.Attribute, error) {
cs := s
Copy link
Contributor

Choose a reason for hiding this comment

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

using descriptive variable naming might be helpful in code readability.

@edwardfeng-db edwardfeng-db merged commit 1562784 into terraform-plugin-framework Jul 27, 2024
3 of 4 checks passed
@edwardfeng-db edwardfeng-db deleted the edwardfeng-db/customizable-schema branch July 27, 2024 17:21
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.

2 participants