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

chore(plugin): migrate kafka #1402

Closed
wants to merge 1 commit into from
Closed

Conversation

byashimov
Copy link
Contributor

No description provided.

Copy link
Contributor

@Serpentiel Serpentiel left a comment

Choose a reason for hiding this comment

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

check the review comments, also add comments for each exported method to explain what it does

// https://github.com/hashicorp/terraform-plugin-framework/issues/242
// We can't share the same functions for resource and datasource by default.
// To do so, we design all functions for resource and copy it to datasource.
func Copy(from, dest any) func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: prefer specific types over any if possible; if not, document why any is necessary

}

dest := &bar{}
copyBack := Copy(from, dest)
Copy link
Contributor

Choose a reason for hiding this comment

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

add assert or require to ensure copyBack is not nil

}
}

func MergeSchemas(a, b schema.Schema) schema.Schema {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider making a copy of a before modifying it to avoid side effects

// Copies state from datasource to resource, then back, when things are done
func (s *kafkaDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
// fixme: replace with datasource
//s.crud.Read(ctx, req, resp, new(kafkaModel))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: implement the commented out code or remove the comment if it's not needed

s.crud.Read(ctx, req, resp, o)
}

// Update todo
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove todo comment or add more context if there is something specific that needs to be done

Computed: true,
},
"ssl": schema.BoolAttribute{
Description: "Whether the endpoint is encrypted or accepts plaintext. By default endpoints are " +
Copy link
Contributor

Choose a reason for hiding this comment

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

rephrase "service components they may disable encryption", maybe something like "service components that might have encryption disabled"

Description: "Name of the source service",
Required: true,
},
"integration_type": schema.StringAttribute{
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth validating the value of integration_type if it only supports read_replica for now, consider adding a validation function

)

// flattenUserConfig from aiven to terraform
func flattenUserConfig(ctx context.Context, diags diag.Diagnostics, r *Resource, dto *aiven.Service) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider adding a comment to describe what the function does

}

// expandUserConfig from terraform to aiven
func expandUserConfig(ctx context.Context, diags diag.Diagnostics, o *Resource, create bool) map[string]any {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider adding a comment to describe what the function does

config = clickhouse.Expand(ctx, diags, o.ClickhouseUserConfig)
}

if diags.HasError() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: check error at the start of the function to return early (add a second check, and keep this one); this will reduce unnecessary processing

@Serpentiel Serpentiel added enhancement New feature or request no changelog No changelog entries are required for this PR labels Oct 23, 2023
@byashimov byashimov closed this Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request no changelog No changelog entries are required for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants