-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: Add automatic deferred action support for unknown provider confi…
…guration (#1335) * update plugin-go * quick implementation of automatic deferral (no opt-in currently) * add opt-in logic with ResourceBehavior * update naming on exported structs/fields * add data source tests * add readresource tests * refactor planresourcechange tests * remove configure from tests * add new PlanResourceChange RPC tests * update import logic + add tests for ImportResourceState * update sdkv2 to match new protocol changes + pass deferral allowed to configureprovider * update terraform-plugin-go * update plugin-go * name changes + doc updates + remove duplicate diags * add logging * error message update * pkg doc updates * add changelogs * add copywrite header * go mod tidy :) * replace TODO comment on import * replace if check for deferralAllowed * replace logging key with a constant * use the proper error returning method for test assertions * add experimental verbiage * DeferredResponse -> Deferred
- Loading branch information
1 parent
b76c8ef
commit 02c429c
Showing
9 changed files
with
2,452 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'helper/schema: Added `(Provider).ConfigureProvider` function for configuring | ||
providers that support additional features, such as deferred actions.' | ||
time: 2024-05-06T15:20:18.393505-04:00 | ||
custom: | ||
Issue: "1335" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'helper/schema: Added `(Resource).ResourceBehavior` to allow additional control | ||
over deferred action behavior during plan modification.' | ||
time: 2024-05-06T15:21:35.304825-04:00 | ||
custom: | ||
Issue: "1335" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: NOTES | ||
body: This release contains support for deferred actions, which is an experimental | ||
feature only available in prerelease builds of Terraform 1.9 and later. This functionality | ||
is subject to change and is not protected by version compatibility guarantees. | ||
time: 2024-05-09T13:49:45.38523-04:00 | ||
custom: | ||
Issue: "1335" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package schema | ||
|
||
// MAINTAINER NOTE: Only PROVIDER_CONFIG_UNKNOWN (enum value 2 in the plugin-protocol) is relevant | ||
// for SDKv2. Since (Deferred).Reason is mapped directly to the plugin-protocol, | ||
// the other enum values are intentionally omitted here. | ||
const ( | ||
// DeferredReasonUnknown is used to indicate an invalid `DeferredReason`. | ||
// Provider developers should not use it. | ||
DeferredReasonUnknown DeferredReason = 0 | ||
|
||
// DeferredReasonProviderConfigUnknown represents a deferred reason caused | ||
// by unknown provider configuration. | ||
DeferredReasonProviderConfigUnknown DeferredReason = 2 | ||
) | ||
|
||
// Deferred is used to indicate to Terraform that a resource or data source is not able | ||
// to be applied yet and should be skipped (deferred). After completing an apply that has deferred actions, | ||
// the practitioner can then execute additional plan and apply “rounds” to eventually reach convergence | ||
// where there are no remaining deferred actions. | ||
// | ||
// NOTE: This functionality is related to deferred action support, which is currently experimental and is subject | ||
// to change or break without warning. It is not protected by version compatibility guarantees. | ||
type Deferred struct { | ||
// Reason represents the deferred reason. | ||
Reason DeferredReason | ||
} | ||
|
||
// DeferredReason represents different reasons for deferring a change. | ||
// | ||
// NOTE: This functionality is related to deferred action support, which is currently experimental and is subject | ||
// to change or break without warning. It is not protected by version compatibility guarantees. | ||
type DeferredReason int32 | ||
|
||
func (d DeferredReason) String() string { | ||
switch d { | ||
case 0: | ||
return "Unknown" | ||
case 2: | ||
return "Provider Config Unknown" | ||
} | ||
return "Unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.