-
Notifications
You must be signed in to change notification settings - Fork 91
/
string.go
88 lines (70 loc) · 3.12 KB
/
string.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package planmodifier
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/internal/privatestate"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// String is a schema plan modifier for types.String attributes.
type String interface {
Describer
// PlanModifyString should perform the modification.
PlanModifyString(context.Context, StringRequest, *StringResponse)
}
// StringRequest is a request for types.String schema plan modification.
type StringRequest struct {
// Path contains the path of the attribute for modification. Use this path
// for any response diagnostics.
Path path.Path
// PathExpression contains the expression matching the exact path
// of the attribute for modification.
PathExpression path.Expression
// Config contains the entire configuration of the resource.
Config tfsdk.Config
// ConfigValue contains the value of the attribute for modification from the configuration.
ConfigValue types.String
// Plan contains the entire proposed new state of the resource.
Plan tfsdk.Plan
// PlanValue contains the value of the attribute for modification from the proposed new state.
PlanValue types.String
// State contains the entire prior state of the resource.
State tfsdk.State
// StateValue contains the value of the attribute for modification from the prior state.
StateValue types.String
// Private is provider-defined resource private state data which was previously
// stored with the resource state. This data is opaque to Terraform and does
// not affect plan output. Any existing data is copied to
// StringResponse.Private to prevent accidental private state data loss.
//
// The private state data is always the original data when the schema-based plan
// modification began or, is updated as the logic traverses deeper into underlying
// attributes.
//
// Use the GetKey method to read data. Use the SetKey method on
// StringResponse.Private to update or remove a value.
Private *privatestate.ProviderData
}
// StringResponse is a response to a StringRequest.
type StringResponse struct {
// PlanValue is the planned new state for the attribute.
PlanValue types.String
// RequiresReplace indicates whether a change in the attribute
// requires replacement of the whole resource.
RequiresReplace bool
// Private is the private state resource data following the PlanModifyString operation.
// This field is pre-populated from StringRequest.Private and
// can be modified during the resource's PlanModifyString operation.
//
// The private state data is always the original data when the schema-based plan
// modification began or, is updated as the logic traverses deeper into underlying
// attributes.
Private *privatestate.ProviderData
// Diagnostics report errors or warnings related to modifying the resource
// plan. An empty slice indicates success, with no warnings or
// errors generated.
Diagnostics diag.Diagnostics
}