-
Notifications
You must be signed in to change notification settings - Fork 386
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
Implement basic functionality for StructToSchema #3788
Implement basic functionality for StructToSchema #3788
Conversation
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.
Had some comments but core logic LGTM.
scm[fieldName] = schema.SingleNestedAttribute{Attributes: nestedScm, Optional: true} | ||
} | ||
} else { | ||
panic(fmt.Errorf("unknown type for field: %s", typeField.Name)) |
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.
should we also print the type as well here?
@@ -289,3 +290,105 @@ func checkTheStringInForceSendFields(fieldName string, forceSendFields []string) | |||
} | |||
return false | |||
} | |||
|
|||
func pluginFrameworkTypeToSchema(v reflect.Value) map[string]schema.Attribute { |
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.
This would also need to include aliases and tracking context that we currently have to typeToSchema for sdkv2?
Example -- we use tracking context for depth:
if tc.depthExceeded(typeField) {
// Skip the field if recursion depth is over the limit.
log.Printf("[TRACE] over recursion limit, skipping field: %s, max depth: %d", getNameForType(typeField.Type), tc.getMaxDepthForTypeField(typeField))
continue
}
and aliases while getting field name:
fieldName := chooseFieldNameWithAliases(typeField, v.Type(), aliases)
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.
For tracking context yes, alias no.
Tracking context is coming up as the next step for recursion depth limit.
In the future all of alias information will go directly into the proto layer with annotations, so we don't have to worry about them in tf
cf5d4bb
into
terraform-plugin-framework
Changes
StructToSchema
, everything isOptional
nowCustomizableSchema
Tests
make test
run locallydocs/
folderinternal/acceptance