Skip to content

Commit

Permalink
Merge pull request #55970 from nikhita/fix-empty-struct-proto
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 54837, 55970, 55912, 55898, 52977). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix protobuf generation for empty struct

Currently, we are not able to generate protobuf for empty structs. This PR fixes proto generation for empty structs. (Example: `type Foo struct{}`)

Needed for kubernetes/kubernetes#55168.

**Release note**:

```release-note
NONE
```

/assign @sttts

Kubernetes-commit: 738940564d44351e2813ba9277498f5df1169349
  • Loading branch information
k8s-publish-robot committed Nov 28, 2017
2 parents 0c3fe41 + dafce78 commit d6c0e73
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/go-to-protobuf/protobuf/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func isProtoable(seen map[*types.Type]bool, t *types.Type) bool {
case types.Map:
return isProtoable(seen, t.Key) && isProtoable(seen, t.Elem)
case types.Struct:
if len(t.Members) == 0 {
return true
}
for _, m := range t.Members {
if isProtoable(seen, m.Type) {
return true
Expand Down

0 comments on commit d6c0e73

Please sign in to comment.