Skip to content

Commit 70b2bc6

Browse files
committed
Remove other action schema types and references to linked resources
1 parent 2607d45 commit 70b2bc6

39 files changed

+319
-403
lines changed

action/invoke.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,27 @@ import (
88
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
99
)
1010

11-
// InvokeRequest represents a request for the provider to invoke the action and update
12-
// the requested action's linked resources.
11+
// InvokeRequest represents a request for the provider to invoke the action.
1312
type InvokeRequest struct {
1413
// Config is the configuration the user supplied for the action.
1514
Config tfsdk.Config
16-
17-
// TODO:Actions: Add linked resources when new action schema types are introduced
1815
}
1916

2017
// InvokeResponse represents a response to an InvokeRequest. An
2118
// instance of this response struct is supplied as
2219
// an argument to the action's Invoke function, in which the provider
2320
// should set values on the InvokeResponse as appropriate.
2421
type InvokeResponse struct {
25-
// Diagnostics report errors or warnings related to invoking the action or updating
26-
// the state of the requested action's linked resources. Returning an empty slice
22+
// Diagnostics report errors or warnings related to invoking the action. Returning an empty slice
2723
// indicates a successful invocation with no warnings or errors
2824
// generated.
2925
Diagnostics diag.Diagnostics
3026

3127
// SendProgress will immediately send a progress update to Terraform core during action invocation.
32-
// This function is pre-populated by the framework and can be called multiple times while action logic is running.
28+
// This function is provided by the framework and can be called multiple times while action logic is running.
29+
//
30+
// TODO:Actions: More documentation about when you should use this / when you shouldn't
3331
SendProgress func(event InvokeProgressEvent)
34-
35-
// TODO:Actions: Add linked resources when new action schema types are introduced
3632
}
3733

3834
// InvokeProgressEvent is the event returned to Terraform while an action is being invoked.

action/modify_plan.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ type ModifyPlanClientCapabilities struct {
2020
DeferralAllowed bool
2121
}
2222

23-
// ModifyPlanRequest represents a request for the provider to modify the
24-
// planned new state that Terraform has generated for any linked resources.
23+
// ModifyPlanRequest represents a request for the provider during planning.
24+
// The plan can be used as an opportunity to raise early
25+
// diagnostics to practitioners, such as validation errors.
2526
type ModifyPlanRequest struct {
2627
// Config is the configuration the user supplied for the action.
2728
//
@@ -30,26 +31,20 @@ type ModifyPlanRequest struct {
3031
// from knowing the value at request time.
3132
Config tfsdk.Config
3233

33-
// TODO:Actions: Add linked resources when new action schema types are introduced
34-
3534
// ClientCapabilities defines optionally supported protocol features for the
3635
// PlanAction RPC, such as forward-compatible Terraform behavior changes.
3736
ClientCapabilities ModifyPlanClientCapabilities
3837
}
3938

4039
// ModifyPlanResponse represents a response to a
4140
// 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.
41+
// as an argument to the action's ModifyPlan function.
4442
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.
43+
// Diagnostics report early errors or warnings related action.
44+
// Returning an empty slice indicates a successful plan modification
45+
// with no warnings or errors generated.
4946
Diagnostics diag.Diagnostics
5047

51-
// TODO:Actions: Add linked resources when new action schema types are introduced
52-
5348
// Deferred indicates that Terraform should defer planning this
5449
// action until a follow-up apply operation.
5550
//

action/schema.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ type SchemaRequest struct{}
1919
type SchemaResponse struct {
2020

2121
// Schema is the schema of the action.
22-
//
23-
// There is currently only one type of action, which defines how a practitioner can trigger an action,
24-
// as well as what effect the action can have on the state.
25-
// - [schema.UnlinkedSchema] actions are actions that cannot cause changes to resource states.
26-
Schema schema.SchemaType
22+
Schema schema.Schema
2723

2824
// Diagnostics report errors or warnings related to retrieving the action schema.
2925
// An empty slice indicates success, with no warnings or errors generated.

action/schema/doc.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
// Package schema contains all available schema functionality for actions.
55
// Action schemas define the structure and value types for configuration data.
66
// Schemas are implemented via the action.Action type Schema method.
7-
//
8-
// There is currently one type of action schema, which defines how a practitioner can trigger an action,
9-
// as well as what effect the action can have on the state.
10-
// - [UnlinkedSchema] actions are actions that cannot cause changes to resource states.
117
package schema

action/schema/unlinked_schema.go renamed to action/schema/schema.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ package schema
66
import (
77
"context"
88

9+
"github.com/hashicorp/terraform-plugin-go/tftypes"
10+
911
"github.com/hashicorp/terraform-plugin-framework/attr"
1012
"github.com/hashicorp/terraform-plugin-framework/diag"
1113
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1214
"github.com/hashicorp/terraform-plugin-framework/path"
13-
"github.com/hashicorp/terraform-plugin-go/tftypes"
1415
)
1516

16-
var _ SchemaType = UnlinkedSchema{}
17+
var _ fwschema.Schema = Schema{}
1718

18-
// UnlinkedSchema defines the structure and value types of an unlinked action. An unlinked action
19+
// Schema defines the structure and value types of an action. An action currently
1920
// cannot cause changes to resource state.
20-
type UnlinkedSchema struct {
21+
type Schema struct {
2122
// Attributes is the mapping of underlying attribute names to attribute
2223
// definitions.
2324
//
@@ -58,78 +59,76 @@ type UnlinkedSchema struct {
5859
DeprecationMessage string
5960
}
6061

61-
func (s UnlinkedSchema) isActionSchemaType() {}
62-
6362
// ApplyTerraform5AttributePathStep applies the given AttributePathStep to the
6463
// schema.
65-
func (s UnlinkedSchema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (any, error) {
64+
func (s Schema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (any, error) {
6665
return fwschema.SchemaApplyTerraform5AttributePathStep(s, step)
6766
}
6867

6968
// AttributeAtPath returns the Attribute at the passed path. If the path points
7069
// to an element or attribute of a complex type, rather than to an Attribute,
7170
// it will return an ErrPathInsideAtomicAttribute error.
72-
func (s UnlinkedSchema) AttributeAtPath(ctx context.Context, p path.Path) (fwschema.Attribute, diag.Diagnostics) {
71+
func (s Schema) AttributeAtPath(ctx context.Context, p path.Path) (fwschema.Attribute, diag.Diagnostics) {
7372
return fwschema.SchemaAttributeAtPath(ctx, s, p)
7473
}
7574

7675
// AttributeAtPath returns the Attribute at the passed path. If the path points
7776
// to an element or attribute of a complex type, rather than to an Attribute,
7877
// it will return an ErrPathInsideAtomicAttribute error.
79-
func (s UnlinkedSchema) AttributeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (fwschema.Attribute, error) {
78+
func (s Schema) AttributeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (fwschema.Attribute, error) {
8079
return fwschema.SchemaAttributeAtTerraformPath(ctx, s, p)
8180
}
8281

8382
// GetAttributes returns the Attributes field value.
84-
func (s UnlinkedSchema) GetAttributes() map[string]fwschema.Attribute {
83+
func (s Schema) GetAttributes() map[string]fwschema.Attribute {
8584
return schemaAttributes(s.Attributes)
8685
}
8786

8887
// GetBlocks returns the Blocks field value.
89-
func (s UnlinkedSchema) GetBlocks() map[string]fwschema.Block {
88+
func (s Schema) GetBlocks() map[string]fwschema.Block {
9089
return schemaBlocks(s.Blocks)
9190
}
9291

9392
// GetDeprecationMessage returns the DeprecationMessage field value.
94-
func (s UnlinkedSchema) GetDeprecationMessage() string {
93+
func (s Schema) GetDeprecationMessage() string {
9594
return s.DeprecationMessage
9695
}
9796

9897
// GetDescription returns the Description field value.
99-
func (s UnlinkedSchema) GetDescription() string {
98+
func (s Schema) GetDescription() string {
10099
return s.Description
101100
}
102101

103102
// GetMarkdownDescription returns the MarkdownDescription field value.
104-
func (s UnlinkedSchema) GetMarkdownDescription() string {
103+
func (s Schema) GetMarkdownDescription() string {
105104
return s.MarkdownDescription
106105
}
107106

108107
// GetVersion always returns 0 as action schemas cannot be versioned.
109-
func (s UnlinkedSchema) GetVersion() int64 {
108+
func (s Schema) GetVersion() int64 {
110109
return 0
111110
}
112111

113112
// Type returns the framework type of the schema.
114-
func (s UnlinkedSchema) Type() attr.Type {
113+
func (s Schema) Type() attr.Type {
115114
return fwschema.SchemaType(s)
116115
}
117116

118117
// TypeAtPath returns the framework type at the given schema path.
119-
func (s UnlinkedSchema) TypeAtPath(ctx context.Context, p path.Path) (attr.Type, diag.Diagnostics) {
118+
func (s Schema) TypeAtPath(ctx context.Context, p path.Path) (attr.Type, diag.Diagnostics) {
120119
return fwschema.SchemaTypeAtPath(ctx, s, p)
121120
}
122121

123122
// TypeAtTerraformPath returns the framework type at the given tftypes path.
124-
func (s UnlinkedSchema) TypeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (attr.Type, error) {
123+
func (s Schema) TypeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (attr.Type, error) {
125124
return fwschema.SchemaTypeAtTerraformPath(ctx, s, p)
126125
}
127126

128127
// ValidateImplementation contains logic for validating the provider-defined
129128
// implementation of the schema and underlying attributes and blocks to prevent
130129
// unexpected errors or panics. This logic runs during the GetProviderSchema RPC,
131130
// or via provider-defined unit testing, and should never include false positives.
132-
func (s UnlinkedSchema) ValidateImplementation(ctx context.Context) diag.Diagnostics {
131+
func (s Schema) ValidateImplementation(ctx context.Context) diag.Diagnostics {
133132
var diags diag.Diagnostics
134133

135134
for attributeName, attribute := range s.GetAttributes() {

0 commit comments

Comments
 (0)