@@ -29,7 +29,6 @@ import (
29
29
"time"
30
30
31
31
cluster3 "github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster"
32
- "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
33
32
"github.com/devtron-labs/devtron/client/grafana"
34
33
"github.com/devtron-labs/devtron/internal/constants"
35
34
"github.com/devtron-labs/devtron/internal/util"
@@ -236,37 +235,11 @@ func (impl *ClusterServiceImplExtended) Update(ctx context.Context, bean *bean.C
236
235
237
236
}
238
237
239
- // if git-ops configured, then only update cluster in ACD, otherwise ignore
238
+ // if git-ops configured and ArgoCD module is installed , then only update cluster in ACD, otherwise ignore
240
239
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 })
269
240
241
+ cl := impl .ConvertClusterBeanObjectToCluster (bean )
242
+ _ , err = impl .argoCDClientWrapper .CreateCluster (ctx , & cluster3.ClusterCreateRequest {Upsert : true , Cluster : cl })
270
243
if err != nil {
271
244
impl .logger .Errorw ("service err, Update" , "error" , err , "payload" , cl )
272
245
userMsg := "failed to update on cluster via ACD"
@@ -349,7 +322,7 @@ func (impl *ClusterServiceImplExtended) Save(ctx context.Context, bean *bean.Clu
349
322
return nil , err
350
323
}
351
324
352
- // if git-ops configured, then only add cluster in ACD, otherwise ignore
325
+ // if git-ops configured and ArgoCD module is installed , then only add cluster in ACD, otherwise ignore
353
326
if gitOpsConfigurationStatus .IsGitOpsConfiguredAndArgoCdInstalled () {
354
327
//create it into argo cd as well
355
328
cl := impl .ConvertClusterBeanObjectToCluster (bean )
0 commit comments