@@ -19,26 +19,28 @@ package app
19
19
import (
20
20
"context"
21
21
"fmt"
22
- argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean"
23
- "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
24
- repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
25
- "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics"
26
- util2 "github.com/devtron-labs/devtron/util"
27
- "net/http"
28
- "strconv"
29
- "strings"
30
- "time"
31
- "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/read"
32
22
"github.com/devtron-labs/common-lib/utils/k8s/health"
23
+ argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean"
33
24
"github.com/devtron-labs/devtron/internal/middleware"
34
25
"github.com/devtron-labs/devtron/internal/sql/repository/app"
26
+ "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
35
27
userrepository "github.com/devtron-labs/devtron/pkg/auth/user/repository"
28
+ ciConfig "github.com/devtron-labs/devtron/pkg/build/pipeline/read"
36
29
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
30
+ repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
31
+ "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics"
32
+ "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/read"
37
33
"github.com/devtron-labs/devtron/pkg/dockerRegistry"
34
+ "github.com/devtron-labs/devtron/pkg/pipeline/constants"
35
+ util2 "github.com/devtron-labs/devtron/util"
38
36
"github.com/devtron-labs/devtron/util/argo"
39
37
errors2 "github.com/juju/errors"
40
38
"go.opentelemetry.io/otel"
41
39
"golang.org/x/exp/slices"
40
+ "net/http"
41
+ "strconv"
42
+ "strings"
43
+ "time"
42
44
43
45
"github.com/devtron-labs/devtron/api/bean"
44
46
application2 "github.com/devtron-labs/devtron/client/argocdServer/application"
@@ -145,6 +147,7 @@ type AppListingServiceImpl struct {
145
147
deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService
146
148
ciArtifactRepository repository.CiArtifactRepository
147
149
envConfigOverrideReadService read.EnvConfigOverrideService
150
+ ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService
148
151
}
149
152
150
153
func NewAppListingServiceImpl (Logger * zap.SugaredLogger , appListingRepository repository.AppListingRepository ,
@@ -156,7 +159,8 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re
156
159
chartRepository chartRepoRepository.ChartRepository , ciPipelineRepository pipelineConfig.CiPipelineRepository ,
157
160
dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService , userRepository userrepository.UserRepository ,
158
161
deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService , ciArtifactRepository repository.CiArtifactRepository ,
159
- envConfigOverrideReadService read.EnvConfigOverrideService ) * AppListingServiceImpl {
162
+ envConfigOverrideReadService read.EnvConfigOverrideService ,
163
+ ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService ) * AppListingServiceImpl {
160
164
serviceImpl := & AppListingServiceImpl {
161
165
Logger : Logger ,
162
166
appListingRepository : appListingRepository ,
@@ -176,6 +180,7 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re
176
180
deployedAppMetricsService : deployedAppMetricsService ,
177
181
ciArtifactRepository : ciArtifactRepository ,
178
182
envConfigOverrideReadService : envConfigOverrideReadService ,
183
+ ciPipelineConfigReadService : ciPipelineConfigReadService ,
179
184
}
180
185
return serviceImpl
181
186
}
@@ -780,11 +785,28 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a
780
785
}
781
786
782
787
if ciPipeline != nil && ciPipeline .CiTemplate != nil && len (* ciPipeline .CiTemplate .DockerRegistryId ) > 0 {
783
- dockerRegistryId := ciPipeline .CiTemplate .DockerRegistryId
784
- appDetailContainer .DockerRegistryId = * dockerRegistryId
785
- if ! ciPipeline .IsExternal || ciPipeline .ParentCiPipeline != 0 {
788
+ if ! ciPipeline .IsExternal || ciPipeline .ParentCiPipeline != 0 && ciPipeline .PipelineType != string (constants .LINKED_CD ) {
786
789
appDetailContainer .IsExternalCi = false
787
790
}
791
+ // get dockerRegistryId starts
792
+ artifact , err := impl .ciArtifactRepository .Get (appDetailContainer .CiArtifactId )
793
+ if err != nil {
794
+ impl .Logger .Errorw ("error in fetching ci artifact" , "ciArtifactId" , appDetailContainer .CiArtifactId , "error" , err )
795
+ return bean.AppDetailContainer {}, err
796
+ }
797
+ dockerRegistryId , err := impl .ciPipelineConfigReadService .GetDockerRegistryIdForCiPipeline (ciPipelineId , artifact )
798
+ if err != nil {
799
+ impl .Logger .Errorw ("error in fetching docker registry id" , "ciPipelineId" , ciPipelineId , "error" , err )
800
+ return bean.AppDetailContainer {}, err
801
+ }
802
+
803
+ if dockerRegistryId == nil {
804
+ impl .Logger .Errorw ("docker registry id not found" , "ciPipelineId" , ciPipelineId )
805
+ return appDetailContainer , nil
806
+ }
807
+ // get dockerRegistryId ends
808
+ appDetailContainer .DockerRegistryId = * dockerRegistryId
809
+
788
810
_ , span = otel .Tracer ("orchestrator" ).Start (ctx , "dockerRegistryIpsConfigService.IsImagePullSecretAccessProvided" )
789
811
// check ips access provided to this docker registry for that cluster
790
812
ipsAccessProvided , err := impl .dockerRegistryIpsConfigService .IsImagePullSecretAccessProvided (* dockerRegistryId , clusterId , isVirtualEnv )
0 commit comments