From bb1519500ac82c6ecf60dc0aac3be02ba38e4709 Mon Sep 17 00:00:00 2001 From: Caleb Washburn Date: Mon, 12 Feb 2024 13:26:36 -0700 Subject: [PATCH 1/2] fixing errors where relationship cannot be set when updating quotas --- quota/quota.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quota/quota.go b/quota/quota.go index b751cbdc..1c64a5eb 100644 --- a/quota/quota.go +++ b/quota/quota.go @@ -4,6 +4,9 @@ import ( "context" "encoding/json" "fmt" + "reflect" + "strings" + "github.com/cloudfoundry-community/go-cfclient/v3/client" "github.com/cloudfoundry-community/go-cfclient/v3/resource" "github.com/pkg/errors" @@ -11,8 +14,6 @@ import ( "github.com/vmwarepivotallabs/cf-mgmt/organizationreader" "github.com/vmwarepivotallabs/cf-mgmt/space" "github.com/xchapter7x/lo" - "reflect" - "strings" ) // NewManager - @@ -274,6 +275,7 @@ func (m *Manager) UpdateSpaceQuota(quotaGUID string, quota *resource.SpaceQuotaC return nil } lo.G.Infof("Updating space quota %s", *quota.Name) + quota.Relationships = nil _, err := m.SpaceQuoteClient.Update(context.Background(), quotaGUID, quota) return err } From ac92f34a87aaa8debbe7a30e626f656ee3ba6099 Mon Sep 17 00:00:00 2001 From: Caleb Washburn Date: Tue, 13 Feb 2024 08:04:19 -0700 Subject: [PATCH 2/2] fix unit test for quota --- .gitignore | 1 + quota/quota_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 63c244c1..fff99f0e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ publish-develop.sh make-binary.sh .idea test-for-pagination.sh +export-cli.sh diff --git a/quota/quota_test.go b/quota/quota_test.go index 133c21dc..7d8e878d 100644 --- a/quota/quota_test.go +++ b/quota/quota_test.go @@ -288,7 +288,7 @@ var _ = Describe("given QuotaManager", func() { _, quotaGUID, quotaRequest := fakeSpaceQuotaClient.UpdateArgsForCall(0) Expect(quotaGUID).Should(Equal("space-quota-guid")) Expect(*quotaRequest.Name).Should(Equal("space1")) - Expect(quotaRequest.Relationships).ShouldNot(BeNil()) + Expect(quotaRequest.Relationships).Should(BeNil()) Expect(fakeSpaceQuotaClient.ApplyCallCount()).Should(Equal(1)) _, quotaGUID, spaceGUIDs := fakeSpaceQuotaClient.ApplyArgsForCall(0) Expect(quotaGUID).Should(Equal("space-quota-guid"))