From 75ec3f2a16eec086d01860bb4521329b36005e44 Mon Sep 17 00:00:00 2001 From: Andrew Costa Date: Wed, 28 Jun 2023 16:10:46 -0700 Subject: [PATCH] Org repository sets deletion time [#2605] Co-authored-by: Dave Walter --- api/repositories/org_repository.go | 6 ++++++ api/repositories/org_repository_test.go | 1 + 2 files changed, 7 insertions(+) diff --git a/api/repositories/org_repository.go b/api/repositories/org_repository.go index 6423f70bc..d9070f250 100644 --- a/api/repositories/org_repository.go +++ b/api/repositories/org_repository.go @@ -244,6 +244,11 @@ func (r *OrgRepo) PatchOrgMetadata(ctx context.Context, authInfo authorization.I func cfOrgToOrgRecord(cfOrg korifiv1alpha1.CFOrg) OrgRecord { updatedAtTime, _ := getTimeLastUpdatedTimestamp(&cfOrg.ObjectMeta) + deletedAtTime := "" + if cfOrg.DeletionTimestamp != nil { + deletedAtTime = formatTimestamp(*cfOrg.DeletionTimestamp) + } + return OrgRecord{ GUID: cfOrg.Name, Name: cfOrg.Spec.DisplayName, @@ -252,5 +257,6 @@ func cfOrgToOrgRecord(cfOrg korifiv1alpha1.CFOrg) OrgRecord { Annotations: cfOrg.Annotations, CreatedAt: formatTimestamp(cfOrg.CreationTimestamp), UpdatedAt: updatedAtTime, + DeletedAt: deletedAtTime, } } diff --git a/api/repositories/org_repository_test.go b/api/repositories/org_repository_test.go index 8299c691a..716e49aae 100644 --- a/api/repositories/org_repository_test.go +++ b/api/repositories/org_repository_test.go @@ -140,6 +140,7 @@ var _ = Describe("OrgRepository", func() { updatedAt, err := time.Parse(time.RFC3339, org.UpdatedAt) Expect(err).NotTo(HaveOccurred()) Expect(updatedAt).To(BeTemporally("~", time.Now(), 2*time.Second)) + Expect(org.DeletedAt).To(BeEmpty()) Expect(org.Labels).To(Equal(map[string]string{"test-label-key": "test-label-val"})) Expect(org.Annotations).To(Equal(map[string]string{"test-annotation-key": "test-annotation-val"})) })