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

Enable new linters #1162

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 7 additions & 14 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ linters-settings:
- name: duplicated-imports
- name: unhandled-error
# - name: flag-parameter
# - name: unused-receiver
# - name: unused-parameter
# - name: confusing-naming
# - name: import-shadowing
# - name: confusing-results
# - name: bool-literal-in-expr
- name: unused-receiver
- name: unused-parameter
- name: confusing-naming
- name: import-shadowing
- name: confusing-results
- name: bool-literal-in-expr

issues:
exclude-rules:
Expand All @@ -99,7 +99,6 @@ linters:
- bidichk
- bodyclose
- cyclop
- deadcode
- decorder
# - depguard
- dogsled
Expand All @@ -119,23 +118,20 @@ linters:
- gocyclo
- gofmt
- gofumpt
- golint
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- interfacebloat
- lll
- logrlint
- maintidx
- makezero
- maligned
- misspell
# - nakedret
- nestif
Expand All @@ -149,9 +145,7 @@ linters:
- reassign
- revive
- rowserrcheck
- scopelint
- sqlclosecheck
- structcheck
- stylecheck
- tenv
- testpackage
Expand All @@ -162,7 +156,6 @@ linters:
- unparam
- unused
- usestdlibvars
- varcheck
# - wastedassign
- whitespace
- wsl
Expand Down Expand Up @@ -191,4 +184,4 @@ linters:
# - forcetypeassert
# - promlinter
# - contextcheck
# - errname
- errname
6 changes: 3 additions & 3 deletions controllers/drcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (r *DRClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
}

func (r *DRClusterReconciler) drClusterConfigMapMapFunc(
ctx context.Context, configMap client.Object,
_ context.Context, configMap client.Object,
) []reconcile.Request {
if configMap.GetName() != HubOperatorConfigMapName || configMap.GetNamespace() != NamespaceName() {
return []reconcile.Request{}
Expand All @@ -149,7 +149,7 @@ func (r *DRClusterReconciler) drClusterConfigMapMapFunc(
return requests
}

func (r *DRClusterReconciler) drClusterSecretMapFunc(ctx context.Context, secret client.Object) []reconcile.Request {
func (r *DRClusterReconciler) drClusterSecretMapFunc(_ context.Context, secret client.Object) []reconcile.Request {
if secret.GetNamespace() != NamespaceName() {
return []reconcile.Request{}
}
Expand Down Expand Up @@ -476,7 +476,7 @@ func validateCIDRsFormat(drcluster *ramen.DRCluster, log logr.Logger) error {
return nil
}

func (r DRClusterReconciler) processDeletion(u *drclusterInstance) (ctrl.Result, error) {
func (DRClusterReconciler) processDeletion(u *drclusterInstance) (ctrl.Result, error) {
u.log.Info("delete")

// Undeploy manifests
Expand Down
8 changes: 4 additions & 4 deletions controllers/drcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var baseNF = &csiaddonsv1alpha1.NetworkFence{
},
}

func (f FakeMCVGetter) GetNFFromManagedCluster(resourceName, resourceNamespace, managedCluster string,
annotations map[string]string,
func (FakeMCVGetter) GetNFFromManagedCluster(_, _, _ string,
_ map[string]string,
) (*csiaddonsv1alpha1.NetworkFence, error) {
nfStatus := csiaddonsv1alpha1.NetworkFenceStatus{
Result: csiaddonsv1alpha1.FencingOperationResultSucceeded,
Expand All @@ -56,8 +56,8 @@ func (f FakeMCVGetter) GetNFFromManagedCluster(resourceName, resourceNamespace,
return nf, nil
}

func (f FakeMCVGetter) DeleteNFManagedClusterView(
resourceName, resourceNamespace, clusterName, resourceType string,
func (FakeMCVGetter) DeleteNFManagedClusterView(
_, _, _, _ string,
) error {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/drcluster_mmode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var _ = Describe("DRClusterMModeTests", Ordered, func() {
},
}

if testEnv.UseExistingCluster != nil && *testEnv.UseExistingCluster == true {
if testEnv.UseExistingCluster != nil && *testEnv.UseExistingCluster {
namespaceDeletionSupported = true
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/drpc_predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ var _ = Describe("DRPCPredicateDRCluster", func() {
},
}

if testEnv.UseExistingCluster != nil && *testEnv.UseExistingCluster == true {
if testEnv.UseExistingCluster != nil && *testEnv.UseExistingCluster {
namespaceDeletionSupported = true
}

Expand Down
23 changes: 9 additions & 14 deletions controllers/drplacementcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ const (
)

var (
WaitForAppResourceRestoreToComplete error = errorswrapper.New("Waiting for App resources to be restored...")
WaitForVolSyncDestRepToComplete error = errorswrapper.New("Waiting for VolSync RD to complete...")
WaitForSourceCluster error = errorswrapper.New("Waiting for primary to provide Protected PVCs...")
WaitForVolSyncManifestWorkCreation error = errorswrapper.New("Waiting for VolSync ManifestWork to be created...")
WaitForVolSyncRDInfoAvailibility error = errorswrapper.New("Waiting for VolSync RDInfo...")
ErrWaitForAppResourceRestoreToComplete error = errorswrapper.New("Waiting for App resources to be restored...")
ErrWaitForSourceCluster error = errorswrapper.New("Waiting for primary to provide Protected PVCs...")
ErrWaitForVolSyncManifestWorkCreation error = errorswrapper.New("Waiting for VolSync ManifestWork to be created...")
)

type DRPCInstance struct {
Expand Down Expand Up @@ -182,11 +180,8 @@ func (d *DRPCInstance) RunInitialDeployment() (bool, error) {
return done, nil
}

func (d *DRPCInstance) getHomeClusterForInitialDeploy() (string, string) {
func (d *DRPCInstance) getHomeClusterForInitialDeploy() (homeCluster string, homeClusterNamespace string) {
// Check if the user wants to use the preferredCluster
homeCluster := ""
homeClusterNamespace := ""

if d.instance.Spec.PreferredCluster != "" {
homeCluster = d.instance.Spec.PreferredCluster
homeClusterNamespace = d.instance.Spec.PreferredCluster
Expand Down Expand Up @@ -1189,7 +1184,7 @@ func (d *DRPCInstance) switchToCluster(targetCluster, targetClusterNamespace str
d.setProgression(rmn.ProgressionWaitingForResourceRestore)

// We just created MWs. Give it time until the App resources have been restored
return fmt.Errorf("%w)", WaitForAppResourceRestoreToComplete)
return fmt.Errorf("%w)", ErrWaitForAppResourceRestoreToComplete)
}

vrg, restored, err := d.ensureClusterDataRestored(targetCluster)
Expand All @@ -1207,7 +1202,7 @@ func (d *DRPCInstance) switchToCluster(targetCluster, targetClusterNamespace str
if !restored || vrg.Status.State != rmn.PrimaryState {
d.setProgression(rmn.ProgressionWaitingForResourceRestore)

return fmt.Errorf("%w)", WaitForAppResourceRestoreToComplete)
return fmt.Errorf("%w)", ErrWaitForAppResourceRestoreToComplete)
}

err = d.updateUserPlacementRule(targetCluster, targetClusterNamespace)
Expand Down Expand Up @@ -1261,7 +1256,7 @@ func (d *DRPCInstance) getVRGFromManifestWork(clusterName string) (*rmn.VolumeRe
return nil, fmt.Errorf("%w", err)
}

vrg, err := d.extractVRGFromManifestWork(mw)
vrg, err := extractVRGFromManifestWork(mw)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2111,7 +2106,7 @@ func (d *DRPCInstance) updateVRGToRunFinalSync(clusterName string) error {
return nil
}

func (d *DRPCInstance) extractVRGFromManifestWork(mw *ocmworkv1.ManifestWork) (*rmn.VolumeReplicationGroup, error) {
func extractVRGFromManifestWork(mw *ocmworkv1.ManifestWork) (*rmn.VolumeReplicationGroup, error) {
if len(mw.Spec.Workload.Manifests) == 0 {
return nil, fmt.Errorf("invalid VRG ManifestWork for type: %s", mw.Name)
}
Expand All @@ -2133,7 +2128,7 @@ func (d *DRPCInstance) updateManifestWork(clusterName string, vrg *rmn.VolumeRep
return fmt.Errorf("%w", err)
}

vrgClientManifest, err := d.mwu.GenerateManifest(vrg)
vrgClientManifest, err := rmnutil.GenerateManifest(vrg)
if err != nil {
d.log.Error(err, "failed to generate manifest")

Expand Down
Loading
Loading