mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Allow proto tag to define field name
When we introduce a new field for backwards compatibility, we may want to specify a different protobuf field name (one that matches JSON) than the automatic transformation applied to the struct field. This allows an API field to define the name of its protobuf tag.
This commit is contained in:
parent
7b067c859f
commit
68bfba29b9
@ -589,6 +589,8 @@ func protobufTagToField(tag string, field *protoField, m types.Member, t *types.
|
||||
return fmt.Errorf("member %q of %q malformed 'protobuf' tag, tag %d should be key=value, got %q\n", m.Name, t.Name, i+4, extra)
|
||||
}
|
||||
switch parts[0] {
|
||||
case "name":
|
||||
protoExtra[parts[0]] = parts[1]
|
||||
case "casttype", "castkey", "castvalue":
|
||||
parts[0] = fmt.Sprintf("(gogoproto.%s)", parts[0])
|
||||
protoExtra[parts[0]] = parts[1]
|
||||
|
Loading…
Reference in New Issue
Block a user