Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test.sh to run go vet and go fmt #3

Merged
merged 4 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
logf.SetLogger(logf.ZapLogger(false))

// Setup a ControllerManager
manager, err := controller.NewControllerManager(ctrl.ControllerManagerArgs{})
manager, err := controller.NewControllerManager(controller.ControllerManagerArgs{})
if err != nil {
log.Fatal(err)
}
Expand Down
58 changes: 29 additions & 29 deletions pkg/controller/eventhandler/eventhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = Describe("Eventhandler", func() {
var pod *corev1.Pod
t := true
BeforeEach(func() {
q = controllertest.Queue{workqueue.New()}
q = controllertest.Queue{Interface: workqueue.New()}
instance = eventhandler.EnqueueHandler{}
pod = &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{Namespace: "biz", Name: "baz"},
Expand Down Expand Up @@ -196,10 +196,10 @@ var _ = Describe("Eventhandler", func() {
Expect(a.Object).To(Equal(pod))
req = []reconcile.ReconcileRequest{
{
types.NamespacedName{"foo", "bar"},
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "bar"},
},
{
types.NamespacedName{"biz", "baz"},
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz"},
},
}
return req
Expand All @@ -215,11 +215,11 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"foo", "bar"}}))
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "bar"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"biz", "baz"}}))
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz"}}))
})

It("should enqueue a ReconcileRequest with the function applied to the DeleteEvent.", func() {
Expand All @@ -231,10 +231,10 @@ var _ = Describe("Eventhandler", func() {
Expect(a.Object).To(Equal(pod))
req = []reconcile.ReconcileRequest{
{
types.NamespacedName{"foo", "bar"},
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "bar"},
},
{
types.NamespacedName{"biz", "baz"},
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz"},
},
}
return req
Expand All @@ -250,11 +250,11 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"foo", "bar"}}))
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "bar"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"biz", "baz"}}))
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz"}}))
})

It("should enqueue a ReconcileRequest with the function applied to both objects in the UpdateEvent.",
Expand All @@ -269,10 +269,10 @@ var _ = Describe("Eventhandler", func() {
defer GinkgoRecover()
req = []reconcile.ReconcileRequest{
{
types.NamespacedName{"foo", a.Meta.GetName() + "-bar"},
NamespacedName: types.NamespacedName{Namespace: "foo", Name: a.Meta.GetName() + "-bar"},
},
{
types.NamespacedName{"biz", a.Meta.GetName() + "-baz"},
NamespacedName: types.NamespacedName{Namespace: "biz", Name: a.Meta.GetName() + "-baz"},
},
}
return req
Expand All @@ -290,19 +290,19 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"foo", "baz-bar"}}))
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "baz-bar"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"biz", "baz-baz"}}))
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz-baz"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"foo", "baz2-bar"}}))
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "baz2-bar"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"biz", "baz2-baz"}}))
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz2-baz"}}))
})

It("should enqueue a ReconcileRequest with the function applied to the GenericEvent.", func() {
Expand All @@ -314,10 +314,10 @@ var _ = Describe("Eventhandler", func() {
Expect(a.Object).To(Equal(pod))
req = []reconcile.ReconcileRequest{
{
types.NamespacedName{"foo", "bar"},
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "bar"},
},
{
types.NamespacedName{"biz", "baz"},
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz"},
},
}
return req
Expand All @@ -333,11 +333,11 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"foo", "bar"}}))
NamespacedName: types.NamespacedName{Namespace: "foo", Name: "bar"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{"biz", "baz"}}))
NamespacedName: types.NamespacedName{Namespace: "biz", Name: "baz"}}))
})
})

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

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo-parent"}}))
})

It("should enqueue a ReconcileRequest with the Owner of the object in the DeleteEvent.", func() {
Expand All @@ -389,7 +389,7 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo-parent"}}))
})

It("should enqueue a ReconcileRequest with the Owners of both objects in the UpdateEvent.", func() {
Expand Down Expand Up @@ -427,11 +427,11 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo1-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo1-parent"}}))

i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{newPod.GetNamespace(), "foo2-parent"}}))
NamespacedName: types.NamespacedName{Namespace: newPod.GetNamespace(), Name: "foo2-parent"}}))
})

It("should enqueue a ReconcileRequest with the Owner of the object in the GenericEvent.", func() {
Expand All @@ -456,7 +456,7 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo-parent"}}))
})

It("should not enqueue a ReconcileRequest if there are no owners matching Group and Kind.", func() {
Expand Down Expand Up @@ -507,7 +507,7 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo-parent"}}))
})

It("should not enqueue a ReconcileRequest if there are no owners.", func() {
Expand Down Expand Up @@ -568,7 +568,7 @@ var _ = Describe("Eventhandler", func() {
Expect(q.Len()).To(Equal(1))
i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo2-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo2-parent"}}))
})

It("should not enqueue ReconcileRequests if there are no Controller owners.", func() {
Expand Down Expand Up @@ -649,13 +649,13 @@ var _ = Describe("Eventhandler", func() {

i, _ := q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo1-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo1-parent"}}))
i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo2-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo2-parent"}}))
i, _ = q.Get()
Expect(i).To(Equal(reconcile.ReconcileRequest{
types.NamespacedName{pod.GetNamespace(), "foo3-parent"}}))
NamespacedName: types.NamespacedName{Namespace: pod.GetNamespace(), Name: "foo3-parent"}}))
})
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/reconcile/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ExampleReconcileFunc() {
return reconcile.ReconcileResult{}, nil
})

r.Reconcile(reconcile.ReconcileRequest{types.NamespacedName{Namespace: "default", Name: "test"}})
r.Reconcile(reconcile.ReconcileRequest{NamespacedName: types.NamespacedName{Namespace: "default", Name: "test"}})

// Output: Name: test, Namespace: default
}
Expand Down
4 changes: 4 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ setup_envs

go test github.com/kubernetes-sigs/controller-runtime/pkg/...
go install github.com/kubernetes-sigs/controller-runtime/example

go vet ./pkg/...

# golint -set_exit_status ./pkg/...