From 03f24c5ffc92d6e00f821625bc518350fae79cac Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Wed, 24 Apr 2024 11:57:13 +0100 Subject: [PATCH] Refine ownership conflict error messages and fix associated tests Signed-off-by: Ilya Dmitrichenko --- cmd/timoni/apply_test.go | 2 +- cmd/timoni/bundle_apply_test.go | 6 +++--- internal/reconciler/types.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/timoni/apply_test.go b/cmd/timoni/apply_test.go index 471010c4..f4ffc104 100644 --- a/cmd/timoni/apply_test.go +++ b/cmd/timoni/apply_test.go @@ -235,7 +235,7 @@ bundle: { modPath, )) g.Expect(err).To(HaveOccurred()) - g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by bundle \"%s\"", instanceName, bundleName))) + g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by another bundle \"%s\"", instanceName, bundleName))) output, err := executeCommand(fmt.Sprintf("ls -n %[1]s", namespace)) g.Expect(err).ToNot(HaveOccurred()) diff --git a/cmd/timoni/bundle_apply_test.go b/cmd/timoni/bundle_apply_test.go index 272ea702..31b480d9 100644 --- a/cmd/timoni/bundle_apply_test.go +++ b/cmd/timoni/bundle_apply_test.go @@ -155,8 +155,8 @@ bundle: { _, err = executeCommandWithIn("bundle apply -f - -p main --wait", strings.NewReader(anotherBundleData)) g.Expect(err).To(HaveOccurred()) - g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by another bundle \"%s\"", "frontend", bundleName))) - g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by another bundle \"%s\"", "backend", bundleName))) + g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance %q exists and is managed by another bundle %q", "frontend", bundleName))) + g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance %q exists and is managed by another bundle %q", "backend", bundleName))) }) t.Run("fails to create instances from partially overlapping bundle", func(t *testing.T) { @@ -247,7 +247,7 @@ bundle: { _, err = executeCommandWithIn("bundle apply -f - -p main --wait", strings.NewReader(bundleData)) g.Expect(err).To(HaveOccurred()) - g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by no bundle", instanceName))) + g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is not managed by any bundle", instanceName))) }) } diff --git a/internal/reconciler/types.go b/internal/reconciler/types.go index 79aa990f..41dafda9 100644 --- a/internal/reconciler/types.go +++ b/internal/reconciler/types.go @@ -85,9 +85,9 @@ func (e *InstanceOwnershipConflictErr) Error() string { numConflicts := len(*e) for i, c := range *e { if c.CurrentOwnerBundle != "" { - s.WriteString(fmt.Sprintf("instance %q exists and is managed by bundle %q", c.InstanceName, c.CurrentOwnerBundle)) + s.WriteString(fmt.Sprintf("instance %q exists and is managed by another bundle %q", c.InstanceName, c.CurrentOwnerBundle)) } else { - s.WriteString(fmt.Sprintf("instance %q exists and is managed by no bundle", c.InstanceName)) + s.WriteString(fmt.Sprintf("instance %q exists and is not managed by any bundle", c.InstanceName)) } if numConflicts > 1 && i != numConflicts { s.WriteString("; ")