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

[Internal] Migrate databricks_clusters data source to plugin framework #3998

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

tanmay-db
Copy link
Contributor

@tanmay-db tanmay-db commented Sep 5, 2024

WIP

Changes

Migrate databricks_clusters data source to plugin framework

Tests

Integration tests are passing.

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

@tanmay-db tanmay-db requested review from a team as code owners September 5, 2024 09:59
@tanmay-db tanmay-db requested review from mgyucht and removed request for a team and mgyucht September 5, 2024 09:59
@tanmay-db tanmay-db marked this pull request as draft September 5, 2024 10:00
Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

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

Initial comments

}

func (d *ClustersDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = "databricks_clusters_pluginframework"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto here

Comment on lines +63 to +65
if apierr.IsMissing(err) {
resp.State.RemoveResource(ctx)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this happen? Is it an error if there are no clusters? (Probably not.)

Comment on lines +74 to +77
if name_contains != "" && !match_name {
continue
}
ids = append(ids, types.StringValue(v.ClusterId))
Copy link
Contributor

Choose a reason for hiding this comment

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

strings.Contains(any string, "") should always be true.

Suggested change
if name_contains != "" && !match_name {
continue
}
ids = append(ids, types.StringValue(v.ClusterId))
if match_name {
ids = append(ids, types.StringValue(v.ClusterId))
}

}

ids := make([]types.String, 0, len(clusters))
name_contains := strings.ToLower(clustersInfo.ClusterNameContains.ValueString())
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use camelCase?

Copy link
Contributor

@edwardfeng-db edwardfeng-db left a comment

Choose a reason for hiding this comment

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

Maybe the work for setComputed could be in a separate pr?

type ClusterInfo struct {
ClusterId types.String `tfsdk:"cluster_id" tf:"optional,computed"`
Name types.String `tfsdk:"cluster_name" tf:"optional,computed"`
ClusterInfo *compute_tf.ClusterDetails `tfsdk:"cluster_info" tf:"optional,computed"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also try adding a proto level annotation for making a field computed in the tf configuration, so the generated tfsdk structs will have these

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.

3 participants