Skip to content

Commit

Permalink
Eliminate the util/crud.go
Browse files Browse the repository at this point in the history
Split out the drpolicy function to drpolicy.go and rename the file to
namespace.go. Now we can understand better the structure of the util
package.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Jan 26, 2025
1 parent 2ffda78 commit 8ac68a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
27 changes: 27 additions & 0 deletions e2e/util/drpolicy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: The RamenDR authors
// SPDX-License-Identifier: Apache-2.0

package util

import (
"context"

ramen "github.com/ramendr/ramen/api/v1alpha1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

const DefaultDRPolicyName = "dr-policy"

// nolint:unparam
func GetDRPolicy(client client.Client, name string) (*ramen.DRPolicy, error) {
drpolicy := &ramen.DRPolicy{}
key := types.NamespacedName{Name: name}

err := client.Get(context.Background(), key, drpolicy)
if err != nil {
return nil, err
}

return drpolicy, nil
}
16 changes: 0 additions & 16 deletions e2e/util/crud.go → e2e/util/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

ramen "github.com/ramendr/ramen/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const DefaultDRPolicyName = "dr-policy"

func CreateNamespace(client client.Client, namespace string) error {
ns := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -116,16 +113,3 @@ func AddNamespaceAnnotationForVolSync(client client.Client, namespace string) er

return client.Update(context.Background(), objNs)
}

// nolint:unparam
func GetDRPolicy(client client.Client, name string) (*ramen.DRPolicy, error) {
drpolicy := &ramen.DRPolicy{}
key := types.NamespacedName{Name: name}

err := client.Get(context.Background(), key, drpolicy)
if err != nil {
return nil, err
}

return drpolicy, nil
}

0 comments on commit 8ac68a4

Please sign in to comment.