From c2f72ecd0c6ee743f2bb87f65796091dfb3375a0 Mon Sep 17 00:00:00 2001 From: Gerard Nguyen Date: Tue, 30 Apr 2024 12:13:35 +1000 Subject: [PATCH] feat: [sc-103119] URI is not replacing the spec but merging instead (#1537) fix uri spec to replace origin spec --- cmd/troubleshoot/cli/run.go | 3 ++- cmd/troubleshoot/cli/run_test.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/troubleshoot/cli/run.go b/cmd/troubleshoot/cli/run.go index 92d8ec37..bd39e498 100644 --- a/cmd/troubleshoot/cli/run.go +++ b/cmd/troubleshoot/cli/run.go @@ -273,7 +273,8 @@ func loadSupportBundleSpecsFromURIs(ctx context.Context, kinds *loader.Troublesh return err } - kinds.Add(moreKinds) + // uri spec replaces the original spec + *kinds = *moreKinds return nil } diff --git a/cmd/troubleshoot/cli/run_test.go b/cmd/troubleshoot/cli/run_test.go index 26d75c3f..30442d52 100644 --- a/cmd/troubleshoot/cli/run_test.go +++ b/cmd/troubleshoot/cli/run_test.go @@ -57,8 +57,9 @@ spec: err = loadSupportBundleSpecsFromURIs(ctx, kinds) require.NoError(t, err) - require.Len(t, kinds.SupportBundlesV1Beta2, 2) - assert.NotNil(t, kinds.SupportBundlesV1Beta2[1].Spec.Collectors[0].ClusterInfo) + // valid uri spec will replace the original spec + require.Len(t, kinds.SupportBundlesV1Beta2, 1) + assert.NotNil(t, kinds.SupportBundlesV1Beta2[0].Spec.Collectors[0].ClusterInfo) } func Test_loadSupportBundleSpecsFromURIs_TimeoutError(t *testing.T) {