Skip to content

Commit

Permalink
Merge pull request #1182 from prafull01/no-apitype
Browse files Browse the repository at this point in the history
🐛 add error check when no apiType is provided for reconciliation
  • Loading branch information
k8s-ci-robot committed Sep 29, 2020
2 parents 6af4e7c + 606344e commit dba75e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/builder/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func (blder *Builder) Build(r reconcile.Reconciler) (controller.Controller, erro
if blder.forInput.err != nil {
return nil, blder.forInput.err
}
// Checking the reconcile type exist or not
if blder.forInput.object == nil {
return nil, fmt.Errorf("must provide an object for reconciliation")
}

// Set the Config
blder.loadRestConfig()
Expand Down
12 changes: 12 additions & 0 deletions pkg/builder/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ var _ = Describe("application", func() {
Expect(instance).To(BeNil())
})

It("should return an error if For function is not called", func() {
By("creating a controller manager")
m, err := manager.New(cfg, manager.Options{})
Expect(err).NotTo(HaveOccurred())

instance, err := ControllerManagedBy(m).
Owns(&appsv1.ReplicaSet{}).
Build(noop)
Expect(err).To(MatchError(ContainSubstring("must provide an object for reconciliation")))
Expect(instance).To(BeNil())
})

It("should return an error if there is no GVK for an object, and thus we can't default the controller name", func() {
By("creating a controller manager")
m, err := manager.New(cfg, manager.Options{})
Expand Down

0 comments on commit dba75e5

Please sign in to comment.