@@ -29,6 +29,7 @@ import (
2929 openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient"
3030 "github.com/devtron-labs/devtron/client/argocdServer"
3131 "github.com/devtron-labs/devtron/internal/sql/repository/app"
32+ repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
3233 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/timelineStatus"
3334 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
3435 "github.com/devtron-labs/devtron/internal/util"
@@ -90,6 +91,7 @@ type AppStoreDeploymentServiceImpl struct {
9091 deletePostProcessor DeletePostProcessor
9192 appStoreValidator AppStoreValidator
9293 deploymentConfigService common.DeploymentConfigService
94+ OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository
9395}
9496
9597func NewAppStoreDeploymentServiceImpl (logger * zap.SugaredLogger ,
@@ -109,7 +111,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
109111 gitOpsConfigReadService config.GitOpsConfigReadService , deletePostProcessor DeletePostProcessor ,
110112 appStoreValidator AppStoreValidator ,
111113 deploymentConfigService common.DeploymentConfigService ,
112- ) * AppStoreDeploymentServiceImpl {
114+ OCIRegistryConfigRepository repository2. OCIRegistryConfigRepository ) * AppStoreDeploymentServiceImpl {
113115
114116 return & AppStoreDeploymentServiceImpl {
115117 logger : logger ,
@@ -130,6 +132,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
130132 deletePostProcessor : deletePostProcessor ,
131133 appStoreValidator : appStoreValidator ,
132134 deploymentConfigService : deploymentConfigService ,
135+ OCIRegistryConfigRepository : OCIRegistryConfigRepository ,
133136 }
134137}
135138
@@ -951,7 +954,49 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta
951954 }
952955
953956 // STEP-2 update APP with chart info
954- chartRepoInfo := appStoreAppVersion .AppStore .ChartRepo
957+ //TODO: below code is duplicated
958+ var IsOCIRepo bool
959+ var registryCredential * bean4.RegistryCredential
960+ var chartRepository * bean4.ChartRepository
961+ dockerRegistryId := appStoreAppVersion .AppStore .DockerArtifactStoreId
962+ if dockerRegistryId != "" {
963+ ociRegistryConfigs , err := impl .OCIRegistryConfigRepository .FindByDockerRegistryId (dockerRegistryId )
964+ if err != nil {
965+ impl .logger .Errorw ("error in fetching oci registry config" , "err" , err )
966+ return nil , err
967+ }
968+ var ociRegistryConfig * repository2.OCIRegistryConfig
969+ for _ , config := range ociRegistryConfigs {
970+ if config .RepositoryAction == repository2 .STORAGE_ACTION_TYPE_PULL || config .RepositoryAction == repository2 .STORAGE_ACTION_TYPE_PULL_AND_PUSH {
971+ ociRegistryConfig = config
972+ break
973+ }
974+ }
975+ IsOCIRepo = true
976+ registryCredential = & bean4.RegistryCredential {
977+ RegistryUrl : appStoreAppVersion .AppStore .DockerArtifactStore .RegistryURL ,
978+ Username : appStoreAppVersion .AppStore .DockerArtifactStore .Username ,
979+ Password : appStoreAppVersion .AppStore .DockerArtifactStore .Password ,
980+ AwsRegion : appStoreAppVersion .AppStore .DockerArtifactStore .AWSRegion ,
981+ AccessKey : appStoreAppVersion .AppStore .DockerArtifactStore .AWSAccessKeyId ,
982+ SecretKey : appStoreAppVersion .AppStore .DockerArtifactStore .AWSSecretAccessKey ,
983+ RegistryType : string (appStoreAppVersion .AppStore .DockerArtifactStore .RegistryType ),
984+ RepoName : appStoreAppVersion .AppStore .Name ,
985+ IsPublic : ociRegistryConfig .IsPublic ,
986+ Connection : appStoreAppVersion .AppStore .DockerArtifactStore .Connection ,
987+ RegistryName : appStoreAppVersion .AppStore .DockerArtifactStore .Id ,
988+ RegistryCertificate : appStoreAppVersion .AppStore .DockerArtifactStore .Cert ,
989+ }
990+ } else {
991+ chartRepository = & bean4.ChartRepository {
992+ Name : appStoreAppVersion .AppStore .ChartRepo .Name ,
993+ Url : appStoreAppVersion .AppStore .ChartRepo .Url ,
994+ Username : appStoreAppVersion .AppStore .ChartRepo .UserName ,
995+ Password : appStoreAppVersion .AppStore .ChartRepo .Password ,
996+ AllowInsecureConnection : appStoreAppVersion .AppStore .ChartRepo .AllowInsecureConnection ,
997+ }
998+ }
999+
9551000 updateReleaseRequest := & bean3.UpdateApplicationWithChartInfoRequestDto {
9561001 InstallReleaseRequest : & bean4.InstallReleaseRequest {
9571002 ValuesYaml : installAppVersionRequest .ValuesOverrideYaml ,
@@ -961,18 +1006,14 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta
9611006 ReleaseNamespace : installAppVersionRequest .Namespace ,
9621007 ReleaseName : installAppVersionRequest .DisplayName ,
9631008 },
1009+ RegistryCredential : registryCredential ,
1010+ ChartRepository : chartRepository ,
1011+ IsOCIRepo : IsOCIRepo ,
1012+ InstallAppVersionHistoryId : 0 ,
9641013 },
9651014 SourceAppType : bean3 .SOURCE_HELM_APP ,
9661015 }
967- if chartRepoInfo != nil {
968- updateReleaseRequest .ChartRepository = & bean4.ChartRepository {
969- Name : chartRepoInfo .Name ,
970- Url : chartRepoInfo .Url ,
971- Username : chartRepoInfo .UserName ,
972- Password : chartRepoInfo .Password ,
973- AllowInsecureConnection : chartRepoInfo .AllowInsecureConnection ,
974- }
975- }
1016+
9761017 res , err := impl .helmAppService .UpdateApplicationWithChartInfo (ctx , installAppVersionRequest .ClusterId , updateReleaseRequest )
9771018 if err != nil {
9781019 return nil , err
0 commit comments