|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +package action |
| 5 | + |
| 6 | +import ( |
| 7 | + "github.com/hashicorp/terraform-plugin-framework/diag" |
| 8 | + "github.com/hashicorp/terraform-plugin-framework/tfsdk" |
| 9 | +) |
| 10 | + |
| 11 | +// ModifyPlanClientCapabilities allows Terraform to publish information |
| 12 | +// regarding optionally supported protocol features for the PlanAction RPC, |
| 13 | +// such as forward-compatible Terraform behavior changes. |
| 14 | +type ModifyPlanClientCapabilities struct { |
| 15 | + // DeferralAllowed indicates whether the Terraform client initiating |
| 16 | + // the request allows a deferral response. |
| 17 | + // |
| 18 | + // NOTE: This functionality is related to deferred action support, which is currently experimental and is subject |
| 19 | + // to change or break without warning. It is not protected by version compatibility guarantees. |
| 20 | + DeferralAllowed bool |
| 21 | +} |
| 22 | + |
| 23 | +// ModifyPlanRequest represents a request for the provider to modify the |
| 24 | +// planned new state that Terraform has generated for any linked resources. |
| 25 | +type ModifyPlanRequest struct { |
| 26 | + // Config is the configuration the user supplied for the action. |
| 27 | + // |
| 28 | + // This configuration may contain unknown values if a user uses |
| 29 | + // interpolation or other functionality that would prevent Terraform |
| 30 | + // from knowing the value at request time. |
| 31 | + Config tfsdk.Config |
| 32 | + |
| 33 | + // TODO:Actions: Add linked resources once lifecycle/linked actions are implemented |
| 34 | + |
| 35 | + // ClientCapabilities defines optionally supported protocol features for the |
| 36 | + // PlanAction RPC, such as forward-compatible Terraform behavior changes. |
| 37 | + ClientCapabilities ModifyPlanClientCapabilities |
| 38 | +} |
| 39 | + |
| 40 | +// ModifyPlanResponse represents a response to a |
| 41 | +// ModifyPlanRequest. An instance of this response struct is supplied |
| 42 | +// as an argument to the action's ModifyPlan function, in which the provider |
| 43 | +// should modify the Plan of any linked resources as appropriate. |
| 44 | +type ModifyPlanResponse struct { |
| 45 | + // Diagnostics report errors or warnings related to determining the |
| 46 | + // planned state of the requested action's linked resources. Returning an empty slice |
| 47 | + // indicates a successful plan modification with no warnings or errors |
| 48 | + // generated. |
| 49 | + Diagnostics diag.Diagnostics |
| 50 | + |
| 51 | + // TODO:Actions: Add linked resources once lifecycle/linked actions are implemented |
| 52 | + |
| 53 | + // Deferred indicates that Terraform should defer planning this |
| 54 | + // action until a follow-up apply operation. |
| 55 | + // |
| 56 | + // This field can only be set if |
| 57 | + // `(action.ModifyPlanRequest).ClientCapabilities.DeferralAllowed` is true. |
| 58 | + // |
| 59 | + // NOTE: This functionality is related to deferred action support, which is currently experimental and is subject |
| 60 | + // to change or break without warning. It is not protected by version compatibility guarantees. |
| 61 | + Deferred *Deferred |
| 62 | +} |
0 commit comments