Use ObjectKeyFromObject instead of ObjectKey
controller-runtime's client package provides ObjectKeyFromObject() to extract NamespacedName from a given object. ObjectKey() in internal/util package is a helper for the same. Replace the internal helper with controller-runtime's helper for the same. Signed-off-by: Sunny <darkowlzz@protonmail.com>
This commit is contained in:
parent
40a47670aa
commit
9825a60b74
|
@ -61,7 +61,6 @@ import (
|
|||
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||
"github.com/fluxcd/source-controller/internal/helm"
|
||||
"github.com/fluxcd/source-controller/internal/util"
|
||||
)
|
||||
|
||||
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmcharts,verbs=get;list;watch;create;update;patch;delete
|
||||
|
@ -926,7 +925,7 @@ func (r *HelmChartReconciler) requestsForHelmRepositoryChange(o client.Object) [
|
|||
// enqueued twice.
|
||||
var reqs []reconcile.Request
|
||||
for _, i := range list.Items {
|
||||
reqs = append(reqs, reconcile.Request{NamespacedName: util.ObjectKey(&i)})
|
||||
reqs = append(reqs, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&i)})
|
||||
}
|
||||
return reqs
|
||||
}
|
||||
|
@ -955,7 +954,7 @@ func (r *HelmChartReconciler) requestsForGitRepositoryChange(o client.Object) []
|
|||
// enqueued twice.
|
||||
var reqs []reconcile.Request
|
||||
for _, i := range list.Items {
|
||||
reqs = append(reqs, reconcile.Request{NamespacedName: util.ObjectKey(&i)})
|
||||
reqs = append(reqs, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&i)})
|
||||
}
|
||||
return reqs
|
||||
}
|
||||
|
@ -984,7 +983,7 @@ func (r *HelmChartReconciler) requestsForBucketChange(o client.Object) []reconci
|
|||
// enqueued twice.
|
||||
var reqs []reconcile.Request
|
||||
for _, i := range list.Items {
|
||||
reqs = append(reqs, reconcile.Request{NamespacedName: util.ObjectKey(&i)})
|
||||
reqs = append(reqs, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&i)})
|
||||
}
|
||||
return reqs
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
// ObjectKey returns client.ObjectKey for the object.
|
||||
func ObjectKey(object metav1.Object) client.ObjectKey {
|
||||
return client.ObjectKey{
|
||||
Namespace: object.GetNamespace(),
|
||||
Name: object.GetName(),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue