Skip to content

Commit

Permalink
use client.Object in controllerutil.SupportsOwnerReference
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Dec 22, 2021
1 parent 73331dc commit d7158a1
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -57,7 +56,7 @@ func WaitForDeletion(ctx context.Context, cl client.Reader, o client.Object) err
}, ctx.Done())
}

func SupportsOwnerReference(restMapper meta.RESTMapper, owner, dependent *unstructured.Unstructured) (bool, error) {
func SupportsOwnerReference(restMapper meta.RESTMapper, owner, dependent client.Object) (bool, error) {
ownerGVK := owner.GetObjectKind().GroupVersionKind()
ownerMapping, err := restMapper.RESTMapping(ownerGVK.GroupKind(), ownerGVK.Version)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

. "github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
. "github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
)

var _ = Describe("Controllerutil", func() {
Expand Down Expand Up @@ -74,8 +74,8 @@ var _ = Describe("Controllerutil", func() {
Describe("SupportsOwnerReference", func() {
var (
rm *meta.DefaultRESTMapper
owner *unstructured.Unstructured
dependent *unstructured.Unstructured
owner client.Object
dependent client.Object
clusterScoped = schema.GroupVersionKind{Group: "example.com", Version: "v1", Kind: "ClusterScoped"}
namespaceScoped = schema.GroupVersionKind{Group: "example.com", Version: "v1", Kind: "NamespaceScoped"}
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/actionclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

"github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/manifestutil"
"github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
)

type ActionClientGetter interface {
Expand Down Expand Up @@ -331,7 +331,7 @@ func (pr *ownerPostRenderer) Run(in *bytes.Buffer) (*bytes.Buffer, error) {
return err
}
u := &unstructured.Unstructured{Object: objMap}
useOwnerRef, err := controllerutil.SupportsOwnerReference(pr.rm, pr.owner.(*unstructured.Unstructured), u)
useOwnerRef, err := controllerutil.SupportsOwnerReference(pr.rm, pr.owner, u)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/internal/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/source"
"sigs.k8s.io/yaml"

"github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/hook"
"github.com/operator-framework/helm-operator-plugins/pkg/internal/predicate"
"github.com/operator-framework/helm-operator-plugins/pkg/manifestutil"
"github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
)

func NewDependentResourceWatcher(c controller.Controller, rm meta.RESTMapper) hook.PostHook {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/internal/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"k8s.io/client-go/util/retry"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/internal/status"
"github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
)

func New(client client.Client) Updater {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ import (
ctrlpredicate "sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/annotation"
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
"github.com/operator-framework/helm-operator-plugins/pkg/hook"
"github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/conditions"
internalhook "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/hook"
"github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/updater"
internalvalues "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/values"
"github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/values"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/yaml"

"github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/annotation"
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
"github.com/operator-framework/helm-operator-plugins/pkg/hook"
"github.com/operator-framework/helm-operator-plugins/pkg/internal/status"
"github.com/operator-framework/helm-operator-plugins/pkg/internal/testutil"
"github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/conditions"
helmfake "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/fake"
"github.com/operator-framework/helm-operator-plugins/pkg/sdk/controllerutil"
"github.com/operator-framework/helm-operator-plugins/pkg/values"
)

Expand Down

0 comments on commit d7158a1

Please sign in to comment.