From 436e9c28805ed4faa2346291c93336232ab63428 Mon Sep 17 00:00:00 2001 From: Kangyi LI Date: Fri, 18 Oct 2024 12:45:21 +0000 Subject: [PATCH] overwrite cr by incoming data instead of appending to the old data --- pkg/remoteconfig/orchestrator_k8s_crd.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/remoteconfig/orchestrator_k8s_crd.go b/pkg/remoteconfig/orchestrator_k8s_crd.go index d2faee780..a8ec55c75 100644 --- a/pkg/remoteconfig/orchestrator_k8s_crd.go +++ b/pkg/remoteconfig/orchestrator_k8s_crd.go @@ -98,8 +98,12 @@ func (r *RemoteConfigUpdater) crdUpdateInstanceStatus(dda v2alpha1.DatadogAgent, } // Orchestrator Explorer - if cfg.ClusterAgent != nil && cfg.ClusterAgent.CRDs != nil && len(*cfg.ClusterAgent.CRDs.Crds) > 0 { - newddaStatus.RemoteConfigConfiguration.Features.OrchestratorExplorer.CustomResources = append(newddaStatus.RemoteConfigConfiguration.Features.OrchestratorExplorer.CustomResources, *cfg.ClusterAgent.CRDs.Crds...) + if cfg.ClusterAgent != nil && cfg.ClusterAgent.CRDs != nil { + newddaStatus.RemoteConfigConfiguration.Features.OrchestratorExplorer.CustomResources = []string{} + // Overwrite custom resources by the new ones + if cfg.ClusterAgent.CRDs.Crds != nil { + newddaStatus.RemoteConfigConfiguration.Features.OrchestratorExplorer.CustomResources = *cfg.ClusterAgent.CRDs.Crds + } newddaStatus.RemoteConfigConfiguration.Features.OrchestratorExplorer.CustomResources = removeDuplicateStr(newddaStatus.RemoteConfigConfiguration.Features.OrchestratorExplorer.CustomResources) }