-
Notifications
You must be signed in to change notification settings - Fork 70
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
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.
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() { |
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.
nit: prefer specific types over any
if possible; if not, document why any
is necessary
} | ||
|
||
dest := &bar{} | ||
copyBack := Copy(from, dest) |
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.
add assert or require to ensure copyBack
is not nil
} | ||
} | ||
|
||
func MergeSchemas(a, b schema.Schema) schema.Schema { |
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.
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)) |
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.
nit: implement the commented out code or remove the comment if it's not needed
s.crud.Read(ctx, req, resp, o) | ||
} | ||
|
||
// Update todo |
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.
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 " + |
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.
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{ |
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.
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) { |
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.
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 { |
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.
nit: consider adding a comment to describe what the function does
config = clickhouse.Expand(ctx, diags, o.ClickhouseUserConfig) | ||
} | ||
|
||
if diags.HasError() { |
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.
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
No description provided.