Skip to content

Commit e3996cf

Browse files
authored
Refactor to single action schema type (#377)
* Refactor to single action schema type * update dependencies
1 parent 07a79a8 commit e3996cf

File tree

8 files changed

+123
-119
lines changed

8 files changed

+123
-119
lines changed

go.mod

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ require (
88
github.com/hashicorp/go-memdb v1.3.5
99
github.com/hashicorp/go-version v1.7.0
1010
github.com/hashicorp/terraform-json v0.26.0
11-
github.com/hashicorp/terraform-plugin-framework v1.16.0-beta.1.0.20250821123331-51dc6877ded6
11+
github.com/hashicorp/terraform-plugin-framework v1.16.0-beta.1.0.20250915220419-1b972ed93a1b
1212
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0
1313
github.com/hashicorp/terraform-plugin-framework-nettypes v0.3.0
1414
github.com/hashicorp/terraform-plugin-framework-timeouts v0.5.0
1515
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0
1616
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0
17-
github.com/hashicorp/terraform-plugin-go v0.29.0-beta.1
18-
github.com/hashicorp/terraform-plugin-mux v0.20.0
17+
github.com/hashicorp/terraform-plugin-go v0.29.0-beta.1.0.20250915194700-c3810b1245c0
18+
github.com/hashicorp/terraform-plugin-mux v0.21.0-alpha.1.0.20250915212024-d1e230c1fcf3
1919
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
20-
github.com/hashicorp/terraform-plugin-testing v1.13.3
21-
github.com/zclconf/go-cty v1.17.0
20+
github.com/hashicorp/terraform-plugin-testing v1.13.2
21+
github.com/zclconf/go-cty v1.16.3
2222
)
2323

2424
require (
@@ -34,7 +34,7 @@ require (
3434
github.com/hashicorp/go-hclog v1.6.3 // indirect
3535
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
3636
github.com/hashicorp/go-multierror v1.1.1 // indirect
37-
github.com/hashicorp/go-plugin v1.6.3 // indirect
37+
github.com/hashicorp/go-plugin v1.7.0 // indirect
3838
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
3939
github.com/hashicorp/go-uuid v1.0.3 // indirect
4040
github.com/hashicorp/golang-lru v0.5.4 // indirect
@@ -43,29 +43,29 @@ require (
4343
github.com/hashicorp/logutils v1.0.0 // indirect
4444
github.com/hashicorp/terraform-exec v0.23.0 // indirect
4545
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
46-
github.com/hashicorp/terraform-registry-address v0.3.0 // indirect
46+
github.com/hashicorp/terraform-registry-address v0.4.0 // indirect
4747
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
48-
github.com/hashicorp/yamux v0.1.1 // indirect
48+
github.com/hashicorp/yamux v0.1.2 // indirect
4949
github.com/mattn/go-colorable v0.1.13 // indirect
5050
github.com/mattn/go-isatty v0.0.20 // indirect
5151
github.com/mitchellh/copystructure v1.2.0 // indirect
5252
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
5353
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
5454
github.com/mitchellh/mapstructure v1.5.0 // indirect
5555
github.com/mitchellh/reflectwalk v1.0.2 // indirect
56-
github.com/oklog/run v1.0.0 // indirect
56+
github.com/oklog/run v1.1.0 // indirect
5757
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
5858
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
5959
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
60-
golang.org/x/crypto v0.39.0 // indirect
61-
golang.org/x/mod v0.25.0 // indirect
62-
golang.org/x/net v0.41.0 // indirect
63-
golang.org/x/sync v0.15.0 // indirect
64-
golang.org/x/sys v0.33.0 // indirect
65-
golang.org/x/text v0.26.0 // indirect
66-
golang.org/x/tools v0.33.0 // indirect
60+
golang.org/x/crypto v0.41.0 // indirect
61+
golang.org/x/mod v0.26.0 // indirect
62+
golang.org/x/net v0.43.0 // indirect
63+
golang.org/x/sync v0.16.0 // indirect
64+
golang.org/x/sys v0.35.0 // indirect
65+
golang.org/x/text v0.28.0 // indirect
66+
golang.org/x/tools v0.35.0 // indirect
6767
google.golang.org/appengine v1.6.8 // indirect
68-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
69-
google.golang.org/grpc v1.74.2 // indirect
70-
google.golang.org/protobuf v1.36.6 // indirect
68+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
69+
google.golang.org/grpc v1.75.1 // indirect
70+
google.golang.org/protobuf v1.36.9 // indirect
7171
)

go.sum

Lines changed: 60 additions & 56 deletions
Large diffs are not rendered by default.

internal/framework5provider/unlinked_action.go renamed to internal/framework5provider/modify_file_action.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import (
1313
"github.com/hashicorp/terraform-plugin-framework/path"
1414
)
1515

16-
var _ action.Action = &UnlinkedAction{}
17-
var _ action.ActionWithModifyPlan = &UnlinkedAction{}
16+
var _ action.Action = &ModifyFileAction{}
17+
var _ action.ActionWithModifyPlan = &ModifyFileAction{}
1818

19-
func NewUnlinkedAction() action.Action {
20-
return &UnlinkedAction{}
19+
func NewModifyAction() action.Action {
20+
return &ModifyFileAction{}
2121
}
2222

23-
type UnlinkedAction struct{}
23+
type ModifyFileAction struct{}
2424

25-
func (u *UnlinkedAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
26-
resp.Schema = schema.UnlinkedSchema{
25+
func (u *ModifyFileAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
26+
resp.Schema = schema.Schema{
2727
Attributes: map[string]schema.Attribute{
2828
"filename": schema.StringAttribute{
2929
Required: true,
@@ -38,11 +38,11 @@ func (u *UnlinkedAction) Schema(ctx context.Context, req action.SchemaRequest, r
3838
}
3939
}
4040

41-
func (u *UnlinkedAction) Metadata(ctx context.Context, req action.MetadataRequest, resp *action.MetadataResponse) {
42-
resp.TypeName = req.ProviderTypeName + "_unlinked_action"
41+
func (u *ModifyFileAction) Metadata(ctx context.Context, req action.MetadataRequest, resp *action.MetadataResponse) {
42+
resp.TypeName = req.ProviderTypeName + "_modify_file_action"
4343
}
4444

45-
func (u *UnlinkedAction) ModifyPlan(ctx context.Context, req action.ModifyPlanRequest, resp *action.ModifyPlanResponse) {
45+
func (u *ModifyFileAction) ModifyPlan(ctx context.Context, req action.ModifyPlanRequest, resp *action.ModifyPlanResponse) {
4646
if req.Config.Raw.IsNull() {
4747
return
4848
}
@@ -61,9 +61,9 @@ func (u *UnlinkedAction) ModifyPlan(ctx context.Context, req action.ModifyPlanRe
6161
}
6262
}
6363

64-
func (u *UnlinkedAction) Invoke(ctx context.Context, req action.InvokeRequest, resp *action.InvokeResponse) {
64+
func (u *ModifyFileAction) Invoke(ctx context.Context, req action.InvokeRequest, resp *action.InvokeResponse) {
6565
resp.SendProgress = func(event action.InvokeProgressEvent) {
66-
event.Message = "starting provider defined unlinked action"
66+
event.Message = "starting provider defined action"
6767
}
6868

6969
var filename string

internal/framework5provider/unlinked_action_test.go renamed to internal/framework5provider/modify_file_action_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/hashicorp/terraform-plugin-testing/tfversion"
2020
)
2121

22-
func TestUnlinkedAction(t *testing.T) {
22+
func TestModifyFileAction(t *testing.T) {
2323
f := filepath.Join(t.TempDir(), "local_file")
2424
f = strings.ReplaceAll(f, `\`, `\\`)
2525

@@ -44,12 +44,12 @@ func TestUnlinkedAction(t *testing.T) {
4444
lifecycle {
4545
action_trigger {
4646
events = [before_create]
47-
actions = [action.framework_unlinked_action.file]
47+
actions = [action.framework_modify_file_action.file]
4848
}
4949
}
5050
}
5151
52-
action "framework_unlinked_action" "file" {
52+
action "framework_modify_file_action" "file" {
5353
config {
5454
filename = %[1]q
5555
content = %[2]q
@@ -77,12 +77,12 @@ func TestUnlinkedAction(t *testing.T) {
7777
lifecycle {
7878
action_trigger {
7979
events = [before_create]
80-
actions = [action.framework_unlinked_action.file]
80+
actions = [action.framework_modify_file_action.file]
8181
}
8282
}
8383
}
8484
85-
action "framework_unlinked_action" "file" {
85+
action "framework_modify_file_action" "file" {
8686
config {
8787
filename = %[1]q
8888
content = "updated test data"
@@ -110,12 +110,12 @@ func TestUnlinkedAction(t *testing.T) {
110110
lifecycle {
111111
action_trigger {
112112
events = [after_update] # action triggers after update
113-
actions = [action.framework_unlinked_action.file]
113+
actions = [action.framework_modify_file_action.file]
114114
}
115115
}
116116
}
117117
118-
action "framework_unlinked_action" "file" {
118+
action "framework_modify_file_action" "file" {
119119
config {
120120
filename = %[1]q
121121
content = "updated test data"
@@ -143,12 +143,12 @@ func TestUnlinkedAction(t *testing.T) {
143143
lifecycle {
144144
action_trigger {
145145
events = [after_update]
146-
actions = [action.framework_unlinked_action.file]
146+
actions = [action.framework_modify_file_action.file]
147147
}
148148
}
149149
}
150150
151-
action "framework_unlinked_action" "file" {
151+
action "framework_modify_file_action" "file" {
152152
config {
153153
filename = %[1]q
154154
content = %[2]q

internal/framework5provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (p *testProvider) ListResources(_ context.Context) []func() list.ListResour
156156

157157
func (p *testProvider) Actions(ctx context.Context) []func() action.Action {
158158
return []func() action.Action{
159-
NewUnlinkedAction,
159+
NewModifyAction,
160160
}
161161
}
162162

internal/framework6provider/unlinked_action.go renamed to internal/framework6provider/modify_file_action.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import (
1313
"github.com/hashicorp/terraform-plugin-framework/path"
1414
)
1515

16-
var _ action.Action = &UnlinkedAction{}
17-
var _ action.ActionWithModifyPlan = &UnlinkedAction{}
16+
var _ action.Action = &ModifyFileAction{}
17+
var _ action.ActionWithModifyPlan = &ModifyFileAction{}
1818

19-
func NewUnlinkedAction() action.Action {
20-
return &UnlinkedAction{}
19+
func NewModifyFileAction() action.Action {
20+
return &ModifyFileAction{}
2121
}
2222

23-
type UnlinkedAction struct{}
23+
type ModifyFileAction struct{}
2424

25-
func (u *UnlinkedAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
26-
resp.Schema = schema.UnlinkedSchema{
25+
func (u *ModifyFileAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
26+
resp.Schema = schema.Schema{
2727
Attributes: map[string]schema.Attribute{
2828
"filename": schema.StringAttribute{
2929
Required: true,
@@ -38,11 +38,11 @@ func (u *UnlinkedAction) Schema(ctx context.Context, req action.SchemaRequest, r
3838
}
3939
}
4040

41-
func (u *UnlinkedAction) Metadata(ctx context.Context, req action.MetadataRequest, resp *action.MetadataResponse) {
42-
resp.TypeName = req.ProviderTypeName + "_unlinked_action"
41+
func (u *ModifyFileAction) Metadata(ctx context.Context, req action.MetadataRequest, resp *action.MetadataResponse) {
42+
resp.TypeName = req.ProviderTypeName + "_modify_file_action"
4343
}
4444

45-
func (u *UnlinkedAction) ModifyPlan(ctx context.Context, req action.ModifyPlanRequest, resp *action.ModifyPlanResponse) {
45+
func (u *ModifyFileAction) ModifyPlan(ctx context.Context, req action.ModifyPlanRequest, resp *action.ModifyPlanResponse) {
4646
if req.Config.Raw.IsNull() {
4747
return
4848
}
@@ -61,9 +61,9 @@ func (u *UnlinkedAction) ModifyPlan(ctx context.Context, req action.ModifyPlanRe
6161
}
6262
}
6363

64-
func (u *UnlinkedAction) Invoke(ctx context.Context, req action.InvokeRequest, resp *action.InvokeResponse) {
64+
func (u *ModifyFileAction) Invoke(ctx context.Context, req action.InvokeRequest, resp *action.InvokeResponse) {
6565
resp.SendProgress = func(event action.InvokeProgressEvent) {
66-
event.Message = "starting provider defined unlinked action"
66+
event.Message = "starting provider defined action"
6767
}
6868

6969
var filename string

internal/framework6provider/unlinked_action_test.go renamed to internal/framework6provider/modify_file_action_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/hashicorp/terraform-plugin-testing/tfversion"
2020
)
2121

22-
func TestUnlinkedAction(t *testing.T) {
22+
func TestModifyFileAction(t *testing.T) {
2323
f := filepath.Join(t.TempDir(), "local_file")
2424
f = strings.ReplaceAll(f, `\`, `\\`)
2525

@@ -44,12 +44,12 @@ func TestUnlinkedAction(t *testing.T) {
4444
lifecycle {
4545
action_trigger {
4646
events = [before_create]
47-
actions = [action.framework_unlinked_action.file]
47+
actions = [action.framework_modify_file_action.file]
4848
}
4949
}
5050
}
5151
52-
action "framework_unlinked_action" "file" {
52+
action "framework_modify_file_action" "file" {
5353
config {
5454
filename = %[1]q
5555
content = %[2]q
@@ -77,12 +77,12 @@ func TestUnlinkedAction(t *testing.T) {
7777
lifecycle {
7878
action_trigger {
7979
events = [before_create]
80-
actions = [action.framework_unlinked_action.file]
80+
actions = [action.framework_modify_file_action.file]
8181
}
8282
}
8383
}
8484
85-
action "framework_unlinked_action" "file" {
85+
action "framework_modify_file_action" "file" {
8686
config {
8787
filename = %[1]q
8888
content = "updated test data"
@@ -110,12 +110,12 @@ func TestUnlinkedAction(t *testing.T) {
110110
lifecycle {
111111
action_trigger {
112112
events = [after_update] # action triggers after update
113-
actions = [action.framework_unlinked_action.file]
113+
actions = [action.framework_modify_file_action.file]
114114
}
115115
}
116116
}
117117
118-
action "framework_unlinked_action" "file" {
118+
action "framework_modify_file_action" "file" {
119119
config {
120120
filename = %[1]q
121121
content = "updated test data"
@@ -143,12 +143,12 @@ func TestUnlinkedAction(t *testing.T) {
143143
lifecycle {
144144
action_trigger {
145145
events = [after_update]
146-
actions = [action.framework_unlinked_action.file]
146+
actions = [action.framework_modify_file_action.file]
147147
}
148148
}
149149
}
150150
151-
action "framework_unlinked_action" "file" {
151+
action "framework_modify_file_action" "file" {
152152
config {
153153
filename = %[1]q
154154
content = %[2]q

internal/framework6provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (p *testProvider) EphemeralResources(ctx context.Context) []func() ephemera
148148

149149
func (p *testProvider) Actions(ctx context.Context) []func() action.Action {
150150
return []func() action.Action{
151-
NewUnlinkedAction,
151+
NewModifyFileAction,
152152
}
153153
}
154154

0 commit comments

Comments
 (0)