@@ -29,6 +29,7 @@ import (
29
29
openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient"
30
30
"github.com/devtron-labs/devtron/client/argocdServer"
31
31
"github.com/devtron-labs/devtron/internal/sql/repository/app"
32
+ repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
32
33
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/timelineStatus"
33
34
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
34
35
"github.com/devtron-labs/devtron/internal/util"
@@ -90,6 +91,7 @@ type AppStoreDeploymentServiceImpl struct {
90
91
deletePostProcessor DeletePostProcessor
91
92
appStoreValidator AppStoreValidator
92
93
deploymentConfigService common.DeploymentConfigService
94
+ OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository
93
95
}
94
96
95
97
func NewAppStoreDeploymentServiceImpl (logger * zap.SugaredLogger ,
@@ -109,7 +111,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
109
111
gitOpsConfigReadService config.GitOpsConfigReadService , deletePostProcessor DeletePostProcessor ,
110
112
appStoreValidator AppStoreValidator ,
111
113
deploymentConfigService common.DeploymentConfigService ,
112
- ) * AppStoreDeploymentServiceImpl {
114
+ OCIRegistryConfigRepository repository2. OCIRegistryConfigRepository ) * AppStoreDeploymentServiceImpl {
113
115
114
116
return & AppStoreDeploymentServiceImpl {
115
117
logger : logger ,
@@ -130,6 +132,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
130
132
deletePostProcessor : deletePostProcessor ,
131
133
appStoreValidator : appStoreValidator ,
132
134
deploymentConfigService : deploymentConfigService ,
135
+ OCIRegistryConfigRepository : OCIRegistryConfigRepository ,
133
136
}
134
137
}
135
138
@@ -951,7 +954,49 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta
951
954
}
952
955
953
956
// 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
+
955
1000
updateReleaseRequest := & bean3.UpdateApplicationWithChartInfoRequestDto {
956
1001
InstallReleaseRequest : & bean4.InstallReleaseRequest {
957
1002
ValuesYaml : installAppVersionRequest .ValuesOverrideYaml ,
@@ -961,18 +1006,14 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta
961
1006
ReleaseNamespace : installAppVersionRequest .Namespace ,
962
1007
ReleaseName : installAppVersionRequest .DisplayName ,
963
1008
},
1009
+ RegistryCredential : registryCredential ,
1010
+ ChartRepository : chartRepository ,
1011
+ IsOCIRepo : IsOCIRepo ,
1012
+ InstallAppVersionHistoryId : 0 ,
964
1013
},
965
1014
SourceAppType : bean3 .SOURCE_HELM_APP ,
966
1015
}
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
+
976
1017
res , err := impl .helmAppService .UpdateApplicationWithChartInfo (ctx , installAppVersionRequest .ClusterId , updateReleaseRequest )
977
1018
if err != nil {
978
1019
return nil , err
0 commit comments