Skip to content

Commit 8714511

Browse files
actions: move schema to single action type and remove linked resources
we want to leave the door open to evolve the design in the future based on feedback
1 parent 6847e76 commit 8714511

File tree

21 files changed

+1067
-3118
lines changed

21 files changed

+1067
-3118
lines changed

docs/plugin-protocol/tfplugin5.proto

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,7 @@ message ResourceIdentityData {
146146

147147
// ActionSchema defines the schema for an action that can be invoked by Terraform.
148148
message ActionSchema {
149-
// An Unlinked action is an action that is not linked to any resources. It may contain
150-
// references to resources but it can not change the resource state of any resource.
151-
message Unlinked {}
152-
153149
Schema schema = 1; // of the action itself
154-
155-
oneof type {
156-
Unlinked unlinked = 2;
157-
}
158150
}
159151

160152
// Schema is the configuration schema for a Resource, Provider, or Provisioner.
@@ -909,54 +901,27 @@ message ValidateListResourceConfig {
909901

910902
message PlanAction {
911903
message Request {
912-
message LinkedResource {
913-
// prior_state is the state of the linked resource before the action is planned.
914-
DynamicValue prior_state = 1;
915-
// planned_state describes the value the linked resource has been last planned with.
916-
// This could also be the output of a predecessor action.
917-
DynamicValue planned_state = 2;
918-
DynamicValue config = 3;
919-
ResourceIdentityData prior_identity = 4;
920-
}
921904
string action_type = 1;
922-
// linked resources, this should match the order the resources are specified in the schema.
923-
repeated LinkedResource linked_resources = 2;
924905
// config of the action, based on the schema of the actual action
925-
DynamicValue config = 3;
906+
DynamicValue config = 2;
926907
// metadata
927-
ClientCapabilities client_capabilities = 4;
908+
ClientCapabilities client_capabilities = 3;
928909
}
929910

930911
message Response {
931-
message LinkedResource {
932-
DynamicValue planned_state = 1;
933-
ResourceIdentityData planned_identity = 2;
934-
}
935-
// planned changes to the linked resources in the order they are specified in the schema.
936-
repeated LinkedResource linked_resources = 1;
937-
repeated Diagnostic diagnostics = 2;
912+
repeated Diagnostic diagnostics = 1;
938913
// metadata
939-
Deferred deferred = 3;
914+
Deferred deferred = 2;
940915
}
941916
}
942917

943918
message InvokeAction {
944919
message Request {
945-
message LinkedResource {
946-
DynamicValue prior_state = 1;
947-
// planned_state describes the value the linked resource has been last planned
948-
// with. This could also be the output of a predecessor action.
949-
DynamicValue planned_state = 2;
950-
DynamicValue config = 3;
951-
ResourceIdentityData planned_identity = 4;
952-
}
953920
string action_type = 1;
954-
// linked resources, matching the order they are specified in the schema
955-
repeated LinkedResource linked_resources = 2;
956921
// response from the plan
957-
DynamicValue config = 3;
922+
DynamicValue config = 2;
958923
// metadata
959-
ClientCapabilities client_capabilities = 4;
924+
ClientCapabilities client_capabilities = 3;
960925
}
961926

962927
message Event {
@@ -965,16 +930,7 @@ message InvokeAction {
965930
string message = 1;
966931
}
967932
message Completed {
968-
message LinkedResource {
969-
DynamicValue new_state = 1;
970-
ResourceIdentityData new_identity = 2;
971-
// Can only be set if error diagnostics are present.
972-
bool requires_replace = 3;
973-
}
974-
975-
// linked resources, matching the order they are specified in the schema
976-
repeated LinkedResource linked_resources = 1;
977-
repeated Diagnostic diagnostics = 2;
933+
repeated Diagnostic diagnostics = 1;
978934
}
979935

980936
oneof type {
@@ -988,14 +944,9 @@ message ValidateActionConfig {
988944
message Request {
989945
string type_name = 1;
990946
DynamicValue config = 2;
991-
repeated LinkedResourceConfig linked_resources = 3;
992947
}
993948
message Response {
994949
repeated Diagnostic diagnostics = 1;
995950
}
996951
}
997952

998-
message LinkedResourceConfig {
999-
string type_name = 1;
1000-
DynamicValue config = 2;
1001-
}

docs/plugin-protocol/tfplugin6.proto

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,7 @@ message ResourceIdentityData {
146146

147147
// ActionSchema defines the schema for an action that can be invoked by Terraform.
148148
message ActionSchema {
149-
// An Unlinked action is an action that is not linked to any resources. It may contain
150-
// references to resources but it can not change the resource state of any resource.
151-
message Unlinked {}
152-
153149
Schema schema = 1; // of the action itself
154-
155-
oneof type {
156-
Unlinked unlinked = 2;
157-
}
158150
}
159151

160152
// Schema is the configuration schema for a Resource or Provider.
@@ -947,55 +939,27 @@ message DeleteState {
947939

948940
message PlanAction {
949941
message Request {
950-
message LinkedResource {
951-
// prior_state is the state of the linked resource before the action is planned.
952-
DynamicValue prior_state = 1;
953-
// planned_state describes the value the linked resource has been last planned with.
954-
// This could also be the output of a predecessor action.
955-
DynamicValue planned_state = 2;
956-
DynamicValue config = 3;
957-
ResourceIdentityData prior_identity = 4;
958-
}
959942
string action_type = 1;
960-
// linked resources, this should match the order the resources are specified in the schema.
961-
repeated LinkedResource linked_resources = 2;
962943
// config of the action, based on the schema of the actual action
963-
DynamicValue config = 3;
944+
DynamicValue config = 2;
964945
// metadata
965-
ClientCapabilities client_capabilities = 4;
946+
ClientCapabilities client_capabilities = 3;
966947
}
967948

968949
message Response {
969-
message LinkedResource {
970-
DynamicValue planned_state = 1;
971-
ResourceIdentityData planned_identity = 2;
972-
}
973-
// planned changes to the linked resources in the order they are specified in the schema.
974-
repeated LinkedResource linked_resources = 1;
975-
repeated Diagnostic diagnostics = 2;
950+
repeated Diagnostic diagnostics = 1;
976951
// metadata
977-
Deferred deferred = 3;
952+
Deferred deferred = 2;
978953
}
979954
}
980955

981956
message InvokeAction {
982957
message Request {
983-
message LinkedResource {
984-
DynamicValue prior_state = 1;
985-
// planned_state describes the value the linked resource has been last planned
986-
// with. This could also be the output of a predecessor action.
987-
DynamicValue planned_state = 2;
988-
DynamicValue config = 3;
989-
ResourceIdentityData planned_identity = 4;
990-
}
991-
992958
string action_type = 1;
993-
// linked resources, matching the order they are specified in the schema
994-
repeated LinkedResource linked_resources = 2;
995959
// response from the plan
996-
DynamicValue config = 3;
960+
DynamicValue config = 2;
997961
// metadata
998-
ClientCapabilities client_capabilities = 4;
962+
ClientCapabilities client_capabilities = 3;
999963
}
1000964

1001965
message Event {
@@ -1005,15 +969,7 @@ message InvokeAction {
1005969
}
1006970

1007971
message Completed {
1008-
message LinkedResource {
1009-
DynamicValue new_state = 1;
1010-
ResourceIdentityData new_identity = 2;
1011-
// Can only be set if error diagnostics are present.
1012-
bool requires_replace = 3;
1013-
}
1014-
// linked resources, matching the order they are specified in the schema
1015-
repeated LinkedResource linked_resources = 1;
1016-
repeated Diagnostic diagnostics = 2;
972+
repeated Diagnostic diagnostics = 1;
1017973
}
1018974

1019975
oneof type {
@@ -1027,14 +983,8 @@ message ValidateActionConfig {
1027983
message Request {
1028984
string type_name = 1;
1029985
DynamicValue config = 2;
1030-
repeated LinkedResourceConfig linked_resources = 3;
1031986
}
1032987
message Response {
1033988
repeated Diagnostic diagnostics = 1;
1034989
}
1035-
}
1036-
1037-
message LinkedResourceConfig {
1038-
string type_name = 1;
1039-
DynamicValue config = 2;
1040-
}
990+
}

internal/command/jsonformat/plan_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func TestRenderHuman_InvokeActionPlan(t *testing.T) {
5454
},
5555
},
5656
},
57-
Unlinked: new(jsonprovider.UnlinkedAction),
5857
},
5958
},
6059
},
@@ -134,7 +133,6 @@ func TestRenderHuman_InvokeActionPlanWithRefresh(t *testing.T) {
134133
},
135134
},
136135
},
137-
Unlinked: new(jsonprovider.UnlinkedAction),
138136
},
139137
},
140138
},
@@ -8711,7 +8709,6 @@ func TestResourceChange_actions(t *testing.T) {
87118709
Actions: map[string]providers.ActionSchema{
87128710
"test_unlinked": {
87138711
ConfigSchema: blockSchema,
8714-
Unlinked: &providers.UnlinkedAction{},
87158712
},
87168713
},
87178714
},

internal/command/jsonprovider/provider_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ func TestMarshalProvider(t *testing.T) {
250250
"req_attr": {Type: cty.List(cty.String), Required: true},
251251
},
252252
},
253-
Unlinked: &providers.UnlinkedAction{},
254253
},
255254
},
256255
},
@@ -298,7 +297,6 @@ func TestMarshalProvider(t *testing.T) {
298297
},
299298
DescriptionKind: "plain",
300299
},
301-
Unlinked: &UnlinkedAction{},
302300
},
303301
},
304302
},

internal/command/jsonprovider/schema.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,8 @@ func marshalIdentitySchemas(schemas map[string]providers.Schema) map[string]*Ide
7171

7272
type ActionSchema struct {
7373
ConfigSchema *Block `json:"block,omitempty"`
74-
75-
// Only unlinked actions are supported.
76-
Unlinked *UnlinkedAction `json:"unlinked,omitempty"`
7774
}
7875

79-
type UnlinkedAction struct{}
80-
8176
func marshalActionSchemas(schemas map[string]providers.ActionSchema) map[string]*ActionSchema {
8277
ret := make(map[string]*ActionSchema, len(schemas))
8378
for name, schema := range schemas {
@@ -87,13 +82,8 @@ func marshalActionSchemas(schemas map[string]providers.ActionSchema) map[string]
8782
}
8883

8984
func marshalActionSchema(schema providers.ActionSchema) *ActionSchema {
90-
ret := &ActionSchema{
85+
return &ActionSchema{
9186
ConfigSchema: marshalBlock(schema.ConfigSchema),
9287
}
9388

94-
if schema.Unlinked != nil {
95-
ret.Unlinked = &UnlinkedAction{}
96-
}
97-
98-
return ret
9989
}

internal/command/show_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,6 @@ func showFixtureSchema() *providers.GetProviderSchemaResponse {
11341134
"attr": {Type: cty.String, Optional: true},
11351135
},
11361136
},
1137-
Unlinked: &providers.UnlinkedAction{},
11381137
},
11391138
},
11401139
}

0 commit comments

Comments
 (0)