Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore MinItems and MaxItems diff in nested block #118

Merged
merged 4 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/118.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
tf5muxserver+tf6muxserver: Allow differing provider schema block `MinItems` and `MaxItems` as terraform-plugin-framework does not use those fields for configuration validation
```
48 changes: 48 additions & 0 deletions tf5muxserver/mux_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,54 @@ func TestNewMuxServer(t *testing.T) {
}).ProviderServer,
},
},
"nested block MinItems and MaxItems diff are ignored": {
servers: []func() tfprotov5.ProviderServer{
(&tf5testserver.TestServer{
ProviderSchema: &tfprotov5.Schema{
Version: 1,
Block: &tfprotov5.SchemaBlock{
Version: 1,
BlockTypes: []*tfprotov5.SchemaNestedBlock{
{
TypeName: "feature",
Nesting: tfprotov5.SchemaNestedBlockNestingModeList,
Block: &tfprotov5.SchemaBlock{
Version: 1,
Description: "features to enable on the provider",
DescriptionKind: tfprotov5.StringKindPlain,
Attributes: []*tfprotov5.SchemaAttribute{},
},
MinItems: 1,
MaxItems: 2,
},
},
},
},
}).ProviderServer,
(&tf5testserver.TestServer{
ProviderSchema: &tfprotov5.Schema{
Version: 1,
Block: &tfprotov5.SchemaBlock{
Version: 1,
BlockTypes: []*tfprotov5.SchemaNestedBlock{
{
TypeName: "feature",
Nesting: tfprotov5.SchemaNestedBlockNestingModeList,
Block: &tfprotov5.SchemaBlock{
Version: 1,
Description: "features to enable on the provider",
DescriptionKind: tfprotov5.StringKindPlain,
Attributes: []*tfprotov5.SchemaAttribute{},
},
MinItems: 0,
MaxItems: 0,
},
},
},
},
}).ProviderServer,
},
},
}

for name, testCase := range testCases {
Expand Down
1 change: 1 addition & 0 deletions tf5muxserver/schema_equality.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var schemaCmpOptions = []cmp.Option{
cmpopts.SortSlices(func(i, j *tfprotov5.SchemaNestedBlock) bool {
return i.TypeName < j.TypeName
}),
cmpopts.IgnoreFields(tfprotov5.SchemaNestedBlock{}, "MinItems", "MaxItems"),
}

// schemaDiff outputs the difference between schemas while accounting for
Expand Down
48 changes: 48 additions & 0 deletions tf6muxserver/mux_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,54 @@ func TestNewMuxServer(t *testing.T) {
}).ProviderServer,
},
},
"nested block MinItems and MaxItems diff are ignored": {
servers: []func() tfprotov6.ProviderServer{
(&tf6testserver.TestServer{
ProviderSchema: &tfprotov6.Schema{
Version: 1,
Block: &tfprotov6.SchemaBlock{
Version: 1,
BlockTypes: []*tfprotov6.SchemaNestedBlock{
{
TypeName: "feature",
Nesting: tfprotov6.SchemaNestedBlockNestingModeList,
Block: &tfprotov6.SchemaBlock{
Version: 1,
Description: "features to enable on the provider",
DescriptionKind: tfprotov6.StringKindPlain,
Attributes: []*tfprotov6.SchemaAttribute{},
},
MinItems: 1,
MaxItems: 2,
},
},
},
},
}).ProviderServer,
(&tf6testserver.TestServer{
ProviderSchema: &tfprotov6.Schema{
Version: 1,
Block: &tfprotov6.SchemaBlock{
Version: 1,
BlockTypes: []*tfprotov6.SchemaNestedBlock{
{
TypeName: "feature",
Nesting: tfprotov6.SchemaNestedBlockNestingModeList,
Block: &tfprotov6.SchemaBlock{
Version: 1,
Description: "features to enable on the provider",
DescriptionKind: tfprotov6.StringKindPlain,
Attributes: []*tfprotov6.SchemaAttribute{},
},
MinItems: 0,
MaxItems: 0,
},
},
},
},
}).ProviderServer,
},
},
}

for name, testCase := range testCases {
Expand Down
1 change: 1 addition & 0 deletions tf6muxserver/schema_equality.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var schemaCmpOptions = []cmp.Option{
cmpopts.SortSlices(func(i, j *tfprotov6.SchemaNestedBlock) bool {
return i.TypeName < j.TypeName
}),
cmpopts.IgnoreFields(tfprotov6.SchemaNestedBlock{}, "MinItems", "MaxItems"),
}

// schemaDiff outputs the difference between schemas while accounting for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The following provider server implementations are supported:

To be combined, provider servers must meet the following requirements:

* All provider schemas must match.
* All provider schemas (except block `MinItems`/`MaxItems`) must match.
* All provider meta schemas must match.
* Only one provider may implement each resource and data source.

Expand Down