@@ -29,7 +29,6 @@ import (
2929 "time"
3030
3131 cluster3 "github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster"
32- "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
3332 "github.com/devtron-labs/devtron/client/grafana"
3433 "github.com/devtron-labs/devtron/internal/constants"
3534 "github.com/devtron-labs/devtron/internal/util"
@@ -238,35 +237,9 @@ func (impl *ClusterServiceImplExtended) Update(ctx context.Context, bean *bean.C
238237
239238 // if git-ops configured, then only update cluster in ACD, otherwise ignore
240239 if gitOpsConfigurationStatus .IsGitOpsConfiguredAndArgoCdInstalled () {
241- configMap := bean .Config
242- serverUrl := bean .ServerUrl
243- bearerToken := ""
244- if configMap [commonBean .BearerToken ] != "" {
245- bearerToken = configMap [commonBean .BearerToken ]
246- }
247-
248- tlsConfig := v1alpha1.TLSClientConfig {
249- Insecure : bean .InsecureSkipTLSVerify ,
250- }
251- if ! bean .InsecureSkipTLSVerify {
252- tlsConfig .KeyData = []byte (configMap [commonBean .TlsKey ])
253- tlsConfig .CertData = []byte (configMap [commonBean .CertData ])
254- tlsConfig .CAData = []byte (configMap [commonBean .CertificateAuthorityData ])
255- }
256-
257- cdClusterConfig := v1alpha1.ClusterConfig {
258- BearerToken : bearerToken ,
259- TLSClientConfig : tlsConfig ,
260- }
261-
262- cl := & v1alpha1.Cluster {
263- Name : bean .ClusterName ,
264- Server : serverUrl ,
265- Config : cdClusterConfig ,
266- }
267-
268- _ , err = impl .argoCDClientWrapper .UpdateCluster (ctx , & cluster3.ClusterUpdateRequest {Cluster : cl })
269240
241+ cl := impl .ConvertClusterBeanObjectToCluster (bean )
242+ _ , err = impl .argoCDClientWrapper .CreateCluster (ctx , & cluster3.ClusterCreateRequest {Upsert : true , Cluster : cl })
270243 if err != nil {
271244 impl .logger .Errorw ("service err, Update" , "error" , err , "payload" , cl )
272245 userMsg := "failed to update on cluster via ACD"
0 commit comments