Skip to content

Commit

Permalink
Merge branch 'main' into release-please--branches--main--components--…
Browse files Browse the repository at this point in the history
…pubsub
  • Loading branch information
hongalex committed May 24, 2023
2 parents c47c06a + 46fc060 commit b53a1bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ for i in $(find . -name go.mod); do
go mod tidy
popd
done
git diff '*go.mod' | tee /dev/stderr | (! read)
git diff '*go.sum' | tee /dev/stderr | (! read)

# Documentation for the :^ pathspec can be found at:
# https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
git diff '*go.mod' :^internal/generated/snippets | tee /dev/stderr | (! read)
git diff '*go.sum' :^internal/generated/snippets | tee /dev/stderr | (! read)

gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read)
goimports -l . 2>&1 | tee /dev/stderr | (! read)
Expand Down
3 changes: 1 addition & 2 deletions pubsub/pstest/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ func (s *GServer) UpdateTopic(_ context.Context, req *pb.UpdateTopicRequest) (*p
}
t.proto.MessageRetentionDuration = req.Topic.MessageRetentionDuration
case "schema_settings":
// Clear this field.
t.proto.SchemaSettings = &pb.SchemaSettings{}
t.proto.SchemaSettings = req.Topic.SchemaSettings
case "schema_settings.schema":
if t.proto.SchemaSettings == nil {
t.proto.SchemaSettings = &pb.SchemaSettings{}
Expand Down
8 changes: 7 additions & 1 deletion pubsub/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ func (t *Topic) updateRequest(cfg TopicConfigToUpdate) *pb.UpdateTopicRequest {
}
paths = append(paths, "message_retention_duration")
}
// Updating SchemaSettings' field masks are more complicated here
// since each field should be able to be independently edited, while
// preserving the current values for everything else. We also denote
// the zero value SchemaSetting to mean clearing or removing schema
// from the topic.
if cfg.SchemaSettings != nil {
pt.SchemaSettings = schemaSettingsToProto(cfg.SchemaSettings)
clearSchema := true
Expand All @@ -426,9 +431,10 @@ func (t *Topic) updateRequest(cfg TopicConfigToUpdate) *pb.UpdateTopicRequest {
paths = append(paths, "schema_settings.last_revision_id")
clearSchema = false
}
// Clear the schema if none of it's value changes.
// Clear the schema if all of its values are equal to the zero value.
if clearSchema {
paths = append(paths, "schema_settings")
pt.SchemaSettings = nil
}
}
return &pb.UpdateTopicRequest{
Expand Down
4 changes: 2 additions & 2 deletions pubsub/topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ func TestUpdateTopic_SchemaSettings(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if !testutil.Equal(config3.SchemaSettings, settings, opt) {
t.Errorf("\ngot %+v\nwant %+v", config3.SchemaSettings, settings)
if config3.SchemaSettings != nil {
t.Errorf("got: %+v, want nil", config3.SchemaSettings)
}
}

Expand Down

0 comments on commit b53a1bd

Please sign in to comment.