Skip to content

Commit 8074f4c

Browse files
author
Ariel Kass
committed
resolving varnamelen linter issues
Signed-off-by: Ariel Kass <[email protected]>
1 parent 4ef9deb commit 8074f4c

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

.github/workflows/config/lint-config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ linters:
3131
- perfsprint
3232
- recvcheck
3333
settings:
34+
varnamelen:
35+
ignore-names:
36+
- pv
37+
- pvc
38+
- vg
39+
- vr
40+
- tc
3441
depguard:
3542
rules:
3643
main:

controllers/parameters.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const (
3737
// replicationclass which are matching the prefix.
3838
func filterPrefixedParameters(prefix string, param map[string]string) map[string]string {
3939
newParam := map[string]string{}
40-
for k, v := range param {
41-
if !strings.HasPrefix(k, prefix) {
42-
newParam[k] = v
40+
for key, val := range param {
41+
if !strings.HasPrefix(key, prefix) {
42+
newParam[key] = val
4343
}
4444
}
4545

@@ -49,21 +49,21 @@ func filterPrefixedParameters(prefix string, param map[string]string) map[string
4949
// validatePrefixParameters checks for unknown reserved keys in parameters and
5050
// empty values for reserved keys.
5151
func validatePrefixedParameters(param map[string]string) error {
52-
for k, v := range param {
53-
if strings.HasPrefix(k, replicationParameterPrefix) {
54-
switch k {
52+
for key, val := range param {
53+
if strings.HasPrefix(key, replicationParameterPrefix) {
54+
switch key {
5555
case prefixedReplicationSecretNameKey:
56-
if v == "" {
56+
if val == "" {
5757
return errors.New("secret name cannot be empty")
5858
}
5959
case prefixedReplicationSecretNamespaceKey:
60-
if v == "" {
60+
if val == "" {
6161
return errors.New("secret namespace cannot be empty")
6262
}
6363
// keep adding known prefixes to this list.
6464
default:
6565

66-
return fmt.Errorf("found unknown parameter key %q with reserved prefix %s", k, replicationParameterPrefix)
66+
return fmt.Errorf("found unknown parameter key %q with reserved prefix %s", key, replicationParameterPrefix)
6767
}
6868
}
6969
}

controllers/replication/replication.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ func (r *Response) HasKnownGRPCError(knownErrors []codes.Code) bool {
106106
return false
107107
}
108108

109-
s, ok := status.FromError(r.Error)
109+
grpcStatus, ok := status.FromError(r.Error)
110110
if !ok {
111111
// This is not gRPC error. The operation must have failed before gRPC
112112
// method was called, otherwise we would get gRPC error.
113113
return false
114114
}
115115

116116
for _, e := range knownErrors {
117-
if s.Code() == e {
117+
if grpcStatus.Code() == e {
118118
return true
119119
}
120120
}
@@ -124,12 +124,12 @@ func (r *Response) HasKnownGRPCError(knownErrors []codes.Code) bool {
124124

125125
// GetMessageFromError returns the message from the error.
126126
func GetMessageFromError(err error) string {
127-
s, ok := status.FromError(err)
127+
grpcStatus, ok := status.FromError(err)
128128
if !ok {
129129
// This is not gRPC error. The operation must have failed before gRPC
130130
// method was called, otherwise we would get gRPC error.
131131
return err.Error()
132132
}
133133

134-
return s.Message()
134+
return grpcStatus.Message()
135135
}

controllers/volumereplication_controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,19 +409,19 @@ func (r *VolumeReplicationReconciler) SetupWithManager(mgr ctrl.Manager, cfg *co
409409
pred := predicate.GenerationChangedPredicate{}
410410

411411
r.DriverConfig = cfg
412-
c, err := grpcClient.New(cfg.DriverEndpoint, cfg.RPCTimeout)
412+
grpcClient, err := grpcClient.New(cfg.DriverEndpoint, cfg.RPCTimeout)
413413
if err != nil {
414414
r.Log.Error(err, "failed to create GRPC Client", "Endpoint", cfg.DriverEndpoint, "GRPC Timeout", cfg.RPCTimeout)
415415

416416
return err
417417
}
418-
err = c.Probe()
418+
err = grpcClient.Probe()
419419
if err != nil {
420420
r.Log.Error(err, "failed to connect to driver", "Endpoint", cfg.DriverEndpoint, "GRPC Timeout", cfg.RPCTimeout)
421421

422422
return err
423423
}
424-
r.GRPCClient = c
424+
r.GRPCClient = grpcClient
425425
r.Replication = grpcClient.NewReplicationClient(r.GRPCClient.Client, cfg.RPCTimeout)
426426

427427
return ctrl.NewControllerManagedBy(mgr).
@@ -616,7 +616,7 @@ func (r *VolumeReplicationReconciler) resyncVolume(volumeReplicationObject *repl
616616
func (r *VolumeReplicationReconciler) disableVolumeReplication(logger logr.Logger, replicationSource *replicationlib.ReplicationSource, replicationID string,
617617
parameters, secrets map[string]string,
618618
) error {
619-
c := replication.CommonRequestParameters{
619+
params := replication.CommonRequestParameters{
620620
ReplicationSource: replicationSource,
621621
ReplicationID: replicationID,
622622
Parameters: parameters,
@@ -625,7 +625,7 @@ func (r *VolumeReplicationReconciler) disableVolumeReplication(logger logr.Logge
625625
}
626626

627627
volumeReplication := replication.Replication{
628-
Params: c,
628+
Params: params,
629629
}
630630

631631
resp := volumeReplication.Disable()
@@ -648,7 +648,7 @@ func (r *VolumeReplicationReconciler) disableVolumeReplication(logger logr.Logge
648648
func (r *VolumeReplicationReconciler) enableReplication(logger logr.Logger, replicationSource *replicationlib.ReplicationSource, replicationID string,
649649
parameters, secrets map[string]string,
650650
) error {
651-
c := replication.CommonRequestParameters{
651+
params := replication.CommonRequestParameters{
652652
ReplicationSource: replicationSource,
653653
ReplicationID: replicationID,
654654
Parameters: parameters,
@@ -657,7 +657,7 @@ func (r *VolumeReplicationReconciler) enableReplication(logger logr.Logger, repl
657657
}
658658

659659
volumeReplication := replication.Replication{
660-
Params: c,
660+
Params: params,
661661
}
662662

663663
resp := volumeReplication.Enable()

0 commit comments

Comments
 (0)