Skip to content

Commit e3f9ad6

Browse files
committed
gofmt the comment
1 parent 3d004e5 commit e3f9ad6

File tree

1 file changed

+184
-183
lines changed

1 file changed

+184
-183
lines changed

internal/controller/postgrescluster/controller_test.go

Lines changed: 184 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -197,207 +197,208 @@ var _ = Describe("PostgresCluster Reconciler", func() {
197197
}
198198

199199
/*
200-
var cluster *v1beta1.PostgresCluster
201-
202-
BeforeEach(func() {
203-
ctx := context.Background()
204-
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
205-
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "", logging.FromContext(ctx))
206-
test.Reconciler.PGOVersion = "v5.4.2"
207-
208-
// REGISTRATION_REQUIRED will be set by OLM installers.
209-
os.Setenv("REGISTRATION_REQUIRED", "true")
210-
cluster = create(olmClusterYAML)
211-
Expect(reconcile(cluster)).To(BeZero())
212-
})
213-
214-
AfterEach(func() {
215-
ctx := context.Background()
216-
217-
if cluster != nil {
218-
Expect(client.IgnoreNotFound(
219-
suite.Client.Delete(ctx, cluster),
200+
Context("New Unregistered Cluster with Registration Requirement, no Token, no need to Encumber", func() {
201+
var cluster *v1beta1.PostgresCluster
202+
203+
BeforeEach(func() {
204+
ctx := context.Background()
205+
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
206+
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "", logging.FromContext(ctx))
207+
test.Reconciler.PGOVersion = "v5.4.2"
208+
209+
// REGISTRATION_REQUIRED will be set by OLM installers.
210+
os.Setenv("REGISTRATION_REQUIRED", "true")
211+
cluster = create(olmClusterYAML)
212+
Expect(reconcile(cluster)).To(BeZero())
213+
})
214+
215+
AfterEach(func() {
216+
ctx := context.Background()
217+
218+
if cluster != nil {
219+
Expect(client.IgnoreNotFound(
220+
suite.Client.Delete(ctx, cluster),
221+
)).To(Succeed())
222+
223+
// Remove finalizers, if any, so the namespace can terminate.
224+
Expect(client.IgnoreNotFound(
225+
suite.Client.Patch(ctx, cluster, client.RawPatch(
226+
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
227+
)).To(Succeed())
228+
}
229+
os.Unsetenv("REGISTRATION_REQUIRED")
230+
})
231+
232+
Specify("Cluster RegistrationRequired Status", func() {
233+
existing := &v1beta1.PostgresCluster{}
234+
Expect(suite.Client.Get(
235+
context.Background(), client.ObjectKeyFromObject(cluster), existing,
220236
)).To(Succeed())
221237
222-
// Remove finalizers, if any, so the namespace can terminate.
223-
Expect(client.IgnoreNotFound(
224-
suite.Client.Patch(ctx, cluster, client.RawPatch(
225-
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
226-
)).To(Succeed())
227-
}
228-
os.Unsetenv("REGISTRATION_REQUIRED")
229-
})
230-
231-
Specify("Cluster RegistrationRequired Status", func() {
232-
existing := &v1beta1.PostgresCluster{}
233-
Expect(suite.Client.Get(
234-
context.Background(), client.ObjectKeyFromObject(cluster), existing,
235-
)).To(Succeed())
236-
237-
registrationRequired := config.RegistrationRequired()
238-
Expect(registrationRequired).To(BeTrue())
239-
240-
pgoVersion := existing.Status.RegistrationRequired.PGOVersion
241-
Expect(pgoVersion).To(Equal("v5.4.2"))
238+
registrationRequired := config.RegistrationRequired()
239+
Expect(registrationRequired).To(BeTrue())
242240
243-
shouldEncumber := shouldEncumberReconciliation(test.Reconciler.Registration.Authenticated, existing, test.Reconciler.PGOVersion)
244-
Expect(shouldEncumber).To(BeFalse())
245-
})
246-
})
247-
248-
Context("Cluster with Registration Requirement and an invalid token, must Encumber", func() {
249-
var cluster *v1beta1.PostgresCluster
241+
pgoVersion := existing.Status.RegistrationRequired.PGOVersion
242+
Expect(pgoVersion).To(Equal("v5.4.2"))
250243
251-
BeforeEach(func() {
252-
test.Reconciler.PGOVersion = "v5.4.3"
253-
// REGISTRATION_REQUIRED will be set by an OLM installer.
254-
os.Setenv("REGISTRATION_REQUIRED", "true")
255-
ctx := context.Background()
256-
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
257-
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "../../testing/invalid_token", logging.FromContext(ctx))
258-
cluster = create(olmClusterYAML)
259-
Expect(reconcile(cluster)).To(BeZero())
244+
shouldEncumber := shouldEncumberReconciliation(test.Reconciler.Registration.Authenticated, existing, test.Reconciler.PGOVersion)
245+
Expect(shouldEncumber).To(BeFalse())
246+
})
260247
})
261248
262-
AfterEach(func() {
263-
ctx := context.Background()
264-
265-
if cluster != nil {
266-
Expect(client.IgnoreNotFound(
267-
suite.Client.Delete(ctx, cluster),
268-
)).To(Succeed())
269-
270-
// Remove finalizers, if any, so the namespace can terminate.
271-
Expect(client.IgnoreNotFound(
272-
suite.Client.Patch(ctx, cluster, client.RawPatch(
273-
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
249+
Context("Cluster with Registration Requirement and an invalid token, must Encumber", func() {
250+
var cluster *v1beta1.PostgresCluster
251+
252+
BeforeEach(func() {
253+
test.Reconciler.PGOVersion = "v5.4.3"
254+
// REGISTRATION_REQUIRED will be set by an OLM installer.
255+
os.Setenv("REGISTRATION_REQUIRED", "true")
256+
ctx := context.Background()
257+
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
258+
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "../../testing/invalid_token", logging.FromContext(ctx))
259+
cluster = create(olmClusterYAML)
260+
Expect(reconcile(cluster)).To(BeZero())
261+
})
262+
263+
AfterEach(func() {
264+
ctx := context.Background()
265+
266+
if cluster != nil {
267+
Expect(client.IgnoreNotFound(
268+
suite.Client.Delete(ctx, cluster),
269+
)).To(Succeed())
270+
271+
// Remove finalizers, if any, so the namespace can terminate.
272+
Expect(client.IgnoreNotFound(
273+
suite.Client.Patch(ctx, cluster, client.RawPatch(
274+
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
275+
)).To(Succeed())
276+
}
277+
os.Unsetenv("REGISTRATION_REQUIRED")
278+
})
279+
280+
Specify("Cluster RegistrationRequired Status", func() {
281+
existing := &v1beta1.PostgresCluster{}
282+
Expect(suite.Client.Get(
283+
context.Background(), client.ObjectKeyFromObject(cluster), existing,
274284
)).To(Succeed())
275-
}
276-
os.Unsetenv("REGISTRATION_REQUIRED")
277-
})
278285
279-
Specify("Cluster RegistrationRequired Status", func() {
280-
existing := &v1beta1.PostgresCluster{}
281-
Expect(suite.Client.Get(
282-
context.Background(), client.ObjectKeyFromObject(cluster), existing,
283-
)).To(Succeed())
284-
285-
reg := test.Reconciler.Registration
286-
Expect(reg.TokenFileFound).To(BeTrue())
287-
Expect(reg.Authenticated).To(BeFalse())
288-
// Simulate an upgrade of the operator by bumping the Reconciler PGOVersion.
289-
shouldEncumber := shouldEncumberReconciliation(reg.Authenticated, existing, "v5.4.4")
290-
Expect(shouldEncumber).To(BeTrue())
286+
reg := test.Reconciler.Registration
287+
Expect(reg.TokenFileFound).To(BeTrue())
288+
Expect(reg.Authenticated).To(BeFalse())
289+
// Simulate an upgrade of the operator by bumping the Reconciler PGOVersion.
290+
shouldEncumber := shouldEncumberReconciliation(reg.Authenticated, existing, "v5.4.4")
291+
Expect(shouldEncumber).To(BeTrue())
292+
})
291293
})
292-
})
293294
294-
Context("Old Unregistered Cluster with Registration Requirement, need to Encumber", func() {
295-
var cluster *v1beta1.PostgresCluster
296-
297-
BeforeEach(func() {
298-
test.Reconciler.PGOVersion = "v5.4.3"
299-
// REGISTRATION_REQUIRED will be set by OLM installers.
300-
os.Setenv("REGISTRATION_REQUIRED", "true")
301-
ctx := context.Background()
302-
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
303-
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "", logging.FromContext(ctx))
304-
test.Reconciler.PGOVersion = "v5.4.3"
305-
cluster = create(olmClusterYAML)
306-
Expect(reconcile(cluster)).To(BeZero())
307-
})
308-
309-
AfterEach(func() {
310-
ctx := context.Background()
311-
312-
if cluster != nil {
313-
Expect(client.IgnoreNotFound(
314-
suite.Client.Delete(ctx, cluster),
315-
)).To(Succeed())
316-
317-
// Remove finalizers, if any, so the namespace can terminate.
318-
Expect(client.IgnoreNotFound(
319-
suite.Client.Patch(ctx, cluster, client.RawPatch(
320-
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
295+
Context("Old Unregistered Cluster with Registration Requirement, need to Encumber", func() {
296+
var cluster *v1beta1.PostgresCluster
297+
298+
BeforeEach(func() {
299+
test.Reconciler.PGOVersion = "v5.4.3"
300+
// REGISTRATION_REQUIRED will be set by OLM installers.
301+
os.Setenv("REGISTRATION_REQUIRED", "true")
302+
ctx := context.Background()
303+
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
304+
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "", logging.FromContext(ctx))
305+
test.Reconciler.PGOVersion = "v5.4.3"
306+
cluster = create(olmClusterYAML)
307+
Expect(reconcile(cluster)).To(BeZero())
308+
})
309+
310+
AfterEach(func() {
311+
ctx := context.Background()
312+
313+
if cluster != nil {
314+
Expect(client.IgnoreNotFound(
315+
suite.Client.Delete(ctx, cluster),
316+
)).To(Succeed())
317+
318+
// Remove finalizers, if any, so the namespace can terminate.
319+
Expect(client.IgnoreNotFound(
320+
suite.Client.Patch(ctx, cluster, client.RawPatch(
321+
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
322+
)).To(Succeed())
323+
}
324+
os.Unsetenv("REGISTRATION_REQUIRED")
325+
})
326+
327+
Specify("Cluster RegistrationRequired Status", func() {
328+
existing := &v1beta1.PostgresCluster{}
329+
Expect(suite.Client.Get(
330+
context.Background(), client.ObjectKeyFromObject(cluster), existing,
321331
)).To(Succeed())
322-
}
323-
os.Unsetenv("REGISTRATION_REQUIRED")
324-
})
325-
326-
Specify("Cluster RegistrationRequired Status", func() {
327-
existing := &v1beta1.PostgresCluster{}
328-
Expect(suite.Client.Get(
329-
context.Background(), client.ObjectKeyFromObject(cluster), existing,
330-
)).To(Succeed())
331332
332-
reg := test.Reconciler.Registration
333-
Expect(reg.TokenFileFound).To(BeFalse())
334-
Expect(reg.Authenticated).To(BeFalse())
333+
reg := test.Reconciler.Registration
334+
Expect(reg.TokenFileFound).To(BeFalse())
335+
Expect(reg.Authenticated).To(BeFalse())
335336
336-
// Simulate an upgrade of the operator.
337-
shouldEncumber := shouldEncumberReconciliation(reg.Authenticated, existing, "v5.4.4")
338-
Expect(shouldEncumber).To(BeTrue())
337+
// Simulate an upgrade of the operator.
338+
shouldEncumber := shouldEncumberReconciliation(reg.Authenticated, existing, "v5.4.4")
339+
Expect(shouldEncumber).To(BeTrue())
340+
})
339341
})
340-
})
341-
342-
Context("New Registered Cluster with Registration Requirement, no need to Encumber", func() {
343-
var cluster *v1beta1.PostgresCluster
344342
345-
BeforeEach(func() {
346-
test.Reconciler.PGOVersion = "v5.4.2"
347-
// REGISTRATION_REQUIRED will be set by OLM installers.
348-
os.Setenv("REGISTRATION_REQUIRED", "true")
349-
350-
ctx := context.Background()
351-
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
352-
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "../../testing/cpk_token", logging.FromContext(ctx))
353-
test.Reconciler.PGOVersion = "v5.4.3"
354-
355-
cluster = create(olmClusterYAML)
356-
Expect(reconcile(cluster)).To(BeZero())
357-
})
358-
359-
AfterEach(func() {
360-
ctx := context.Background()
361-
362-
if cluster != nil {
363-
Expect(client.IgnoreNotFound(
364-
suite.Client.Delete(ctx, cluster),
343+
Context("New Registered Cluster with Registration Requirement, no need to Encumber", func() {
344+
var cluster *v1beta1.PostgresCluster
345+
346+
BeforeEach(func() {
347+
test.Reconciler.PGOVersion = "v5.4.2"
348+
// REGISTRATION_REQUIRED will be set by OLM installers.
349+
os.Setenv("REGISTRATION_REQUIRED", "true")
350+
351+
ctx := context.Background()
352+
rsaKey, _ := os.ReadFile("../../../cpk_rsa_key.pub")
353+
test.Reconciler.Registration = util.GetRegistration(string(rsaKey), "../../testing/cpk_token", logging.FromContext(ctx))
354+
test.Reconciler.PGOVersion = "v5.4.3"
355+
356+
cluster = create(olmClusterYAML)
357+
Expect(reconcile(cluster)).To(BeZero())
358+
})
359+
360+
AfterEach(func() {
361+
ctx := context.Background()
362+
363+
if cluster != nil {
364+
Expect(client.IgnoreNotFound(
365+
suite.Client.Delete(ctx, cluster),
366+
)).To(Succeed())
367+
368+
// Remove finalizers, if any, so the namespace can terminate.
369+
Expect(client.IgnoreNotFound(
370+
suite.Client.Patch(ctx, cluster, client.RawPatch(
371+
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
372+
)).To(Succeed())
373+
}
374+
os.Unsetenv("REGISTRATION_REQUIRED")
375+
})
376+
377+
Specify("Cluster RegistrationRequired Status", func() {
378+
existing := &v1beta1.PostgresCluster{}
379+
Expect(suite.Client.Get(
380+
context.Background(), client.ObjectKeyFromObject(cluster), existing,
365381
)).To(Succeed())
366382
367-
// Remove finalizers, if any, so the namespace can terminate.
368-
Expect(client.IgnoreNotFound(
369-
suite.Client.Patch(ctx, cluster, client.RawPatch(
370-
client.Merge.Type(), []byte(`{"metadata":{"finalizers":[]}}`))),
371-
)).To(Succeed())
372-
}
373-
os.Unsetenv("REGISTRATION_REQUIRED")
383+
registrationRequired := config.RegistrationRequired()
384+
Expect(registrationRequired).To(BeTrue())
385+
386+
registrationRequiredStatus := existing.Status.RegistrationRequired
387+
Expect(registrationRequiredStatus).To(BeNil())
388+
389+
reg := test.Reconciler.Registration
390+
shouldEncumber := shouldEncumberReconciliation(reg.Authenticated, existing, "v5.4.2")
391+
Expect(shouldEncumber).To(BeFalse())
392+
Expect(reg.TokenFileFound).To(BeTrue())
393+
Expect(reg.Authenticated).To(BeTrue())
394+
Expect(reg.Aud).To(Equal("CPK"))
395+
Expect(reg.Sub).To(Equal("[email protected]"))
396+
Expect(reg.Iss).To(Equal("Crunchy Data"))
397+
Expect(reg.Exp).To(Equal(int64(1727451935)))
398+
Expect(reg.Nbf).To(Equal(int64(1516239022)))
399+
Expect(reg.Iat).To(Equal(int64(1516239022)))
400+
})
374401
})
375-
376-
Specify("Cluster RegistrationRequired Status", func() {
377-
existing := &v1beta1.PostgresCluster{}
378-
Expect(suite.Client.Get(
379-
context.Background(), client.ObjectKeyFromObject(cluster), existing,
380-
)).To(Succeed())
381-
382-
registrationRequired := config.RegistrationRequired()
383-
Expect(registrationRequired).To(BeTrue())
384-
385-
registrationRequiredStatus := existing.Status.RegistrationRequired
386-
Expect(registrationRequiredStatus).To(BeNil())
387-
388-
reg := test.Reconciler.Registration
389-
shouldEncumber := shouldEncumberReconciliation(reg.Authenticated, existing, "v5.4.2")
390-
Expect(shouldEncumber).To(BeFalse())
391-
Expect(reg.TokenFileFound).To(BeTrue())
392-
Expect(reg.Authenticated).To(BeTrue())
393-
Expect(reg.Aud).To(Equal("CPK"))
394-
Expect(reg.Sub).To(Equal("[email protected]"))
395-
Expect(reg.Iss).To(Equal("Crunchy Data"))
396-
Expect(reg.Exp).To(Equal(int64(1727451935)))
397-
Expect(reg.Nbf).To(Equal(int64(1516239022)))
398-
Expect(reg.Iat).To(Equal(int64(1516239022)))
399-
})
400-
})
401402
*/
402403

403404
Context("Cluster", func() {

0 commit comments

Comments
 (0)