Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,13 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
}

err = k8sClient.Create(ctx, {{ lower .Resource.Kind }})
if err != nil {
Expect(err).To(Not(HaveOccurred()))
}
Expect(err).To(Not(HaveOccurred()))
}

By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
Copy link
Contributor Author

@LittleWat LittleWat Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}, time.Minute, time.Second).Should(Succeed())

By("Reconciling the custom resource created")
Expand All @@ -164,11 +158,7 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,13 @@ var _ = Describe("Busybox controller", func() {
}

err = k8sClient.Create(ctx, busybox)
if err != nil {
Expect(err).To(Not(HaveOccurred()))
}
Expect(err).To(Not(HaveOccurred()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LittleWat,

Thank you for the contribution 🥇.

But this change cannot be done in the samples. the samples are generated automatically when we run make generate, see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/testdata/generate.sh

Therefore, this change needs to be done in the plugin implementation: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller-test.go#L138-L140

Could you please do that in the code implementation and run make generate to ensure that all samples will be updated according to, squash the commits and push it so we are able to get this one merged?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please note that you need assign to the CLA. #2838 (comment)

Copy link
Contributor Author

@LittleWat LittleWat Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@camilamacedo86 Thank you for the quick and detailed review! Oh, these test codes are generated, cool!

I edited the original template file and did make generate and committed!
I also signed!

}

By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Busybox{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())

By("Reconciling the custom resource created")
Expand All @@ -114,11 +108,7 @@ var _ = Describe("Busybox controller", func() {
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ var _ = Describe("Memcached controller", func() {
}

err = k8sClient.Create(ctx, memcached)
if err != nil {
Expect(err).To(Not(HaveOccurred()))
}
Expect(err).To(Not(HaveOccurred()))
}

By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Memcached{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())

By("Reconciling the custom resource created")
Expand All @@ -115,11 +109,7 @@ var _ = Describe("Memcached controller", func() {
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,13 @@ var _ = Describe("Busybox controller", func() {
}

err = k8sClient.Create(ctx, busybox)
if err != nil {
Expect(err).To(Not(HaveOccurred()))
}
Expect(err).To(Not(HaveOccurred()))
}

By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Busybox{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())

By("Reconciling the custom resource created")
Expand All @@ -114,11 +108,7 @@ var _ = Describe("Busybox controller", func() {
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ var _ = Describe("Memcached controller", func() {
}

err = k8sClient.Create(ctx, memcached)
if err != nil {
Expect(err).To(Not(HaveOccurred()))
}
Expect(err).To(Not(HaveOccurred()))
}

By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Memcached{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())

By("Reconciling the custom resource created")
Expand All @@ -115,11 +109,7 @@ var _ = Describe("Memcached controller", func() {
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
if err != nil {
return err
}
return nil
return k8sClient.Get(ctx, typeNamespaceName, found)
}, time.Minute, time.Second).Should(Succeed())
})
})
Expand Down