Skip to content

Commit 6a09eaf

Browse files
committed
Create 'future work' section with String simplification and omitzero support
1 parent cbb2703 commit 6a09eaf

File tree

1 file changed

+25
-23
lines changed
  • keps/sig-api-machinery/5589-gogo-dependency

1 file changed

+25
-23
lines changed

keps/sig-api-machinery/5589-gogo-dependency/README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ SIG Architecture for cross-cutting KEPs).
100100
- [Implementation History](#implementation-history)
101101
- [Drawbacks](#drawbacks)
102102
- [Alternatives](#alternatives)
103+
- [Possible Future Work](#possible-future-work)
103104
- [Infrastructure Needed (Optional)](#infrastructure-needed-optional)
104105
<!-- /toc -->
105106

@@ -221,10 +222,6 @@ That accomplishes goal 1 of leaving serialization / deserialization code unchang
221222
All of these steps can be accomplished without changing non-protobuf aspects of Kubernetes API Go types,
222223
which accomplishes goal 2 of leaving the Go types unchanged from previous releases.
223224

224-
A possible step 6 is to modify the generated `String()` methods (which *happen* to be in protobuf generated code)
225-
from outputting pseudo-Go structures to something simpler and more meaningful like a JSON-encoding of the object.
226-
This is not part of the REST or storage API surface, but could disrupt callers who expect exact string representations in tests.
227-
228225
### User Stories
229226

230227
#### Story 1
@@ -388,20 +385,6 @@ The subset of the gogo code generation used by `k8s.io/code-generator/cmd/go-to-
388385
will be forked to a location within the `kubernetes` or `kubernetes-sigs` project,
389386
and pruned / modified to only output the subset of generated code kept by `go-to-protobuf`.
390387

391-
**Modify String() implementation**
392-
393-
There is widespread reliance on Kubernetes API objects implementing `String()`,
394-
so preserving the existence of `String()` implementations is necessary to minimize disruption.
395-
396-
However, this only *happens* to be done as part of protobuf generation,
397-
and the output is a pseudo-Go structure that requires large amounts of code to construct,
398-
and is not particularly meaningful from an API perspective.
399-
400-
After the code-generation is forked and modifiable, the `String()` implementation will be
401-
switched to output a JSON encoding of the object. This will either be done by modifying
402-
the protobuf `String()` generator, or by creating a separate `String()` generator
403-
and disabling the protobuf `String()` generator.
404-
405388
### Test Plan
406389

407390
[x] I/we understand the owners of the involved components may require updates to
@@ -437,11 +420,6 @@ Second phase:
437420
* Complete step 5: Removal of code-generation use of gogo packages
438421
* Result: No gogo packages are referenced from any staging .go file, or as a direct dependency from any Kubernetes go.mod file
439422

440-
Third phase:
441-
* Complete step 6: modify `String()` implementations to be independent of protobuf generation
442-
* Result: `String()` implementations for API objects can be generated independent of protobuf,
443-
and return results
444-
445423
#### Deprecation
446424

447425
n/a
@@ -633,6 +611,30 @@ Two alternatives were considered:
633611
if it becomes apparent there are benefits that would justify a change of that magnitude,
634612
and a plan is proposed to make that change safely.
635613
614+
## Possible Future Work
615+
616+
The following are *possible* future changes that could be made to the protobuf generator
617+
once it is in a location that can be modified in ways scoped to Kubernetes API types.
618+
These changes are not planned as part of this KEP, but are captured here for reference.
619+
620+
**Add omitzero support**
621+
622+
Current protobuf serialization *always* outputs non-pointer scalar and struct fields.
623+
This means that feature-gate-disabled fields must be created as pointers so they will not be serialized unless populated.
624+
Adding support for an `omitzero` tag to protobuf serialization would allow for non-pointer fields which can still be feature-gate-disabled.
625+
626+
**Simplify String() implementation**
627+
628+
There is widespread reliance on Kubernetes API objects implementing `String()`,
629+
so preserving the existence of `String()` implementations is necessary to minimize disruption.
630+
631+
However, this only *happens* to be done as part of protobuf generation,
632+
and the output is a pseudo-Go structure that requires large amounts of code to construct,
633+
and is not particularly meaningful from an API perspective.
634+
635+
After the code-generation is forked and modifiable, the `String()` implementation could be
636+
switched to a simpler implementation, for example returning a JSON encoding of the object.
637+
636638
## Infrastructure Needed (Optional)
637639
638640
n/a

0 commit comments

Comments
 (0)