-
Notifications
You must be signed in to change notification settings - Fork 4
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
Expect short names in flatten functions #63
Comments
I expect it's only the root property in Read function need such modifications. |
What if there is also nested object inside another nested object? E.g. we have following nested objects: type Foo struct {
*Bar
}
type Bar struct {
*Baz
}
type Baz struct {
Name string
}
func main() {
f := &Foo{
&Bar{
&Baz{
Name: "foobar",
},
},
}
if prop := f.Bar; prop != nil {
// `prop` below has different identity
if prop := prop.Baz; prop != nil {
fmt.Println(prop.Name)
}
}
} Take note at the comment above, where |
I suppose this case will not appear. This issue is essentially a naming convention of Hashicorp, specifically, when using
MM now always uses For your specific example. it should be in this way (because if prop := f.Bar; prop != nil {
// `prop` below has different identity
if err := d.set("Baz", flattenBaz(prop.Baz)){
return fmt.Error(" ... ")
}
} If if prop := f.Bar; prop != nil {
// `prop` below has different identity
if baz := prop.Baz; baz != nil {
return fmt.Error(" ... ")
}
} |
After digging further, I found that part of naming is controled by file: nested_object_shcema_assign.erb, as below: <%
...
temp_var = sdk_type.go_variable_name || sdk_type.go_field_name.camelcase(:lower) || input
-%>
... And this part is only used for this purpose. From the code above we can see the var name is resolved via prioprity: So I suppose for this issue, we can just modify the |
Update last reply If we want the embeded part of unmarshalling(i.e. sdk -> schema) to follow same naming convention on tmp var, we need to apply the same naming convention used in nested_object_schema_assign.erb in other places. |
Auto-Gened:
Expected:
The text was updated successfully, but these errors were encountered: