Open
Description
Describe the bug
- proto3
oneof
type not fully supported by theprotoc-gen-policy
tool. - seems it is calling
oneof
message attributes directly instead it should get inverted to the interface.
To Reproduce
Steps to reproduce the behavior:
- Add
oneof
message types in sample requests.
eg.
message UpdateOrg {
string id = 1;
oneof test {
string name = 2;
string admin_key = 3;
};
string admin_user = 4;
string server_id = 5;
repeated string projects = 6;
}
- hit
compile_go_protobuf_component api
. - wired & implement all request gateway functions.
- try
rebuild components/automate-gateway
- it raises any error:
# github.com/chef/automate/api/external/infra_proxy
/src/api/external/infra_proxy/infra_proxy.pb.policy.go:166:14: m.Name undefined (type *request.UpdateOrg has no field or method Name)
/src/api/external/infra_proxy/infra_proxy.pb.policy.go:168:14: m.AdminKey undefined (type *request.UpdateOrg has no field or method AdminKey)
automate-gateway: Build time: 0m3s
automate-gateway: Exiting on error
Expected behavior
- it should simply rebuild the automate-gateway.
Versions (please complete the following information):
- OS: ubuntu
- Automate: latest master
Additional context
Add any other context about the problem here.
- policy code generated for this type:
policy.MapMethodTo("/chef.automate.api.infra_proxy.InfraProxy/UpdateOrg", "infra:infraServers:{server_id}:orgs:{id}", "infra:infraServers:update", "PUT", "/api/v0/infra/servers/{server_id}/orgs/{id}", func(unexpandedResource string, input interface{}) string {
if m, ok := input.(*request.UpdateOrg); ok {
return policy.ExpandParameterizedResource(unexpandedResource, func(want string) string {
switch want {
case "id":
return m.Id
case "name":
return m.Name
case "admin_key":
return m.AdminKey
case "admin_user":
return m.AdminUser
case "server_id":
return m.ServerId
default:
return ""
}
})
}
return ""
it should be something like
policy.MapMethodTo("/chef.automate.api.infra_proxy.InfraProxy/UpdateOrg", "infra:infraServers:{server_id}:orgs:{id}", "infra:infraServers:update", "PUT", "/api/v0/infra/servers/{server_id}/orgs/{id}", func(unexpandedResource string, input interface{}) string {
if m, ok := input.(*request.UpdateOrg); ok {
return policy.ExpandParameterizedResource(unexpandedResource, func(want string) string {
switch want {
case "id":
return m.Id
case "name":
return m.GetTest().(*request.UpdateOrg_Name).Name
case "admin_key":
return m.GetTest().(*request.UpdateOrg_AdminKey).AdminKey
case "admin_user":
return m.AdminUser
case "server_id":
return m.ServerId
default:
return ""
}
})
}
return ""
})