From ebe256be891d68f9764652db854cbceb6d87f1c1 Mon Sep 17 00:00:00 2001 From: Michael Yocca Date: Sun, 28 Jan 2024 17:56:48 -0800 Subject: [PATCH] refactor: instrument HasChange and GetChange --- internal/provider/resource_tfe_organization.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/internal/provider/resource_tfe_organization.go b/internal/provider/resource_tfe_organization.go index 08f5bb88f..0a8ce3738 100644 --- a/internal/provider/resource_tfe_organization.go +++ b/internal/provider/resource_tfe_organization.go @@ -199,22 +199,16 @@ func resourceTFEOrganizationUpdate(d *schema.ResourceData, meta interface{}) err options.CostEstimationEnabled = tfe.Bool(costEstimationEnabled.(bool)) } + // If send_passing_statuses_for_untriggered_speculative_plans is supplied, set it using the options struct. if d.HasChange("send_passing_statuses_for_untriggered_speculative_plans") { - // If send_passing_statuses_for_untriggered_speculative_plans is supplied, set it using the options struct. - if sendPassingStatusesForUntriggeredSpeculativePlans, ok := d.GetOk("send_passing_statuses_for_untriggered_speculative_plans"); ok { - options.SendPassingStatusesForUntriggeredSpeculativePlans = tfe.Bool(sendPassingStatusesForUntriggeredSpeculativePlans.(bool)) - } else { - options.SendPassingStatusesForUntriggeredSpeculativePlans = tfe.Bool(false) - } + _, newVal := d.GetChange("send_passing_statuses_for_untriggered_speculative_plans") + options.SendPassingStatusesForUntriggeredSpeculativePlans = tfe.Bool(newVal.(bool)) } + // If aggregated_commit_status_enabled is supplied, set it using the options struct. if d.HasChange("aggregated_commit_status_enabled") { - // If aggregated_commit_status_enabled is supplied, set it using the options struct. - if aggregatedCommitStatusEnabled, ok := d.GetOk("aggregated_commit_status_enabled"); ok { - options.AggregatedCommitStatusEnabled = tfe.Bool(aggregatedCommitStatusEnabled.(bool)) - } else { - options.AggregatedCommitStatusEnabled = tfe.Bool(false) - } + _, newVal := d.GetChange("aggregated_commit_status_enabled") + options.AggregatedCommitStatusEnabled = tfe.Bool(newVal.(bool)) } // If assessments_enforced is supplied, set it using the options struct.