Skip to content

Commit 68c51e9

Browse files
authored
Merge pull request #2835 from NikhilSharmaWe/fixRecorderScaffold
🐛 deploy-image/v1alpha: fix small issues
2 parents 9e433c8 + bb74f84 commit 68c51e9

File tree

11 files changed

+20
-18
lines changed

11 files changed

+20
-18
lines changed

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ func (s *apiScaffolder) updateMainByAddingEventRecorder() error {
175175

176176
if err := util.InsertCode(
177177
defaultMainPath,
178-
`Scheme: mgr.GetScheme(),`,
178+
fmt.Sprintf(
179+
`if err = (&controllers.%sReconciler{
180+
Client: mgr.GetClient(),
181+
Scheme: mgr.GetScheme(),`, s.resource.Kind),
179182
fmt.Sprintf(recorderTemplate, strings.ToLower(s.resource.Kind)),
180183
); err != nil {
181184
return fmt.Errorf("error scaffolding event recorder in %s: %v", defaultMainPath, err)
@@ -320,8 +323,7 @@ const portTemplate = `
320323
}},`
321324

322325
const recorderTemplate = `
323-
Recorder: mgr.GetEventRecorderFor("%s-controller"),
324-
`
326+
Recorder: mgr.GetEventRecorderFor("%s-controller"),`
325327

326328
const envVarTemplate = `
327329
- name: %s_IMAGE

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller-test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
140140
}
141141
}
142142
143-
By("Checking if the custom resource was successfully crated")
143+
By("Checking if the custom resource was successfully created")
144144
Eventually(func() error {
145145
found := &{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}
146146
err = k8sClient.Get(ctx, typeNamespaceName, found)
@@ -161,7 +161,7 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
161161
})
162162
Expect(err).To(Not(HaveOccurred()))
163163
164-
By("Checking if Deployment was successfully crated in the reconciliation")
164+
By("Checking if Deployment was successfully created in the reconciliation")
165165
Eventually(func() error {
166166
found := &appsv1.Deployment{}
167167
err = k8sClient.Get(ctx, typeNamespaceName, found)

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (r *{{ .Resource.Kind }}Reconciler) Reconcile(ctx context.Context, req ctrl
134134
return ctrl.Result{}, nil
135135
}
136136
// Error reading the object - requeue the request.
137-
log.Error(err, "Failed to get {{ lower .Resource.Kind }} }}")
137+
log.Error(err, "Failed to get {{ lower .Resource.Kind }}")
138138
return ctrl.Result{}, err
139139
}
140140

testdata/project-v3-with-deploy-image/controllers/busybox_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (r *BusyboxReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
8686
return ctrl.Result{}, nil
8787
}
8888
// Error reading the object - requeue the request.
89-
log.Error(err, "Failed to get busybox }}")
89+
log.Error(err, "Failed to get busybox")
9090
return ctrl.Result{}, err
9191
}
9292

testdata/project-v3-with-deploy-image/controllers/busybox_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ var _ = Describe("Busybox controller", func() {
9090
}
9191
}
9292

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

114-
By("Checking if Deployment was successfully crated in the reconciliation")
114+
By("Checking if Deployment was successfully created in the reconciliation")
115115
Eventually(func() error {
116116
found := &appsv1.Deployment{}
117117
err = k8sClient.Get(ctx, typeNamespaceName, found)

testdata/project-v3-with-deploy-image/controllers/memcached_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
8686
return ctrl.Result{}, nil
8787
}
8888
// Error reading the object - requeue the request.
89-
log.Error(err, "Failed to get memcached }}")
89+
log.Error(err, "Failed to get memcached")
9090
return ctrl.Result{}, err
9191
}
9292

testdata/project-v3-with-deploy-image/controllers/memcached_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ var _ = Describe("Memcached controller", func() {
9191
}
9292
}
9393

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

115-
By("Checking if Deployment was successfully crated in the reconciliation")
115+
By("Checking if Deployment was successfully created in the reconciliation")
116116
Eventually(func() error {
117117
found := &appsv1.Deployment{}
118118
err = k8sClient.Get(ctx, typeNamespaceName, found)

testdata/project-v4-with-deploy-image/controllers/busybox_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (r *BusyboxReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
8686
return ctrl.Result{}, nil
8787
}
8888
// Error reading the object - requeue the request.
89-
log.Error(err, "Failed to get busybox }}")
89+
log.Error(err, "Failed to get busybox")
9090
return ctrl.Result{}, err
9191
}
9292

testdata/project-v4-with-deploy-image/controllers/busybox_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ var _ = Describe("Busybox controller", func() {
9090
}
9191
}
9292

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

114-
By("Checking if Deployment was successfully crated in the reconciliation")
114+
By("Checking if Deployment was successfully created in the reconciliation")
115115
Eventually(func() error {
116116
found := &appsv1.Deployment{}
117117
err = k8sClient.Get(ctx, typeNamespaceName, found)

testdata/project-v4-with-deploy-image/controllers/memcached_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
8686
return ctrl.Result{}, nil
8787
}
8888
// Error reading the object - requeue the request.
89-
log.Error(err, "Failed to get memcached }}")
89+
log.Error(err, "Failed to get memcached")
9090
return ctrl.Result{}, err
9191
}
9292

0 commit comments

Comments
 (0)