-
Notifications
You must be signed in to change notification settings - Fork 398
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
[Internal] Use Attributes by default for List Objects #4315
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b929583
first attempt
mgyucht 7f8a845
work
mgyucht d16ec81
fixes
mgyucht 29aa7e9
Merge branch 'readonly-and-list-validators' into use-attributes-by-de…
mgyucht 7c539b8
some work
mgyucht e282b55
work
mgyucht 223acf8
fix formatting
mgyucht 92dbbe9
fix formatting
mgyucht 3ba9694
Merge branch 'main' into use-attributes-by-default
mgyucht 8d42b08
less unnecessary diff
mgyucht f0117c8
work
mgyucht 28c6acc
fix
mgyucht 361cec4
update contributing
mgyucht 402f40a
docs
mgyucht c425508
docs
mgyucht fc9e4c8
tests and better error
mgyucht 10c456e
rename
mgyucht 86b8cce
fix test
mgyucht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 31 additions & 3 deletions
34
internal/providers/pluginfw/tfschema/attribute_converter.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
package tfschema | ||
|
||
type BlockToAttributeConverter interface { | ||
// ConvertBlockToAttribute converts a contained block to its corresponding attribute type. | ||
ConvertBlockToAttribute(string) BaseSchemaBuilder | ||
// Blockable is an interface that can be implemented by an AttributeBuilder to convert it to a BlockBuilder. | ||
type Blockable interface { | ||
// ToBlock converts the AttributeBuilder to a BlockBuilder. | ||
ToBlock() BlockBuilder | ||
} | ||
|
||
// convertAttributesToBlocks converts all attributes implementing the Blockable interface to blocks, returning | ||
// a new NestedBlockObject with the converted attributes and the original blocks. | ||
func convertAttributesToBlocks(attributes map[string]AttributeBuilder, blocks map[string]BlockBuilder) NestedBlockObject { | ||
newAttributes := make(map[string]AttributeBuilder) | ||
newBlocks := make(map[string]BlockBuilder) | ||
for name, attr := range attributes { | ||
if lnab, ok := attr.(Blockable); ok { | ||
newBlocks[name] = lnab.ToBlock() | ||
} else { | ||
newAttributes[name] = attr | ||
} | ||
} | ||
for name, block := range blocks { | ||
newBlocks[name] = block | ||
} | ||
if len(newAttributes) == 0 { | ||
newAttributes = nil | ||
} | ||
if len(newBlocks) == 0 { | ||
newBlocks = nil | ||
} | ||
return NestedBlockObject{ | ||
Attributes: newAttributes, | ||
Blocks: newBlocks, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why, but for me
ConfigureForSdkV2Migration
sends the message that it prepares it for a migration towards SDKv2, how about something with "compatibility", likeMakeCompatibleWithSdkV2
orConfigureAsSdkV2Compatible
?