Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.*: fix revive lints redefines-builtin-id #7552

Merged
merged 56 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ed434dc
Fixed linter issues for superfluous-else, increment-decrement, indent…
janardhanvissa Aug 14, 2024
3ea5488
Reverting context-as-argument in server.go
janardhanvissa Aug 14, 2024
7beda74
Merge pull request #1 from janardhanvissa/linter-godoc
janardhanvissa Aug 18, 2024
bd44787
Revert "Optimising the code by fixing var-declaration, indent-error-f…
janardhanvissa Aug 18, 2024
c3dfaaf
Merge pull request #4 from janardhanvissa/revert-1-linter-godoc
janardhanvissa Aug 18, 2024
932ed9f
Merge branch 'grpc:master' into master
janardhanvissa Aug 22, 2024
023be1f
Merge branch 'grpc:master' into master
janardhanvissa Aug 22, 2024
41eb4bc
Fix revive identified linter issues: redefines-builtin-id, empty-block
janardhanvissa Aug 22, 2024
37f7a6b
Merge branch 'grpc:master' into master
janardhanvissa Aug 26, 2024
36b3d83
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhanvissa Aug 26, 2024
38f56db
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhanvissa Aug 27, 2024
fa91ae0
Refactoring the drainchannel in TestGRPCLBStatsQuashEmpty case
janardhanvissa Aug 27, 2024
654124e
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhankrishna-sai Aug 27, 2024
3bc53c5
Removing break statement and adding comments in the for loop
janardhanvissa Aug 27, 2024
b324b08
Updated the comments inside for loop
janardhanvissa Aug 27, 2024
ca55dad
Merge branch 'linter-emtyblk-builtin-id' of https://github.com/janard…
janardhankrishna-sai Aug 28, 2024
091bf41
Merge branch 'linter-emtyblk-builtin-id' of https://github.com/janard…
janardhanvissa Aug 28, 2024
62a2fb5
Updating comments for func keepReading and TestCZGetSocket
janardhanvissa Aug 28, 2024
dfeb468
Merge branch 'grpc:master' into master
janardhanvissa Aug 29, 2024
ba88c1c
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhanvissa Aug 30, 2024
1ad9b77
Updating the redefines-builtin-id fixes
janardhanvissa Aug 30, 2024
e999d13
Reverting the empty-block fix
janardhanvissa Aug 30, 2024
aab2317
re-trigger
janardhanvissa Aug 30, 2024
72a5222
empty-block fix for testing
janardhanvissa Aug 30, 2024
e9f8978
empty-block fix for testing
janardhanvissa Aug 30, 2024
f4a765e
Reverting empty-block fix for testing
janardhanvissa Aug 30, 2024
e15b23d
re-trigger
janardhanvissa Aug 30, 2024
e68df9a
Updating the redefines-builtin-id fixes
janardhanvissa Aug 30, 2024
1a64983
Merge branch 'grpc:master' into master
janardhanvissa Aug 31, 2024
1fe9b8b
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhanvissa Sep 3, 2024
614d7ff
Reverting empty-block fixes
janardhanvissa Sep 3, 2024
aa07ed6
Reverting unused-parameter
janardhanvissa Sep 3, 2024
9d02e35
Resolving merge conflicts and regenerated script
janardhankrishna-sai Sep 4, 2024
a8ad536
Merge branch 'linter-emtyblk-builtin-id' of https://github.com/janard…
janardhankrishna-sai Sep 4, 2024
dd467eb
re-trigger
janardhankrishna-sai Sep 4, 2024
9e18de2
re-trigger for EasyCLA check
janardhankrishna-sai Sep 4, 2024
1a99e43
re-trigger
janardhanvissa Sep 4, 2024
aa96fd0
re-trigger
janardhanvissa Sep 4, 2024
74cc4d0
re-trigger
janardhankrishna-sai Sep 4, 2024
32321cb
re-trigger
janardhankrishna-sai Sep 4, 2024
0899496
Revert "Resolving merge conflicts and regenerated script"
janardhankrishna-sai Sep 5, 2024
c965a4f
revert empty-block fixes
janardhankrishna-sai Sep 5, 2024
161a413
re-trigger
janardhankrishna-sai Sep 5, 2024
fd53abc
re-trigger
janardhankrishna-sai Sep 5, 2024
7465b90
Updating redefined-builtin-id in server_metrics.go file
janardhankrishna-sai Sep 5, 2024
2095550
Updating redefined-builtin-id in server_metrics.go file
janardhankrishna-sai Sep 5, 2024
c6e094d
Revert "Updating redefined-builtin-id in server_metrics.go file"
janardhankrishna-sai Sep 5, 2024
facc6b2
Merge branch 'grpc:master' into master
janardhanvissa Sep 5, 2024
1a5f7a8
Update orca/producer.go
purnesh42H Sep 6, 2024
116e281
closeF->closeFn
purnesh42H Sep 6, 2024
cfa0bf6
Update balancer_wrapper.go, closeF->closeFn
purnesh42H Sep 6, 2024
e5b7b8c
Update xds_resolver.go, closeF -> closeFn
purnesh42H Sep 6, 2024
5d4880c
Update loadreport_test.go, closeF -> closeFn
purnesh42H Sep 6, 2024
97b9e2a
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhankrishna-sai Sep 6, 2024
6f8c09e
Updating redefines-builtin-id fixes
janardhankrishna-sai Sep 6, 2024
b4cf666
Merge branch 'linter-emtyblk-builtin-id' of https://github.com/janard…
janardhankrishna-sai Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions balancer_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ func (acbw *acBalancerWrapper) GetOrBuildProducer(pb balancer.ProducerBuilder) (
pData := acbw.producers[pb]
if pData == nil {
// Not found; create a new one and add it to the producers map.
p, close := pb.Build(acbw)
pData = &refCountedProducer{producer: p, close: close}
p, closeFn := pb.Build(acbw)
pData = &refCountedProducer{producer: p, close: closeFn}
acbw.producers[pb] = pData
}
// Account for this new reference.
Expand Down
4 changes: 2 additions & 2 deletions internal/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ func (s *Status) WithDetails(details ...protoadapt.MessageV1) (*Status, error) {
// s.Code() != OK implies that s.Proto() != nil.
p := s.Proto()
for _, detail := range details {
any, err := anypb.New(protoadapt.MessageV2Of(detail))
m, err := anypb.New(protoadapt.MessageV2Of(detail))
if err != nil {
return nil, err
}
p.Details = append(p.Details, any)
p.Details = append(p.Details, m)
}
return &Status{s: p}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/rbac/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func buildLogger(loggerConfig *v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConf
}

func getCustomConfig(config *anypb.Any) (json.RawMessage, string, error) {
any, err := config.UnmarshalNew()
c, err := config.UnmarshalNew()
if err != nil {
return nil, "", err
}
switch m := any.(type) {
switch m := c.(type) {
case *v1xdsudpatypepb.TypedStruct:
return convertCustomConfig(m.TypeUrl, m.Value)
case *v3xdsxdstypepb.TypedStruct:
Expand Down
4 changes: 2 additions & 2 deletions orca/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type OOBListenerOptions struct {
// returned stop function must be called when no longer needed. Do not
// register a single OOBListener more than once per SubConn.
func RegisterOOBListener(sc balancer.SubConn, l OOBListener, opts OOBListenerOptions) (stop func()) {
pr, close := sc.GetOrBuildProducer(producerBuilderSingleton)
pr, closeFn := sc.GetOrBuildProducer(producerBuilderSingleton)
p := pr.(*producer)

p.registerListener(l, opts.ReportInterval)
Expand All @@ -84,7 +84,7 @@ func RegisterOOBListener(sc balancer.SubConn, l OOBListener, opts OOBListenerOpt
// subsequent calls.
return grpcsync.OnceFunc(func() {
p.unregisterListener(l, opts.ReportInterval)
close()
closeFn()
})
}

Expand Down
4 changes: 2 additions & 2 deletions stats/opentelemetry/server_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (h *serverStatsHandler) unaryInterceptor(ctx context.Context, req any, _ *g
}
ctx = grpc.NewContextWithServerTransportStream(ctx, alts)

any, err := handler(ctx, req)
res, err := handler(ctx, req)
if err != nil { // maybe trailers-only if headers haven't already been sent
if !alts.attachedLabels.Swap(true) {
alts.SetTrailer(alts.metadataExchangeLabels)
Expand All @@ -115,7 +115,7 @@ func (h *serverStatsHandler) unaryInterceptor(ctx context.Context, req any, _ *g
}
}

return any, err
return res, err
}

// attachLabelsStream embeds a grpc.ServerStream, and intercepts the
Expand Down
4 changes: 2 additions & 2 deletions status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ func str(s *Status) string {

// mustMarshalAny converts a protobuf message to an any.
func mustMarshalAny(msg proto.Message) *anypb.Any {
any, err := anypb.New(msg)
m, err := anypb.New(msg)
if err != nil {
panic(fmt.Sprintf("anypb.New(%+v) failed: %v", msg, err))
}
return any
return m
}

func (s) TestFromContextError(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/clusterspecifier/rls/rls.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func (rls) ParseClusterSpecifierConfig(cfg proto.Message) (clusterspecifier.Bala
if cfg == nil {
return nil, fmt.Errorf("rls_csp: nil configuration message provided")
}
any, ok := cfg.(*anypb.Any)
m, ok := cfg.(*anypb.Any)
if !ok {
return nil, fmt.Errorf("rls_csp: error parsing config %v: unknown type %T", cfg, cfg)
}
rlcs := new(rlspb.RouteLookupClusterSpecifier)

if err := any.UnmarshalTo(rlcs); err != nil {
if err := m.UnmarshalTo(rlcs); err != nil {
return nil, fmt.Errorf("rls_csp: error parsing config %v: %v", cfg, err)
}
rlcJSON, err := protojson.Marshal(rlcs.GetRouteLookupConfig())
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/httpfilter/fault/fault.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func parseConfig(cfg proto.Message) (httpfilter.FilterConfig, error) {
if cfg == nil {
return nil, fmt.Errorf("fault: nil configuration message provided")
}
any, ok := cfg.(*anypb.Any)
m, ok := cfg.(*anypb.Any)
if !ok {
return nil, fmt.Errorf("fault: error parsing config %v: unknown type %T", cfg, cfg)
}
msg := new(fpb.HTTPFault)
if err := any.UnmarshalTo(msg); err != nil {
if err := m.UnmarshalTo(msg); err != nil {
return nil, fmt.Errorf("fault: error parsing config %v: %v", cfg, err)
}
return config{config: msg}, nil
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/httpfilter/rbac/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ func (builder) ParseFilterConfig(cfg proto.Message) (httpfilter.FilterConfig, er
if cfg == nil {
return nil, fmt.Errorf("rbac: nil configuration message provided")
}
any, ok := cfg.(*anypb.Any)
m, ok := cfg.(*anypb.Any)
if !ok {
return nil, fmt.Errorf("rbac: error parsing config %v: unknown type %T", cfg, cfg)
}
msg := new(rpb.RBAC)
if err := any.UnmarshalTo(msg); err != nil {
if err := m.UnmarshalTo(msg); err != nil {
return nil, fmt.Errorf("rbac: error parsing config %v: %v", cfg, err)
}
return parseConfig(msg)
Expand All @@ -156,12 +156,12 @@ func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.Fil
if override == nil {
return nil, fmt.Errorf("rbac: nil configuration message provided")
}
any, ok := override.(*anypb.Any)
m, ok := override.(*anypb.Any)
if !ok {
return nil, fmt.Errorf("rbac: error parsing override config %v: unknown type %T", override, override)
}
msg := new(rpb.RBACPerRoute)
if err := any.UnmarshalTo(msg); err != nil {
if err := m.UnmarshalTo(msg); err != nil {
return nil, fmt.Errorf("rbac: error parsing override config %v: %v", override, err)
}
return parseConfig(msg.Rbac)
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/httpfilter/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func (builder) ParseFilterConfig(cfg proto.Message) (httpfilter.FilterConfig, er
if cfg == nil {
return nil, fmt.Errorf("router: nil configuration message provided")
}
any, ok := cfg.(*anypb.Any)
m, ok := cfg.(*anypb.Any)
if !ok {
return nil, fmt.Errorf("router: error parsing config %v: unknown type %T", cfg, cfg)
}
msg := new(pb.Router)
if err := any.UnmarshalTo(msg); err != nil {
if err := m.UnmarshalTo(msg); err != nil {
return nil, fmt.Errorf("router: error parsing config %v: %v", cfg, err)
}
return config{}, nil
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/resolver/xds_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ func (b *xdsResolverBuilder) Build(target resolver.Target, cc resolver.ClientCon
if b.newXDSClient != nil {
newXDSClient = b.newXDSClient
}
client, close, err := newXDSClient(target.String())
client, closeFn, err := newXDSClient(target.String())
if err != nil {
return nil, fmt.Errorf("xds: failed to create xds-client: %v", err)
}
r.xdsClient = client
r.xdsClientClose = close
r.xdsClientClose = closeFn

// Determine the listener resource name and start a watcher for it.
template, err := r.sanityChecksOnBootstrapConfig(target, opts, r.xdsClient)
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/xdsclient/loadreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func (s) TestLRSClient(t *testing.T) {
t.Fatalf("Failed to create server config for testing: %v", err)
}
bc := e2e.DefaultBootstrapContents(t, nodeID, fs1.Address)
xdsC, close, err := NewForTesting(OptionsForTesting{
xdsC, closeFn, err := NewForTesting(OptionsForTesting{
Name: t.Name(),
Contents: bc,
WatchExpiryTimeout: defaultTestWatchExpiryTimeout,
})
if err != nil {
t.Fatalf("Failed to create an xDS client: %v", err)
}
defer close()
defer closeFn()

// Report to the same address should not create new ClientConn.
store1, lrsCancel1 := xdsC.ReportLoad(serverCfg1)
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/xdsclient/xdsresource/filter_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,12 @@ func (fcm *FilterChainManager) filterChainFromProto(fc *v3listenerpb.FilterChain
if name := ts.GetName(); name != transportSocketName {
return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
}
any := ts.GetTypedConfig()
if any == nil || any.TypeUrl != version.V3DownstreamTLSContextURL {
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", any.TypeUrl)
tc := ts.GetTypedConfig()
if tc == nil || tc.TypeUrl != version.V3DownstreamTLSContextURL {
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", tc.TypeUrl)
}
downstreamCtx := &v3tlspb.DownstreamTlsContext{}
if err := proto.Unmarshal(any.GetValue(), downstreamCtx); err != nil {
if err := proto.Unmarshal(tc.GetValue(), downstreamCtx); err != nil {
return nil, fmt.Errorf("failed to unmarshal DownstreamTlsContext in LDS response: %v", err)
}
if downstreamCtx.GetRequireSni().GetValue() {
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/xdsclient/xdsresource/unmarshal_cds.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@
if name := ts.GetName(); name != transportSocketName {
return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
}
any := ts.GetTypedConfig()
if any == nil || any.TypeUrl != version.V3UpstreamTLSContextURL {
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", any.TypeUrl)
tc := ts.GetTypedConfig()
if tc == nil || tc.TypeUrl != version.V3UpstreamTLSContextURL {
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", tc.TypeUrl)

Check warning on line 295 in xds/internal/xdsclient/xdsresource/unmarshal_cds.go

View check run for this annotation

Codecov / codecov/patch

xds/internal/xdsclient/xdsresource/unmarshal_cds.go#L295

Added line #L295 was not covered by tests
}
upstreamCtx := &v3tlspb.UpstreamTlsContext{}
if err := proto.Unmarshal(any.GetValue(), upstreamCtx); err != nil {
if err := proto.Unmarshal(tc.GetValue(), upstreamCtx); err != nil {
return nil, fmt.Errorf("failed to unmarshal UpstreamTlsContext in CDS response: %v", err)
}
// The following fields from `UpstreamTlsContext` are ignored:
Expand Down