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 d86436f + 1f29067 commit 74a1f0b
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 74a1f0b

Please sign in to comment.