Skip to content

Commit 3ffb98b

Browse files
janardhanvissajanardhankrishna-saipurnesh42Harvindbr8
authored
.*: fix revive lints redefines-builtin-id (#7552)
* Fix revive identified linter issues: redefines-builtin-id --------- Co-authored-by: Vissa Janardhan Krishna Sai <[email protected]> Co-authored-by: Purnesh Dixit <[email protected]> Co-authored-by: Arvind Bright <[email protected]>
1 parent 5666049 commit 3ffb98b

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

balancer_wrapper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ func (acbw *acBalancerWrapper) GetOrBuildProducer(pb balancer.ProducerBuilder) (
342342
pData := acbw.producers[pb]
343343
if pData == nil {
344344
// Not found; create a new one and add it to the producers map.
345-
p, close := pb.Build(acbw)
346-
pData = &refCountedProducer{producer: p, close: close}
345+
p, closeFn := pb.Build(acbw)
346+
pData = &refCountedProducer{producer: p, close: closeFn}
347347
acbw.producers[pb] = pData
348348
}
349349
// Account for this new reference.

internal/status/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ func (s *Status) WithDetails(details ...protoadapt.MessageV1) (*Status, error) {
138138
// s.Code() != OK implies that s.Proto() != nil.
139139
p := s.Proto()
140140
for _, detail := range details {
141-
any, err := anypb.New(protoadapt.MessageV2Of(detail))
141+
m, err := anypb.New(protoadapt.MessageV2Of(detail))
142142
if err != nil {
143143
return nil, err
144144
}
145-
p.Details = append(p.Details, any)
145+
p.Details = append(p.Details, m)
146146
}
147147
return &Status{s: p}, nil
148148
}

internal/xds/rbac/converter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ func buildLogger(loggerConfig *v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConf
5959
}
6060

6161
func getCustomConfig(config *anypb.Any) (json.RawMessage, string, error) {
62-
any, err := config.UnmarshalNew()
62+
c, err := config.UnmarshalNew()
6363
if err != nil {
6464
return nil, "", err
6565
}
66-
switch m := any.(type) {
66+
switch m := c.(type) {
6767
case *v1xdsudpatypepb.TypedStruct:
6868
return convertCustomConfig(m.TypeUrl, m.Value)
6969
case *v3xdsxdstypepb.TypedStruct:

orca/producer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type OOBListenerOptions struct {
7272
// returned stop function must be called when no longer needed. Do not
7373
// register a single OOBListener more than once per SubConn.
7474
func RegisterOOBListener(sc balancer.SubConn, l OOBListener, opts OOBListenerOptions) (stop func()) {
75-
pr, close := sc.GetOrBuildProducer(producerBuilderSingleton)
75+
pr, closeFn := sc.GetOrBuildProducer(producerBuilderSingleton)
7676
p := pr.(*producer)
7777

7878
p.registerListener(l, opts.ReportInterval)
@@ -84,7 +84,7 @@ func RegisterOOBListener(sc balancer.SubConn, l OOBListener, opts OOBListenerOpt
8484
// subsequent calls.
8585
return grpcsync.OnceFunc(func() {
8686
p.unregisterListener(l, opts.ReportInterval)
87-
close()
87+
closeFn()
8888
})
8989
}
9090

stats/opentelemetry/server_metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (h *serverStatsHandler) unaryInterceptor(ctx context.Context, req any, _ *g
104104
}
105105
ctx = grpc.NewContextWithServerTransportStream(ctx, alts)
106106

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

118-
return any, err
118+
return res, err
119119
}
120120

121121
// attachLabelsStream embeds a grpc.ServerStream, and intercepts the

status/status_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,11 @@ func str(s *Status) string {
451451

452452
// mustMarshalAny converts a protobuf message to an any.
453453
func mustMarshalAny(msg proto.Message) *anypb.Any {
454-
any, err := anypb.New(msg)
454+
m, err := anypb.New(msg)
455455
if err != nil {
456456
panic(fmt.Sprintf("anypb.New(%+v) failed: %v", msg, err))
457457
}
458-
return any
458+
return m
459459
}
460460

461461
func (s) TestFromContextError(t *testing.T) {

xds/internal/clusterspecifier/rls/rls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ func (rls) ParseClusterSpecifierConfig(cfg proto.Message) (clusterspecifier.Bala
6565
if cfg == nil {
6666
return nil, fmt.Errorf("rls_csp: nil configuration message provided")
6767
}
68-
any, ok := cfg.(*anypb.Any)
68+
m, ok := cfg.(*anypb.Any)
6969
if !ok {
7070
return nil, fmt.Errorf("rls_csp: error parsing config %v: unknown type %T", cfg, cfg)
7171
}
7272
rlcs := new(rlspb.RouteLookupClusterSpecifier)
7373

74-
if err := any.UnmarshalTo(rlcs); err != nil {
74+
if err := m.UnmarshalTo(rlcs); err != nil {
7575
return nil, fmt.Errorf("rls_csp: error parsing config %v: %v", cfg, err)
7676
}
7777
rlcJSON, err := protojson.Marshal(rlcs.GetRouteLookupConfig())

xds/internal/httpfilter/fault/fault.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ func parseConfig(cfg proto.Message) (httpfilter.FilterConfig, error) {
8181
if cfg == nil {
8282
return nil, fmt.Errorf("fault: nil configuration message provided")
8383
}
84-
any, ok := cfg.(*anypb.Any)
84+
m, ok := cfg.(*anypb.Any)
8585
if !ok {
8686
return nil, fmt.Errorf("fault: error parsing config %v: unknown type %T", cfg, cfg)
8787
}
8888
msg := new(fpb.HTTPFault)
89-
if err := any.UnmarshalTo(msg); err != nil {
89+
if err := m.UnmarshalTo(msg); err != nil {
9090
return nil, fmt.Errorf("fault: error parsing config %v: %v", cfg, err)
9191
}
9292
return config{config: msg}, nil

xds/internal/httpfilter/rbac/rbac.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ func (builder) ParseFilterConfig(cfg proto.Message) (httpfilter.FilterConfig, er
141141
if cfg == nil {
142142
return nil, fmt.Errorf("rbac: nil configuration message provided")
143143
}
144-
any, ok := cfg.(*anypb.Any)
144+
m, ok := cfg.(*anypb.Any)
145145
if !ok {
146146
return nil, fmt.Errorf("rbac: error parsing config %v: unknown type %T", cfg, cfg)
147147
}
148148
msg := new(rpb.RBAC)
149-
if err := any.UnmarshalTo(msg); err != nil {
149+
if err := m.UnmarshalTo(msg); err != nil {
150150
return nil, fmt.Errorf("rbac: error parsing config %v: %v", cfg, err)
151151
}
152152
return parseConfig(msg)
@@ -156,12 +156,12 @@ func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.Fil
156156
if override == nil {
157157
return nil, fmt.Errorf("rbac: nil configuration message provided")
158158
}
159-
any, ok := override.(*anypb.Any)
159+
m, ok := override.(*anypb.Any)
160160
if !ok {
161161
return nil, fmt.Errorf("rbac: error parsing override config %v: unknown type %T", override, override)
162162
}
163163
msg := new(rpb.RBACPerRoute)
164-
if err := any.UnmarshalTo(msg); err != nil {
164+
if err := m.UnmarshalTo(msg); err != nil {
165165
return nil, fmt.Errorf("rbac: error parsing override config %v: %v", override, err)
166166
}
167167
return parseConfig(msg.Rbac)

xds/internal/httpfilter/router/router.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ func (builder) ParseFilterConfig(cfg proto.Message) (httpfilter.FilterConfig, er
5454
if cfg == nil {
5555
return nil, fmt.Errorf("router: nil configuration message provided")
5656
}
57-
any, ok := cfg.(*anypb.Any)
57+
m, ok := cfg.(*anypb.Any)
5858
if !ok {
5959
return nil, fmt.Errorf("router: error parsing config %v: unknown type %T", cfg, cfg)
6060
}
6161
msg := new(pb.Router)
62-
if err := any.UnmarshalTo(msg); err != nil {
62+
if err := m.UnmarshalTo(msg); err != nil {
6363
return nil, fmt.Errorf("router: error parsing config %v: %v", cfg, err)
6464
}
6565
return config{}, nil

xds/internal/resolver/xds_resolver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ func (b *xdsResolverBuilder) Build(target resolver.Target, cc resolver.ClientCon
101101
if b.newXDSClient != nil {
102102
newXDSClient = b.newXDSClient
103103
}
104-
client, close, err := newXDSClient(target.String())
104+
client, closeFn, err := newXDSClient(target.String())
105105
if err != nil {
106106
return nil, fmt.Errorf("xds: failed to create xds-client: %v", err)
107107
}
108108
r.xdsClient = client
109-
r.xdsClientClose = close
109+
r.xdsClientClose = closeFn
110110

111111
// Determine the listener resource name and start a watcher for it.
112112
template, err := r.sanityChecksOnBootstrapConfig(target, opts, r.xdsClient)

xds/internal/xdsclient/loadreport_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ func (s) TestLRSClient(t *testing.T) {
4949
t.Fatalf("Failed to create server config for testing: %v", err)
5050
}
5151
bc := e2e.DefaultBootstrapContents(t, nodeID, fs1.Address)
52-
xdsC, close, err := NewForTesting(OptionsForTesting{
52+
xdsC, closeFn, err := NewForTesting(OptionsForTesting{
5353
Name: t.Name(),
5454
Contents: bc,
5555
WatchExpiryTimeout: defaultTestWatchExpiryTimeout,
5656
})
5757
if err != nil {
5858
t.Fatalf("Failed to create an xDS client: %v", err)
5959
}
60-
defer close()
60+
defer closeFn()
6161

6262
// Report to the same address should not create new ClientConn.
6363
store1, lrsCancel1 := xdsC.ReportLoad(serverCfg1)

xds/internal/xdsclient/xdsresource/filter_chain.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,12 @@ func (fcm *FilterChainManager) filterChainFromProto(fc *v3listenerpb.FilterChain
536536
if name := ts.GetName(); name != transportSocketName {
537537
return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
538538
}
539-
any := ts.GetTypedConfig()
540-
if any == nil || any.TypeUrl != version.V3DownstreamTLSContextURL {
541-
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", any.TypeUrl)
539+
tc := ts.GetTypedConfig()
540+
if tc == nil || tc.TypeUrl != version.V3DownstreamTLSContextURL {
541+
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", tc.TypeUrl)
542542
}
543543
downstreamCtx := &v3tlspb.DownstreamTlsContext{}
544-
if err := proto.Unmarshal(any.GetValue(), downstreamCtx); err != nil {
544+
if err := proto.Unmarshal(tc.GetValue(), downstreamCtx); err != nil {
545545
return nil, fmt.Errorf("failed to unmarshal DownstreamTlsContext in LDS response: %v", err)
546546
}
547547
if downstreamCtx.GetRequireSni().GetValue() {

xds/internal/xdsclient/xdsresource/unmarshal_cds.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ func securityConfigFromCluster(cluster *v3clusterpb.Cluster) (*SecurityConfig, e
290290
if name := ts.GetName(); name != transportSocketName {
291291
return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
292292
}
293-
any := ts.GetTypedConfig()
294-
if any == nil || any.TypeUrl != version.V3UpstreamTLSContextURL {
295-
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", any.TypeUrl)
293+
tc := ts.GetTypedConfig()
294+
if tc == nil || tc.TypeUrl != version.V3UpstreamTLSContextURL {
295+
return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", tc.TypeUrl)
296296
}
297297
upstreamCtx := &v3tlspb.UpstreamTlsContext{}
298-
if err := proto.Unmarshal(any.GetValue(), upstreamCtx); err != nil {
298+
if err := proto.Unmarshal(tc.GetValue(), upstreamCtx); err != nil {
299299
return nil, fmt.Errorf("failed to unmarshal UpstreamTlsContext in CDS response: %v", err)
300300
}
301301
// The following fields from `UpstreamTlsContext` are ignored:

0 commit comments

Comments
 (0)