Skip to content

Commit

Permalink
Merge pull request #2835 from NikhilSharmaWe/fixRecorderScaffold
Browse files Browse the repository at this point in the history
🐛 deploy-image/v1alpha: fix small issues
  • Loading branch information
k8s-ci-robot committed Jul 25, 2022
2 parents 9e433c8 + bb74f84 commit 68c51e9
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 18 deletions.
8 changes: 5 additions & 3 deletions pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ func (s *apiScaffolder) updateMainByAddingEventRecorder() error {

if err := util.InsertCode(
defaultMainPath,
`Scheme: mgr.GetScheme(),`,
fmt.Sprintf(
`if err = (&controllers.%sReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),`, s.resource.Kind),
fmt.Sprintf(recorderTemplate, strings.ToLower(s.resource.Kind)),
); err != nil {
return fmt.Errorf("error scaffolding event recorder in %s: %v", defaultMainPath, err)
Expand Down Expand Up @@ -320,8 +323,7 @@ const portTemplate = `
}},`

const recorderTemplate = `
Recorder: mgr.GetEventRecorderFor("%s-controller"),
`
Recorder: mgr.GetEventRecorderFor("%s-controller"),`

const envVarTemplate = `
- name: %s_IMAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
}
}
By("Checking if the custom resource was successfully crated")
By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand All @@ -161,7 +161,7 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
})
Expect(err).To(Not(HaveOccurred()))
By("Checking if Deployment was successfully crated in the reconciliation")
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (r *{{ .Resource.Kind }}Reconciler) Reconcile(ctx context.Context, req ctrl
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
log.Error(err, "Failed to get {{ lower .Resource.Kind }} }}")
log.Error(err, "Failed to get {{ lower .Resource.Kind }}")
return ctrl.Result{}, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *BusyboxReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
log.Error(err, "Failed to get busybox }}")
log.Error(err, "Failed to get busybox")
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("Busybox controller", func() {
}
}

By("Checking if the custom resource was successfully crated")
By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Busybox{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand All @@ -111,7 +111,7 @@ var _ = Describe("Busybox controller", func() {
})
Expect(err).To(Not(HaveOccurred()))

By("Checking if Deployment was successfully crated in the reconciliation")
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
log.Error(err, "Failed to get memcached }}")
log.Error(err, "Failed to get memcached")
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var _ = Describe("Memcached controller", func() {
}
}

By("Checking if the custom resource was successfully crated")
By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Memcached{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand All @@ -112,7 +112,7 @@ var _ = Describe("Memcached controller", func() {
})
Expect(err).To(Not(HaveOccurred()))

By("Checking if Deployment was successfully crated in the reconciliation")
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *BusyboxReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
log.Error(err, "Failed to get busybox }}")
log.Error(err, "Failed to get busybox")
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("Busybox controller", func() {
}
}

By("Checking if the custom resource was successfully crated")
By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Busybox{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand All @@ -111,7 +111,7 @@ var _ = Describe("Busybox controller", func() {
})
Expect(err).To(Not(HaveOccurred()))

By("Checking if Deployment was successfully crated in the reconciliation")
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
log.Error(err, "Failed to get memcached }}")
log.Error(err, "Failed to get memcached")
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var _ = Describe("Memcached controller", func() {
}
}

By("Checking if the custom resource was successfully crated")
By("Checking if the custom resource was successfully created")
Eventually(func() error {
found := &examplecomv1alpha1.Memcached{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand All @@ -112,7 +112,7 @@ var _ = Describe("Memcached controller", func() {
})
Expect(err).To(Not(HaveOccurred()))

By("Checking if Deployment was successfully crated in the reconciliation")
By("Checking if Deployment was successfully created in the reconciliation")
Eventually(func() error {
found := &appsv1.Deployment{}
err = k8sClient.Get(ctx, typeNamespaceName, found)
Expand Down

0 comments on commit 68c51e9

Please sign in to comment.