Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 9c14a8e

Browse files
Madhu-1mergify[bot]
authored andcommitted
ci: fix found linter issues
fix all the inter issues for in the repo. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
1 parent 19529a7 commit 9c14a8e

20 files changed

Lines changed: 237 additions & 125 deletions

api/v1alpha1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
)
2626

2727
var (
28-
// GroupVersion is group version used to register these objects
28+
// GroupVersion is group version used to register these objects.
2929
GroupVersion = schema.GroupVersion{Group: "replication.storage.openshift.io", Version: "v1alpha1"}
3030

31-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3333

3434
// AddToScheme adds the types in this group-version to the given scheme.

api/v1alpha1/volumereplication_types.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ import (
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
)
2323

24-
// ReplicationState represents the replication operations to be performed on the volume
24+
// ReplicationState represents the replication operations to be performed on the volume.
2525
// +kubebuilder:validation:Enum=primary;secondary;resync
2626
type ReplicationState string
2727

2828
const (
29-
// Primary ReplicationState enables mirroring and promotes the volume to primary
29+
// Primary ReplicationState enables mirroring and promotes the volume to primary.
3030
Primary ReplicationState = "primary"
3131

32-
// Secondary ReplicationState demotes the volume to secondary and resyncs the volume if out of sync
32+
// Secondary ReplicationState demotes the volume to secondary and resyncs the volume if out of sync.
3333
Secondary ReplicationState = "secondary"
3434

35-
// Resync option resyncs the volume
35+
// Resync option resyncs the volume.
3636
Resync ReplicationState = "resync"
3737
)
3838

39-
// State captures the latest state of the replication operation
39+
// State captures the latest state of the replication operation.
4040
type State string
4141

4242
const (
43-
// PrimaryState represents the Primary replication state
43+
// PrimaryState represents the Primary replication state.
4444
PrimaryState State = "Primary"
4545

46-
// SecondaryState represents the Secondary replication state
46+
// SecondaryState represents the Secondary replication state.
4747
SecondaryState State = "Secondary"
4848

49-
// UnknownState represents the Unknown replication state
49+
// UnknownState represents the Unknown replication state.
5050
UnknownState State = "Unknown"
5151
)
5252

53-
// VolumeReplicationSpec defines the desired state of VolumeReplication
53+
// VolumeReplicationSpec defines the desired state of VolumeReplication.
5454
type VolumeReplicationSpec struct {
5555
// VolumeReplicationClass is the VolumeReplicationClass name for this VolumeReplication resource
5656
// +kubebuilder:validation:Required
@@ -70,7 +70,7 @@ type VolumeReplicationSpec struct {
7070
ReplicationHandle string `json:"replicationHandle"`
7171
}
7272

73-
// VolumeReplicationStatus defines the observed state of VolumeReplication
73+
// VolumeReplicationStatus defines the observed state of VolumeReplication.
7474
type VolumeReplicationStatus struct {
7575
State State `json:"state,omitempty"`
7676
Message string `json:"message,omitempty"`
@@ -92,7 +92,7 @@ type VolumeReplicationStatus struct {
9292
// +kubebuilder:printcolumn:JSONPath=".status.state",name=currentState,type=string
9393
// +kubebuilder:resource:shortName=vr
9494

95-
// VolumeReplication is the Schema for the volumereplications API
95+
// VolumeReplication is the Schema for the volumereplications API.
9696
type VolumeReplication struct {
9797
metav1.TypeMeta `json:",inline"`
9898
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -103,7 +103,7 @@ type VolumeReplication struct {
103103

104104
// +kubebuilder:object:root=true
105105

106-
// VolumeReplicationList contains a list of VolumeReplication
106+
// VolumeReplicationList contains a list of VolumeReplication.
107107
type VolumeReplicationList struct {
108108
metav1.TypeMeta `json:",inline"`
109109
metav1.ListMeta `json:"metadata,omitempty"`

api/v1alpha1/volumereplicationclass_types.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ type VolumeReplicationClassSpec struct {
3333
Parameters map[string]string `json:"parameters,omitempty"`
3434
}
3535

36-
// VolumeReplicationClassStatus defines the observed state of VolumeReplicationClass
37-
type VolumeReplicationClassStatus struct {
38-
}
36+
// VolumeReplicationClassStatus defines the observed state of VolumeReplicationClass.
37+
type VolumeReplicationClassStatus struct{}
3938

4039
// +kubebuilder:object:root=true
4140
// +kubebuilder:subresource:status
4241
// +kubebuilder:resource:scope=Cluster,shortName=vrc
4342
// +kubebuilder:printcolumn:JSONPath=".spec.provisioner",name=provisioner,type=string
4443

45-
// VolumeReplicationClass is the Schema for the volumereplicationclasses API
44+
// VolumeReplicationClass is the Schema for the volumereplicationclasses API.
4645
type VolumeReplicationClass struct {
4746
metav1.TypeMeta `json:",inline"`
4847
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -53,7 +52,7 @@ type VolumeReplicationClass struct {
5352

5453
// +kubebuilder:object:root=true
5554

56-
// VolumeReplicationClassList contains a list of VolumeReplicationClass
55+
// VolumeReplicationClassList contains a list of VolumeReplicationClass.
5756
type VolumeReplicationClassList struct {
5857
metav1.TypeMeta `json:",inline"`
5958
metav1.ListMeta `json:"metadata,omitempty"`

controllers/parameters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ func validatePrefixedParameters(param map[string]string) error {
6767
}
6868
}
6969
}
70+
7071
return nil
7172
}

controllers/pvc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (r VolumeReplicationReconciler) getPVCDataSource(logger logr.Logger, req ty
3434
if errors.IsNotFound(err) {
3535
logger.Error(err, "PVC not found", "PVC Name", req.Name)
3636
}
37+
3738
return nil, nil, err
3839
}
3940
// Validate PVC in bound state

controllers/pvc_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import (
2121

2222
replicationv1alpha1 "github.com/csi-addons/volume-replication-operator/api/v1alpha1"
2323
"github.com/csi-addons/volume-replication-operator/pkg/config"
24+
2425
"github.com/stretchr/testify/assert"
2526
corev1 "k8s.io/api/core/v1"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728
"k8s.io/apimachinery/pkg/runtime"
2829
"k8s.io/apimachinery/pkg/types"
29-
logf "sigs.k8s.io/controller-runtime/pkg/log"
30-
3130
"sigs.k8s.io/controller-runtime/pkg/client/fake"
31+
logf "sigs.k8s.io/controller-runtime/pkg/log"
3232
)
3333

3434
const (
@@ -78,6 +78,7 @@ var mockPersistentVolumeClaim = &corev1.PersistentVolumeClaim{
7878
}
7979

8080
func createFakeScheme(t *testing.T) *runtime.Scheme {
81+
t.Helper()
8182
scheme, err := replicationv1alpha1.SchemeBuilder.Build()
8283
if err != nil {
8384
assert.Fail(t, "unable to build scheme")
@@ -90,10 +91,12 @@ func createFakeScheme(t *testing.T) *runtime.Scheme {
9091
if err != nil {
9192
assert.Fail(t, "failed to add replicationv1alpha1 scheme")
9293
}
94+
9395
return scheme
9496
}
9597

9698
func createFakeVolumeReplicationReconciler(t *testing.T, obj ...runtime.Object) VolumeReplicationReconciler {
99+
t.Helper()
97100
scheme := createFakeScheme(t)
98101
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(obj...).Build()
99102

@@ -106,6 +109,7 @@ func createFakeVolumeReplicationReconciler(t *testing.T, obj ...runtime.Object)
106109
}
107110

108111
func TestGetVolumeHandle(t *testing.T) {
112+
t.Parallel()
109113
testcases := []struct {
110114
name string
111115
pv *corev1.PersistentVolume
@@ -156,8 +160,10 @@ func TestGetVolumeHandle(t *testing.T) {
156160
testPVC := &corev1.PersistentVolumeClaim{}
157161
tc.pvc.DeepCopyInto(testPVC)
158162

159-
namespacedName := types.NamespacedName{Name: mockPVCName,
160-
Namespace: volumeReplication.Namespace}
163+
namespacedName := types.NamespacedName{
164+
Name: mockPVCName,
165+
Namespace: volumeReplication.Namespace,
166+
}
161167

162168
reconciler := createFakeVolumeReplicationReconciler(t, testPV, testPVC, volumeReplication)
163169
resultPVC, resultPV, err := reconciler.getPVCDataSource(reconciler.Log, namespacedName)

controllers/replication/replication.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323
"google.golang.org/grpc/status"
2424
)
2525

26-
// Replication represents the instance of a single replication operation
26+
// Replication represents the instance of a single replication operation.
2727
type Replication struct {
2828
Params CommonRequestParameters
2929
Force bool
3030
}
3131

32-
// ReplicationResponse is the response of a replication operation
33-
type ReplicationResponse struct {
32+
// Response is the response of a replication operation.
33+
type Response struct {
3434
Response interface{}
3535
Error error
3636
}
@@ -44,29 +44,29 @@ type CommonRequestParameters struct {
4444
Replication client.VolumeReplication
4545
}
4646

47-
func (r *Replication) Enable() *ReplicationResponse {
47+
func (r *Replication) Enable() *Response {
4848
resp, err := r.Params.Replication.EnableVolumeReplication(
4949
r.Params.VolumeID,
5050
r.Params.ReplicationID,
5151
r.Params.Secrets,
5252
r.Params.Parameters,
5353
)
5454

55-
return &ReplicationResponse{Response: resp, Error: err}
55+
return &Response{Response: resp, Error: err}
5656
}
5757

58-
func (r *Replication) Disable() *ReplicationResponse {
58+
func (r *Replication) Disable() *Response {
5959
resp, err := r.Params.Replication.DisableVolumeReplication(
6060
r.Params.VolumeID,
6161
r.Params.ReplicationID,
6262
r.Params.Secrets,
6363
r.Params.Parameters,
6464
)
6565

66-
return &ReplicationResponse{Response: resp, Error: err}
66+
return &Response{Response: resp, Error: err}
6767
}
6868

69-
func (r *Replication) Promote() *ReplicationResponse {
69+
func (r *Replication) Promote() *Response {
7070
resp, err := r.Params.Replication.PromoteVolume(
7171
r.Params.VolumeID,
7272
r.Params.ReplicationID,
@@ -75,32 +75,32 @@ func (r *Replication) Promote() *ReplicationResponse {
7575
r.Params.Parameters,
7676
)
7777

78-
return &ReplicationResponse{Response: resp, Error: err}
78+
return &Response{Response: resp, Error: err}
7979
}
8080

81-
func (r *Replication) Demote() *ReplicationResponse {
81+
func (r *Replication) Demote() *Response {
8282
resp, err := r.Params.Replication.DemoteVolume(
8383
r.Params.VolumeID,
8484
r.Params.ReplicationID,
8585
r.Params.Secrets,
8686
r.Params.Parameters,
8787
)
8888

89-
return &ReplicationResponse{Response: resp, Error: err}
89+
return &Response{Response: resp, Error: err}
9090
}
9191

92-
func (r *Replication) Resync() *ReplicationResponse {
92+
func (r *Replication) Resync() *Response {
9393
resp, err := r.Params.Replication.ResyncVolume(
9494
r.Params.VolumeID,
9595
r.Params.ReplicationID,
9696
r.Params.Secrets,
9797
r.Params.Parameters,
9898
)
9999

100-
return &ReplicationResponse{Response: resp, Error: err}
100+
return &Response{Response: resp, Error: err}
101101
}
102102

103-
func (r *ReplicationResponse) HasKnownGRPCError(knownErrors []codes.Code) bool {
103+
func (r *Response) HasKnownGRPCError(knownErrors []codes.Code) bool {
104104
if r.Error == nil {
105105
return false
106106
}

controllers/replication/replication_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
)
2626

2727
func TestGetMessageFromError(t *testing.T) {
28+
t.Parallel()
2829
tests := []struct {
2930
name string
3031
err error
@@ -47,9 +48,11 @@ func TestGetMessageFromError(t *testing.T) {
4748
},
4849
}
4950
for _, tt := range tests {
50-
t.Run(tt.name, func(t *testing.T) {
51-
if got := GetMessageFromError(tt.err); got != tt.want {
52-
t.Errorf("GetMessageFromError() = %v, want %v", got, tt.want)
51+
newtt := tt
52+
t.Run(newtt.name, func(t *testing.T) {
53+
t.Parallel()
54+
if got := GetMessageFromError(newtt.err); got != newtt.want {
55+
t.Errorf("GetMessageFromError() = %v, want %v", got, newtt.want)
5356
}
5457
})
5558
}

0 commit comments

Comments
 (0)