Protobuf API V2: compatibility fixes #94
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes to maintain compatibility with the old implementation
json.marshal
becamejson.encode
. Added these aliases back like we do foryamlModule
Skycfg previously allowed setting proto2 message values with None, effectively unsetting them. For maps, this set them to be nil, so
became
With protoreflect,
map.Set
only accepts aprotoreflect.Value
https://pkg.go.dev/google.golang.org/protobuf/reflect/protoreflect#Map.Set (a struct, cannot be nil) so my two options are 1) create an empty&pb.MessageV2{}
or treatNone
as not setting the key. I went with the latter, to make it behave likeprotoMessage
but neither option seems greatskycfg/internal/go/skycfg/proto_test.go
Line 1069 in e785c6f
skycfg/internal/go/skycfg/proto_test.go
Line 870 in e785c6f
Tests
I added a test for compatibility