diff --git a/.golangci.yaml b/.golangci.yaml index d8e74c633e..ee8dd85cbc 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -175,7 +175,7 @@ linters: # - goimports # - wrapcheck # - varnamelen - # - staticcheck + - staticcheck # - nosnakecase # - ireturn # - nilnil diff --git a/controllers/drclusters.go b/controllers/drclusters.go index 6153657023..03e11291b3 100644 --- a/controllers/drclusters.go +++ b/controllers/drclusters.go @@ -223,7 +223,7 @@ func drClusterUndeploy( mcv util.ManagedClusterViewGetter, log logr.Logger, ) error { - clusterNames := sets.String{} + clusterNames := sets.New[string]() drpolicies := rmn.DRPolicyList{} if err := mwu.Client.List(mwu.Ctx, &drpolicies); err != nil { diff --git a/controllers/drplacementcontrol_controller_test.go b/controllers/drplacementcontrol_controller_test.go index fce8cd36c8..62990e0ae6 100644 --- a/controllers/drplacementcontrol_controller_test.go +++ b/controllers/drplacementcontrol_controller_test.go @@ -389,7 +389,7 @@ func resetClusterDown() { } //nolint:funlen,cyclop,gocognit -func (FakeMCVGetter) GetVRGFromManagedCluster(_, _, managedCluster string, +func (FakeMCVGetter) GetVRGFromManagedCluster(_, resourceNamespace, managedCluster string, _ map[string]string, ) (*rmn.VolumeReplicationGroup, error) { conType := controllers.VRGConditionTypeDataReady @@ -1161,7 +1161,7 @@ const ( UsePlacementWithAppSet = 3 ) -func InitialDeploymentAsync(namespace, placementName string, plType PlacementType) ( +func InitialDeploymentAsync(namespace, placementName, homeCluster string, plType PlacementType) ( client.Object, *rmn.DRPlacementControl, ) { createNamespacesAsync(getNamespaceObj(namespace)) @@ -1194,7 +1194,7 @@ func CreatePlacementAndDRPC(namespace, placementName, homeCluster string, plType return placementObj, createDRPC(placementName, DRPCCommonName, namespace, AsyncDRPolicyName, homeCluster) } -func FollowOnDeploymentAsync(namespace, placementName string) (*plrv1.PlacementRule, +func FollowOnDeploymentAsync(namespace, placementName, homeCluster string) (*plrv1.PlacementRule, *rmn.DRPlacementControl, ) { createNamespace(appNamespace2) @@ -1632,7 +1632,7 @@ func createNamespacesSync() { createNamespace(appNamespace) } -func InitialDeploymentSync(namespace, placementName string) (*plrv1.PlacementRule, +func InitialDeploymentSync(namespace, placementName, homeCluster string) (*plrv1.PlacementRule, *rmn.DRPlacementControl, ) { createNamespacesSync() @@ -1863,7 +1863,7 @@ var _ = Describe("DRPlacementControl Reconciler", func() { By("Initial Deployment") var placementObj client.Object placementObj, drpc = InitialDeploymentAsync( - DefaultDRPCNamespace, UserPlacementRuleName, UsePlacementRule) + DefaultDRPCNamespace, UserPlacementRuleName, East1ManagedCluster, UsePlacementRule) userPlacementRule = placementObj.(*plrv1.PlacementRule) Expect(userPlacementRule).NotTo(BeNil()) verifyInitialDRPCDeployment(userPlacementRule, East1ManagedCluster) @@ -1930,7 +1930,7 @@ var _ = Describe("DRPlacementControl Reconciler", func() { }) When("A DRPC is created referring to a deleted DRPolicy", func() { It("Should fail DRPC reconciliaiton and not add a finalizer", func() { - _, drpc2 := FollowOnDeploymentAsync(DRPC2NamespaceName, UserPlacementRuleName) + _, drpc2 := FollowOnDeploymentAsync(DRPC2NamespaceName, UserPlacementRuleName, East1ManagedCluster) checkIfDRPCFinalizerNotAdded(drpc2) Expect(k8sClient.Delete(context.TODO(), drpc2)).Should(Succeed()) }) @@ -1975,7 +1975,7 @@ var _ = Describe("DRPlacementControl Reconciler", func() { By("Initial Deployment") var placementObj client.Object placementObj, drpc = InitialDeploymentAsync( - DefaultDRPCNamespace, UserPlacementName, UsePlacementWithSubscription) + DefaultDRPCNamespace, UserPlacementName, East1ManagedCluster, UsePlacementWithSubscription) placement = placementObj.(*clrapiv1beta1.Placement) Expect(placement).NotTo(BeNil()) verifyInitialDRPCDeployment(placement, East1ManagedCluster) @@ -2051,7 +2051,7 @@ var _ = Describe("DRPlacementControl Reconciler", func() { getBaseVRG(DefaultDRPCNamespace).ObjectMeta.Namespace = ApplicationNamespace var placementObj client.Object placementObj, drpc = InitialDeploymentAsync( - DefaultDRPCNamespace, UserPlacementName, UsePlacementWithAppSet) + DefaultDRPCNamespace, UserPlacementName, East1ManagedCluster, UsePlacementWithAppSet) placement = placementObj.(*clrapiv1beta1.Placement) Expect(placement).NotTo(BeNil()) verifyInitialDRPCDeployment(placement, East1ManagedCluster) @@ -2135,7 +2135,7 @@ var _ = Describe("DRPlacementControl Reconciler", func() { When("An Application is deployed for the first time", func() { It("Should deploy to East1ManagedCluster", func() { By("Initial Deployment") - userPlacementRule, _ = InitialDeploymentSync(DefaultDRPCNamespace, UserPlacementRuleName) + userPlacementRule, _ = InitialDeploymentSync(DefaultDRPCNamespace, UserPlacementRuleName, East1ManagedCluster) verifyInitialDRPCDeployment(userPlacementRule, East1ManagedCluster) verifyDRPCOwnedByPlacement(userPlacementRule, getLatestDRPC(DefaultDRPCNamespace)) }) @@ -2211,7 +2211,7 @@ var _ = Describe("DRPlacementControl Reconciler", func() { When("An Application is deployed for the first time", func() { It("Should deploy to East1ManagedCluster", func() { By("Initial Deployment") - userPlacementRule, _ = InitialDeploymentSync(DefaultDRPCNamespace, UserPlacementRuleName) + userPlacementRule, _ = InitialDeploymentSync(DefaultDRPCNamespace, UserPlacementRuleName, East1ManagedCluster) verifyInitialDRPCDeployment(userPlacementRule, East1ManagedCluster) verifyDRPCOwnedByPlacement(userPlacementRule, getLatestDRPC(DefaultDRPCNamespace)) }) diff --git a/controllers/drpolicy.go b/controllers/drpolicy.go index 9e35cb59ae..a846256c1d 100644 --- a/controllers/drpolicy.go +++ b/controllers/drpolicy.go @@ -59,7 +59,7 @@ func drClusterSecretsDeploy( log.Info("Received partial list", "err", err) } - for _, secretName := range drPolicySecrets.List() { + for secretName := range drPolicySecrets { if err := secretsUtil.AddSecretToCluster( secretName, clusterName, @@ -102,7 +102,7 @@ func drClustersUndeploySecrets( return nil } - mustHaveS3Secrets := map[string]sets.String{} + mustHaveS3Secrets := map[string]sets.Set[string]{} // Determine S3 secrets that must continue to exist per cluster in the policy being deleted for _, clusterName := range util.DrpolicyClusterNames(drpolicy) { @@ -119,7 +119,7 @@ func drClustersUndeploySecrets( // For each cluster in the must have S3 secrets list, check and delete // S3Profiles that maybe deleted, iff absent in the must have list for clusterName, mustHaveS3Secrets := range mustHaveS3Secrets { - for _, s3SecretToDelete := range mayDeleteS3Secrets.List() { + for s3SecretToDelete := range mayDeleteS3Secrets { if mustHaveS3Secrets.Has(s3SecretToDelete) { continue } @@ -144,8 +144,8 @@ func drClusterListMustHaveSecrets( clusterName string, ignorePolicy *rmn.DRPolicy, ramenConfig *rmn.RamenConfig, -) sets.String { - mustHaveS3Secrets := sets.String{} +) sets.Set[string] { + mustHaveS3Secrets := sets.New[string]() mustHaveS3Profiles := drClusterListMustHaveS3Profiles(drpolicies, drclusters, clusterName, ignorePolicy) @@ -164,8 +164,8 @@ func drClusterListMustHaveS3Profiles(drpolicies rmn.DRPolicyList, drclusters *rmn.DRClusterList, clusterName string, ignorePolicy *rmn.DRPolicy, -) sets.String { - mustHaveS3Profiles := sets.String{} +) sets.Set[string] { + mustHaveS3Profiles := sets.New[string]() for idx := range drpolicies.Items { // Skip the policy being ignored (used for delete) @@ -192,8 +192,8 @@ func drClusterListMustHaveS3Profiles(drpolicies rmn.DRPolicyList, func drPolicySecretNames(drpolicy *rmn.DRPolicy, drclusters *rmn.DRClusterList, rmnCfg *rmn.RamenConfig, -) (sets.String, error) { - secretNames := sets.String{} +) (sets.Set[string], error) { + secretNames := sets.New[string]() var err error diff --git a/controllers/ramenconfig.go b/controllers/ramenconfig.go index 0570de5346..c5aaa85f64 100644 --- a/controllers/ramenconfig.go +++ b/controllers/ramenconfig.go @@ -6,7 +6,6 @@ package controllers import ( "context" "fmt" - "io/ioutil" "net/url" "os" @@ -90,7 +89,7 @@ func ReadRamenConfigFile(log logr.Logger) (ramenConfig ramendrv1alpha1.RamenConf log.Info("loading Ramen config file ", "name", cachedRamenConfigFileName) - fileContents, err := ioutil.ReadFile(cachedRamenConfigFileName) + fileContents, err := os.ReadFile(cachedRamenConfigFileName) if err != nil { err = fmt.Errorf("unable to load the config file %s: %w", cachedRamenConfigFileName, err) diff --git a/controllers/util/drpolicy_util.go b/controllers/util/drpolicy_util.go index 1d2256850a..6f04fc5655 100644 --- a/controllers/util/drpolicy_util.go +++ b/controllers/util/drpolicy_util.go @@ -40,8 +40,8 @@ func DrpolicyRegionNames(drpolicy *rmn.DRPolicy, drClusters []rmn.DRCluster) []s return regionNames } -func DrpolicyRegionNamesAsASet(drpolicy *rmn.DRPolicy, drClusters []rmn.DRCluster) sets.String { - return sets.NewString(DrpolicyRegionNames(drpolicy, drClusters)...) +func DrpolicyRegionNamesAsASet(drpolicy *rmn.DRPolicy, drClusters []rmn.DRCluster) sets.Set[string] { + return sets.New(DrpolicyRegionNames(drpolicy, drClusters)...) } func DrpolicyValidated(drpolicy *rmn.DRPolicy) error { @@ -68,8 +68,8 @@ func GetAllDRPolicies(ctx context.Context, cli client.Reader) (rmn.DRPolicyList, return drpolicies, nil } -func DRPolicyS3Profiles(drpolicy *rmn.DRPolicy, drclusters []rmn.DRCluster) sets.String { - mustHaveS3Profiles := sets.String{} +func DRPolicyS3Profiles(drpolicy *rmn.DRPolicy, drclusters []rmn.DRCluster) sets.Set[string] { + mustHaveS3Profiles := sets.New[string]() for _, managedCluster := range DrpolicyClusterNames(drpolicy) { s3ProfileName := "" diff --git a/controllers/vrg_recipe.go b/controllers/vrg_recipe.go index 43ae8314b7..a94a23e668 100644 --- a/controllers/vrg_recipe.go +++ b/controllers/vrg_recipe.go @@ -220,7 +220,6 @@ func recipesWatch(b *builder.Builder, m objectToReconcileRequestsMapper) *builde } func (m objectToReconcileRequestsMapper) recipeToVrgReconcileRequestsMapper( -<<<<<<< HEAD _ context.Context, rcp client.Object, ) []reconcile.Request { diff --git a/controllers/vrg_recipe_test.go b/controllers/vrg_recipe_test.go index 0a8d69de29..d864ed1d9b 100644 --- a/controllers/vrg_recipe_test.go +++ b/controllers/vrg_recipe_test.go @@ -436,7 +436,7 @@ var _ = Describe("VolumeReplicationGroupRecipe", func() { recipeHooksDefine(hook(ns0ParameterRef)) }) JustBeforeEach(func() { - recipeExpanded = &*r + recipeExpanded = r Expect(controllers.RecipeParametersExpand(recipeExpanded, vrgRecipeParameters(), testLogger)).To(Succeed()) }) It("expands a parameter list enclosed in double quotes to a single string with quotes preserved", func() { diff --git a/controllers/vrg_volrep.go b/controllers/vrg_volrep.go index 664c5a5a64..75148ce6de 100644 --- a/controllers/vrg_volrep.go +++ b/controllers/vrg_volrep.go @@ -1997,7 +1997,7 @@ func restoreClusterDataObjects[ for i := range objList { object := &objList[i] - objectCopy := &*object + objectCopy := object obj := ClientObject(objectCopy) cleanupForRestore(objectCopy)