Skip to content

Commit

Permalink
Merge pull request #397 from darkowlzz/rm-util-objectkey
Browse files Browse the repository at this point in the history
Remove old util ObjectKey
  • Loading branch information
stefanprodan authored Aug 1, 2021
2 parents 9d66fc7 + 930e7d3 commit 81a4090
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
8 changes: 4 additions & 4 deletions controllers/kustomization_controller_gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ data:

var got kustomizev1.Kustomization
Eventually(func() bool {
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &got)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &got)
c := apimeta.FindStatusCondition(got.Status.Conditions, meta.ReadyCondition)
return c != nil && c.Reason == meta.ReconciliationSucceededReason
}, timeout, time.Second).Should(BeTrue())
Expand All @@ -158,7 +158,7 @@ data:
Expect(k8sClient.Status().Update(context.Background(), gitRepo)).To(Succeed())

Eventually(func() bool {
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &got)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &got)
return got.Status.LastAppliedRevision == gitRepo.Status.Artifact.Revision
}, timeout, time.Second).Should(BeTrue())
err = k8sClient.Get(context.Background(), client.ObjectKey{Name: "first", Namespace: namespace.Name}, &configMap)
Expand Down Expand Up @@ -204,7 +204,7 @@ data:

var got kustomizev1.Kustomization
Eventually(func() bool {
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &got)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &got)
c := apimeta.FindStatusCondition(got.Status.Conditions, meta.ReadyCondition)
return c != nil && c.Reason == meta.ReconciliationSucceededReason
}, timeout, time.Second).Should(BeTrue())
Expand All @@ -224,7 +224,7 @@ data:
Expect(k8sClient.Status().Update(context.Background(), gitRepo)).To(Succeed())

Eventually(func() bool {
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &got)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &got)
return got.Status.LastAppliedRevision == gitRepo.Status.Artifact.Revision
}, timeout, time.Second).Should(BeTrue())
err = k8sClient.Get(context.Background(), client.ObjectKey{Name: "first", Namespace: namespace.Name}, &configMap)
Expand Down
10 changes: 5 additions & 5 deletions controllers/kustomization_controller_patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var _ = Describe("KustomizationReconciler", func() {

Eventually(func() bool {
var obj kustomizev1.Kustomization
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &obj)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &obj)
return obj.Status.LastAppliedRevision == "main/"+artifactChecksum
}, timeout, time.Second).Should(BeTrue())

Expand All @@ -161,7 +161,7 @@ var _ = Describe("KustomizationReconciler", func() {

Eventually(func() bool {
var obj kustomizev1.Kustomization
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &obj)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &obj)
return obj.Status.LastAppliedRevision == "main/"+artifactChecksum
}, timeout, time.Second).Should(BeTrue())

Expand All @@ -187,7 +187,7 @@ metadata:

Eventually(func() bool {
var obj kustomizev1.Kustomization
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &obj)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &obj)
return obj.Status.LastAppliedRevision == "main/"+artifactChecksum
}, timeout, time.Second).Should(BeTrue())

Expand All @@ -206,7 +206,7 @@ metadata:

Eventually(func() bool {
var obj kustomizev1.Kustomization
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &obj)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &obj)
return obj.Status.LastAppliedRevision == "main/"+artifactChecksum
}, timeout, time.Second).Should(BeTrue())

Expand Down Expand Up @@ -234,7 +234,7 @@ metadata:

Eventually(func() bool {
var obj kustomizev1.Kustomization
_ = k8sClient.Get(context.Background(), ObjectKey(kustomization), &obj)
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), &obj)
return obj.Status.LastAppliedRevision == "main/"+artifactChecksum
}, timeout, time.Second).Should(BeTrue())

Expand Down
2 changes: 1 addition & 1 deletion controllers/kustomization_indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r *KustomizationReconciler) requestsForRevisionChangeOf(indexKey string) f
ctx := context.Background()
var list kustomizev1.KustomizationList
if err := r.List(ctx, &list, client.MatchingFields{
indexKey: ObjectKey(obj).String(),
indexKey: client.ObjectKeyFromObject(obj).String(),
}); err != nil {
return nil
}
Expand Down
10 changes: 0 additions & 10 deletions controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package controllers

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"strings"
)

Expand Down Expand Up @@ -79,11 +77,3 @@ func containsString(slice []string, s string) bool {
}
return false
}

// ObjectKey returns client.ObjectKey for the object.
func ObjectKey(object metav1.Object) client.ObjectKey {
return client.ObjectKey{
Namespace: object.GetNamespace(),
Name: object.GetName(),
}
}

0 comments on commit 81a4090

Please sign in to comment.