@@ -20,6 +20,7 @@ package appStoreDeploymentFullMode
2020import (
2121 "context"
2222 "github.com/devtron-labs/devtron/client/argocdServer"
23+ repository2 "github.com/devtron-labs/devtron/internal/sql/repository"
2324 appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
2425 repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository"
2526 appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository"
@@ -35,8 +36,6 @@ import (
3536 "time"
3637
3738 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
38- repository2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository"
39- "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
4039 application2 "github.com/devtron-labs/devtron/client/argocdServer/application"
4140 "github.com/devtron-labs/devtron/client/argocdServer/repository"
4241 "github.com/devtron-labs/devtron/internal/util"
@@ -54,7 +53,6 @@ const (
5453type AppStoreDeploymentFullModeService interface {
5554 AppStoreDeployOperationGIT (installAppVersionRequest * appStoreBean.InstallAppVersionDTO ) (* appStoreBean.InstallAppVersionDTO , * util.ChartGitAttribute , error )
5655 AppStoreDeployOperationACD (installAppVersionRequest * appStoreBean.InstallAppVersionDTO , chartGitAttr * util.ChartGitAttribute , ctx context.Context ) (* appStoreBean.InstallAppVersionDTO , error )
57- RegisterInArgo (chartGitAttribute * util.ChartGitAttribute , ctx context.Context ) error
5856 SyncACD (acdAppName string , ctx context.Context )
5957 UpdateValuesYaml (installAppVersionRequest * appStoreBean.InstallAppVersionDTO ) (* appStoreBean.InstallAppVersionDTO , error )
6058 UpdateRequirementYaml (installAppVersionRequest * appStoreBean.InstallAppVersionDTO , appStoreAppVersion * appStoreDiscoverRepository.AppStoreApplicationVersion ) error
@@ -76,6 +74,7 @@ type AppStoreDeploymentFullModeServiceImpl struct {
7674 installedAppRepository repository4.InstalledAppRepository
7775 tokenCache * util2.TokenCache
7876 argoUserService argo.ArgoUserService
77+ gitOpsConfigRepository repository2.GitOpsConfigRepository
7978}
8079
8180func NewAppStoreDeploymentFullModeServiceImpl (logger * zap.SugaredLogger ,
@@ -237,8 +236,13 @@ func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationGIT(ins
237236func (impl AppStoreDeploymentFullModeServiceImpl ) AppStoreDeployOperationACD (installAppVersionRequest * appStoreBean.InstallAppVersionDTO , chartGitAttr * util.ChartGitAttribute , ctx context.Context ) (* appStoreBean.InstallAppVersionDTO , error ) {
238237 ctx , cancel := context .WithTimeout (ctx , 1 * time .Minute )
239238 defer cancel ()
239+ gitOpsConfig , err := impl .gitOpsConfigRepository .GetGitOpsConfigActive ()
240+ if err != nil {
241+ impl .logger .Errorw ("error in getting active gitOps config" , "err" , err )
242+ return nil , err
243+ }
240244 //STEP 4: registerInArgo
241- err : = impl .RegisterInArgo (chartGitAttr , ctx )
245+ err = impl .chartTemplateService . RegisterInArgo (chartGitAttr , ctx , gitOpsConfig . AllowInsecureTLS )
242246 if err != nil {
243247 impl .logger .Errorw ("error in argo registry" , "err" , err )
244248 return nil , err
@@ -255,18 +259,6 @@ func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(ins
255259 return installAppVersionRequest , nil
256260}
257261
258- func (impl AppStoreDeploymentFullModeServiceImpl ) RegisterInArgo (chartGitAttribute * util.ChartGitAttribute , ctx context.Context ) error {
259- repo := & v1alpha1.Repository {
260- Repo : chartGitAttribute .RepoUrl ,
261- }
262- repo , err := impl .repositoryService .Create (ctx , & repository2.RepoCreateRequest {Repo : repo , Upsert : true })
263- if err != nil {
264- impl .logger .Errorw ("error in creating argo Repository " , "err" , err )
265- }
266- impl .logger .Debugw ("repo registered in argo" , "name" , chartGitAttribute .RepoUrl )
267- return err
268- }
269-
270262func (impl AppStoreDeploymentFullModeServiceImpl ) SyncACD (acdAppName string , ctx context.Context ) {
271263 req := new (application.ApplicationSyncRequest )
272264 req .Name = & acdAppName
0 commit comments