Skip to content

Commit cb3a7e0

Browse files
authored
Merge pull request #545 from xychu/skip-update
Skip update op when instance is created
2 parents 83200fa + 6ef4807 commit cb3a7e0

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

pkg/scaffold/controller/controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ func (r *Reconcile{{ .Resource.Kind }}) Reconcile(request reconcile.Request) (re
252252
if err != nil && errors.IsNotFound(err) {
253253
log.Info("Creating Deployment", "namespace", deploy.Namespace, "name", deploy.Name)
254254
err = r.Create(context.TODO(), deploy)
255-
if err != nil {
256-
return reconcile.Result{}, err
257-
}
255+
return reconcile.Result{}, err
258256
} else if err != nil {
259257
return reconcile.Result{}, err
260258
}

pkg/scaffold/controller/controllertest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ func TestReconcile(t *testing.T) {
138138
Should(gomega.Succeed())
139139
140140
// Manually delete Deployment since GC isn't enabled in the test control plane
141-
g.Expect(c.Delete(context.TODO(), deploy)).To(gomega.Succeed())
141+
g.Eventually(func() error { return c.Delete(context.TODO(), deploy) }, timeout).
142+
Should(gomega.MatchError("deployments.apps \"foo-deployment\" not found"))
142143
{{ end }}
143144
}
144145
`

test/project/pkg/controller/firstmate/firstmate_controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ func (r *ReconcileFirstMate) Reconcile(request reconcile.Request) (reconcile.Res
148148
if err != nil && errors.IsNotFound(err) {
149149
log.Info("Creating Deployment", "namespace", deploy.Namespace, "name", deploy.Name)
150150
err = r.Create(context.TODO(), deploy)
151-
if err != nil {
152-
return reconcile.Result{}, err
153-
}
151+
return reconcile.Result{}, err
154152
} else if err != nil {
155153
return reconcile.Result{}, err
156154
}

test/project/pkg/controller/firstmate/firstmate_controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func TestReconcile(t *testing.T) {
8282
Should(gomega.Succeed())
8383

8484
// Manually delete Deployment since GC isn't enabled in the test control plane
85-
g.Expect(c.Delete(context.TODO(), deploy)).To(gomega.Succeed())
85+
g.Eventually(func() error { return c.Delete(context.TODO(), deploy) }, timeout).
86+
Should(gomega.MatchError("deployments.apps \"foo-deployment\" not found"))
8687

8788
}

0 commit comments

Comments
 (0)