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

[datadog_dashboard_list] Migrate to tf framework #2038

Merged
merged 22 commits into from
Aug 4, 2023

Conversation

HantingZhang2
Copy link
Contributor

No description provided.

Copy link
Member

@skarimo skarimo left a comment

Choose a reason for hiding this comment

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

This looks great overall. However, we need to consider the issue #1979 . Previously, the sdk did not care about mismatch between state and config after a terraform action was performed but with this change, it will exit with Provider produced inconsistent result after apply.

I think the best approach here is to modify the updateState methods to always use whatever the user supplied. Something like:

func (r *dashboardListResource) updateStateFromResponse(ctx context.Context, state *dashboardListResourceModel, dashboards []datadogV2.DashboardListItemResponse) {
	temp := []*DashItemModel{}
	for _, dashboard := range dashboards {
		dashboardItem := DashItemModel{}
		dashboardItem.Dash_id = types.StringValue(dashboard.GetId())

		found := false
		for _, v := range state.DashItem {
			if v.Dash_id.ValueString() == dashboard.GetId() {
				dashboardItem.Type = v.Type
				found = true
			}
		}
		if !found {
			dashboardItem.Type = types.StringValue(string(dashboard.GetType()))
		}

		temp = append(temp, &dashboardItem)
	}
	state.DashItem = temp
}

datadog/fwprovider/resource_datadog_dashboard_list.go Outdated Show resolved Hide resolved
datadog/fwprovider/resource_datadog_dashboard_list.go Outdated Show resolved Hide resolved
Copy link
Member

@skarimo skarimo left a comment

Choose a reason for hiding this comment

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

Change to be applied after #2042

NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"type": schema.StringAttribute{
Description: "The type of this dashboard. Valid values are `custom_timeboard`, `custom_screenboard`, `integration_screenboard`, `integration_timeboard`, `host_timeboard`.",
Copy link
Member

@skarimo skarimo Aug 3, 2023

Choose a reason for hiding this comment

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

Suggested change
Description: "The type of this dashboard. Valid values are `custom_timeboard`, `custom_screenboard`, `integration_screenboard`, `integration_timeboard`, `host_timeboard`.",
Description: "The type of this dashboard.",

nkzou
nkzou previously approved these changes Aug 3, 2023
@HantingZhang2 HantingZhang2 merged commit c8bfa05 into master Aug 4, 2023
8 checks passed
@HantingZhang2 HantingZhang2 deleted the Migrate-to-tf-framework branch August 4, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants