Skip to content
Merged
Show file tree
Hide file tree
Changes from 160 commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
8a7d822
Add custom tag
avdhesh-devtron Aug 24, 2023
127ad00
Refactor handle concurrency
avdhesh-devtron Aug 24, 2023
d5c6102
Refactor
avdhesh-devtron Aug 24, 2023
c559393
Update workflow when trigger failes due to tag conflict
avdhesh-devtron Aug 25, 2023
3dfde7a
Fix error
avdhesh-devtron Aug 25, 2023
2768ea5
temp
avdhesh-devtron Aug 25, 2023
e3da3b8
Build history failure case
avdhesh-devtron Aug 25, 2023
ae8b894
Merge branch 'custom-tag' of github.com:devtron-labs/devtron into ref…
avdhesh-devtron Aug 25, 2023
edd2d54
Custom tag logic extracted
avdhesh-devtron Aug 28, 2023
abd20e8
Fix build
avdhesh-devtron Aug 28, 2023
bd6b603
fix get query
avdhesh-devtron Aug 28, 2023
f97fac5
fix error handling
avdhesh-devtron Aug 28, 2023
9ebfbb5
fix iota value
avdhesh-devtron Aug 28, 2023
0818862
Fix errors
avdhesh-devtron Aug 28, 2023
ef9af2c
Return error when image path conflicts
avdhesh-devtron Aug 29, 2023
7c672de
Handle errors
avdhesh-devtron Aug 29, 2023
98cd350
Handle failed ci_workflow
avdhesh-devtron Aug 29, 2023
0b8efba
Handle failed ci_workflow
avdhesh-devtron Aug 29, 2023
47729b1
Remove unnecessary image path deactivation
avdhesh-devtron Aug 29, 2023
ec8510f
Fix migration
avdhesh-devtron Aug 29, 2023
a564454
Merge branch 'main' of github.com:devtron-labs/devtron into refactor-…
avdhesh-devtron Aug 29, 2023
bf99dce
Refactor
avdhesh-devtron Aug 29, 2023
720a99d
Refactor
avdhesh-devtron Aug 29, 2023
b841f29
Add validations
avdhesh-devtron Aug 29, 2023
c955e21
Remove regex check
avdhesh-devtron Aug 29, 2023
3ea5834
Fix error message
avdhesh-devtron Aug 29, 2023
8fde21d
Return bad request in case of trigger
avdhesh-devtron Aug 29, 2023
0f3c248
add validation
avdhesh-devtron Aug 30, 2023
06edac9
add validation
avdhesh-devtron Aug 30, 2023
df484ca
ad ci workflow id in status api
avdhesh-devtron Aug 30, 2023
786121b
add comments
avdhesh-devtron Aug 31, 2023
500a256
main merge
iamayushm Oct 4, 2023
1febd7d
custom image tag migration
iamayushm Oct 4, 2023
ec1dd53
sql script correction
iamayushm Oct 4, 2023
8f3a54b
fix: validation and sql script
iamayushm Oct 5, 2023
33ae161
fixing null value in custom tag
iamayushm Oct 5, 2023
558928c
Merge branch 'main' into refactor-tag-generation
iamayushm Oct 9, 2023
74f1c38
marking image tag unreserved on abort
iamayushm Oct 11, 2023
5ab08bb
main merge
iamayushm Oct 11, 2023
1252c91
main merge
iamayushm Oct 17, 2023
a0c5a10
wip
gireesh-naidu Oct 19, 2023
4f80365
wip
gireesh-naidu Oct 19, 2023
29d5e8c
ci type parent artifats fetched
gireesh-naidu Oct 19, 2023
6beb311
commented not required data
gireesh-naidu Oct 19, 2023
3a68687
custom tag cd and in trigger api
iamayushm Oct 19, 2023
0d0ed18
almost done, optimise TODOs
gireesh-naidu Oct 19, 2023
673570d
pagination done for OSS
gireesh-naidu Oct 19, 2023
d043980
calling V2 function in resthandler
gireesh-naidu Oct 19, 2023
2bf1cd3
bug fix for no deployment triggered on the pipeline and query fix for…
gireesh-naidu Oct 20, 2023
d78a097
query fix for emptyexclude artifacts ids
gireesh-naidu Oct 20, 2023
89351cf
code review comments
kripanshdevtron Oct 20, 2023
3a1f591
Merge branch 'main' into refactor-tag-generation
iamayushm Oct 23, 2023
15b3ba1
migration script fix
iamayushm Oct 23, 2023
2ff5cf8
fix get api
iamayushm Oct 23, 2023
badac18
tag validation updated
iamayushm Oct 23, 2023
849ebfe
wip: validaion using regex
iamayushm Oct 23, 2023
87420ff
wip
iamayushm Oct 23, 2023
784b65a
fix validation
iamayushm Oct 23, 2023
fca223a
fixing error string
iamayushm Oct 23, 2023
8b39dbe
fix validation
iamayushm Oct 23, 2023
20f35c6
tag validation updated
iamayushm Oct 23, 2023
a3277dc
tag pattern modification
iamayushm Oct 23, 2023
5f1a6c7
wip: fix
iamayushm Oct 25, 2023
d89d12e
fixing regex
iamayushm Oct 25, 2023
5be2095
Merge branch 'main' into refactor-tag-generation
iamayushm Oct 25, 2023
0f73a9b
wip custom tag
iamayushm Oct 25, 2023
b713e2d
pr review changes
iamayushm Oct 25, 2023
3112044
Merge branch 'refactor-tag-generation' into custom-tag-cd
iamayushm Oct 25, 2023
5d131db
Revert "Merge branch 'refactor-tag-generation' into custom-tag-cd"
iamayushm Oct 25, 2023
ee8fbbf
Revert "Revert "Merge branch 'refactor-tag-generation' into custom-ta…
iamayushm Oct 26, 2023
6fa35bd
enable disable changes
iamayushm Oct 26, 2023
a489727
tag enabled sql script
iamayushm Oct 26, 2023
d98117f
enable flag in get api
iamayushm Oct 26, 2023
c009e93
Merge remote-tracking branch 'origin/artifact-api-refactoring' into c…
iamayushm Oct 26, 2023
4787091
searchstring refactor fix
gireesh-naidu Oct 26, 2023
1402943
wip: get api fix
iamayushm Oct 26, 2023
b0021db
custom tag enabled moved outside
iamayushm Oct 26, 2023
cb0db3b
wip
iamayushm Oct 26, 2023
70e70d8
wip
iamayushm Oct 26, 2023
b1dad32
update api
iamayushm Oct 26, 2023
2349e43
wip
iamayushm Oct 27, 2023
a12e68d
Merge remote-tracking branch 'origin/artifact-api-refactoring' into c…
iamayushm Oct 27, 2023
5f35f1c
wip
iamayushm Oct 27, 2023
53532cf
added rollback API V2 in
gireesh-naidu Oct 27, 2023
4357070
added artifact createdOn time
gireesh-naidu Oct 30, 2023
73bcb32
pagination fix
gireesh-naidu Oct 30, 2023
dc61990
fix
gireesh-naidu Oct 30, 2023
c9acbb9
adding support for parent stage
iamayushm Oct 30, 2023
0ba2890
delete redundant ids
gireesh-naidu Oct 30, 2023
b505dc7
adding registry type and registry name flag in api
iamayushm Oct 30, 2023
964d135
hiding credential source type and value from request
iamayushm Oct 30, 2023
8d2d3fc
adding registry type and name flag
iamayushm Oct 30, 2023
8faf24a
fixes: trigger pre cd
iamayushm Oct 31, 2023
b9948a1
deleting cd custom tag on pipeline delete
iamayushm Oct 31, 2023
15cd7bc
setting data source value
gireesh-naidu Oct 31, 2023
d282ca2
sql script
gireesh-naidu Oct 31, 2023
37071c7
artifacts save code fix
iamayushm Oct 31, 2023
bf4f173
removing unnecessary information
iamayushm Oct 31, 2023
dea49ba
fix image api
iamayushm Nov 1, 2023
9f7aad3
adding plugin parent
iamayushm Nov 1, 2023
686ba66
queries optimised and created queryBuilder for getting artifacts list
gireesh-naidu Nov 1, 2023
f5a9425
sync oss code
gireesh-naidu Nov 1, 2023
851c7f4
optimise getting git-triggers logic
gireesh-naidu Nov 1, 2023
b2fbcfb
fix
gireesh-naidu Nov 1, 2023
0b39d41
post ci fixes
iamayushm Nov 2, 2023
6b40a61
required changes after merging api refactor branch
iamayushm Nov 2, 2023
feac3ea
fix list api
iamayushm Nov 2, 2023
1c96fe5
merge main
gireesh-naidu Nov 3, 2023
469d1a3
totalcount fix
gireesh-naidu Nov 3, 2023
84b3911
offset validation
gireesh-naidu Nov 3, 2023
1ff96d7
fixes post ci
iamayushm Nov 3, 2023
d45c1da
fix custom tag id
iamayushm Nov 3, 2023
ffe740f
custom tag fix and ci artifact api fix
iamayushm Nov 3, 2023
e4619ea
adding image_path_reservation_ids
iamayushm Nov 3, 2023
0324adb
code for deleting reserved tags
iamayushm Nov 3, 2023
2bf3ede
fix sql object
iamayushm Nov 3, 2023
a34e214
adding array field in sql object
iamayushm Nov 3, 2023
9bccb07
fix: custom tag enabled
iamayushm Nov 3, 2023
b4d7c84
api refactoring merge
iamayushm Nov 5, 2023
2444130
fix custom tag used even if disabled
iamayushm Nov 5, 2023
5075851
adding data source
iamayushm Nov 5, 2023
d495f9a
refactoring skopeo parsing
iamayushm Nov 5, 2023
9c0063c
sql script modified plus registry credentials
iamayushm Nov 5, 2023
6545b2b
removing source info handling and adding comments
iamayushm Nov 6, 2023
262792f
new cd workflow in case of auto trigger and plugin generated image
iamayushm Nov 6, 2023
b915cca
idempotency in saving artifacts and deploy cd workflow fix
iamayushm Nov 6, 2023
2e472ed
fix image order
iamayushm Nov 6, 2023
db0d216
fix cdWorkflow object
iamayushm Nov 6, 2023
f271155
removing unnecessary code
iamayushm Nov 6, 2023
4a03123
fix post trigger
iamayushm Nov 6, 2023
fa09e81
Merge branch 'main' into artifact-api-refactoring
gireesh-naidu Nov 7, 2023
90ae68e
showing source info
iamayushm Nov 7, 2023
2c6e251
sql script no fix
iamayushm Nov 8, 2023
86349c0
artifact api refactoring merge
iamayushm Nov 9, 2023
542bd77
enterprise sync
ShashwatDadhich Nov 10, 2023
abc6fad
qa fixes
iamayushm Nov 10, 2023
26ff795
offset issue
gireesh-naidu Nov 10, 2023
cc152f4
query change
gireesh-naidu Nov 10, 2023
47be577
query change
gireesh-naidu Nov 10, 2023
92aac1d
fix
gireesh-naidu Nov 10, 2023
13c60fb
fix
gireesh-naidu Nov 10, 2023
4d78b07
Merge branch 'main' into custom-tag-cd-v2
iamayushm Nov 14, 2023
686061f
upstream branch merge
iamayushm Nov 14, 2023
24fa757
down script file
iamayushm Nov 14, 2023
ba4bc33
fix migration script
iamayushm Nov 14, 2023
4acfa07
plugin migration
iamayushm Nov 14, 2023
6f4edfb
bug fixes
iamayushm Nov 15, 2023
20d5514
qa issue fix
iamayushm Nov 15, 2023
a736d11
bug fixes
iamayushm Nov 16, 2023
57d2eb1
bug fixes
iamayushm Nov 16, 2023
079e310
create ecr repo if not present
iamayushm Nov 16, 2023
39f27aa
bug fixes
iamayushm Nov 17, 2023
3f5129d
big fixes
iamayushm Nov 17, 2023
ebae885
sql script correction
iamayushm Nov 17, 2023
e328c05
bug fixes
iamayushm Nov 17, 2023
542072a
renaming skopeo to copy container image
iamayushm Nov 17, 2023
7e6d3cf
sql script update
iamayushm Nov 20, 2023
88a0b58
main merge
iamayushm Nov 20, 2023
98631ef
enterprise bugs
iamayushm Nov 20, 2023
b9eda3c
PE REVIEW CHANFS
iamayushm Nov 20, 2023
0d84636
updating plugin image in migration
iamayushm Nov 20, 2023
1ba1bac
Merge branch 'main' into custom-tag-cd-v2
iamayushm Nov 21, 2023
335f67e
sql script correction
iamayushm Nov 21, 2023
3871da4
sql script update
iamayushm Nov 21, 2023
2818509
Merge branch 'main' into custom-tag-cd-v2
iamayushm Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,9 @@ func InitializeApp() (*App, error) {

argocdServer.NewArgoClientWrapperServiceImpl,
wire.Bind(new(argocdServer.ArgoClientWrapperService), new(*argocdServer.ArgoClientWrapperServiceImpl)),

pipeline.NewPluginInputVariableParserImpl,
wire.Bind(new(pipeline.PluginInputVariableParser), new(*pipeline.PluginInputVariableParserImpl)),
)
return &App{}, nil
}
1 change: 1 addition & 0 deletions api/bean/CustomTag.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type CustomTag struct {
TagPattern string `json:"tagPattern"`
AutoIncreasingNumber int `json:"counterX"`
Metadata string `json:"metadata"`
Enabled bool `json:"enabled"`
}

type CustomTagErrorResponse struct {
Expand Down
4 changes: 4 additions & 0 deletions api/bean/ValuesOverrideRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ type ArtifactsListFilterOptions struct {

//excludeWfRunners
ExcludeWfrIds []int


//pluginStage
PluginStage string
}
2 changes: 1 addition & 1 deletion api/restHandler/PipelineTriggerRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (handler PipelineTriggerRestHandlerImpl) OverrideConfig(w http.ResponseWrit
span.End()
if err != nil {
handler.logger.Errorw("request err, OverrideConfig", "err", err, "payload", overrideRequest)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
common.WriteJsonResp(w, err, err.Error(), http.StatusInternalServerError)
return
}
res := map[string]interface{}{"releaseId": mergeResp}
Expand Down
54 changes: 38 additions & 16 deletions api/restHandler/app/BuildPipelineRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ func (handler PipelineConfigRestHandlerImpl) TriggerCiPipeline(w http.ResponseWr
resp, err := handler.ciHandler.HandleCIManual(ciTriggerRequest)
if errors.Is(err, bean1.ErrImagePathInUse) {
handler.Logger.Errorw("service err duplicate image tag, TriggerCiPipeline", "err", err, "payload", ciTriggerRequest)
common.WriteJsonResp(w, err, response, http.StatusConflict)
common.WriteJsonResp(w, err, err, http.StatusConflict)
return
}
if err != nil {
Expand Down Expand Up @@ -1976,27 +1976,49 @@ func (handler PipelineConfigRestHandlerImpl) extractCipipelineMetaForImageTags(a
externalCi = false
ciPipelineId = 0
appId = 0

ciPipeline, err := handler.ciPipelineRepository.GetCiPipelineByArtifactId(artifactId)
var externalCiPipeline *pipelineConfig.ExternalCiPipeline
ciArtifact, err := handler.ciArtifactRepository.Get(artifactId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this below code can be part of service

if err != nil {
if err == pg.ErrNoRows {
handler.Logger.Infow("no ciPipeline found by artifact Id, fetching external ci-pipeline ", "artifactId", artifactId)
externalCiPipeline, err = handler.ciPipelineRepository.GetExternalCiPipelineByArtifactId(artifactId)
}
handler.Logger.Errorw("Error in fetching ci artifact by ci artifact id", "err", err)
return externalCi, ciPipelineId, appId, err
}
if ciArtifact.DataSource == repository.POST_CI {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment down all the probable DataSource in model

ciPipelineId = ciArtifact.ComponentId
ciPipeline, err := handler.pipelineBuilder.GetCiPipelineById(ciPipelineId)
if err != nil {
handler.Logger.Errorw("error occurred in fetching ciPipeline/externalCiPipeline by artifact Id ", "err", err, "artifactId", artifactId)
handler.Logger.Errorw("no ci pipeline found for given artifact", "err", err, "artifactId", artifactId, "ciPipelineId", ciPipelineId)
return externalCi, ciPipelineId, appId, err
}
}

if ciPipeline.Id != 0 {
ciPipelineId = ciPipeline.Id
appId = ciPipeline.AppId
} else if ciArtifact.DataSource == repository.PRE_CD || ciArtifact.DataSource == repository.POST_CD {
cdPipelineId := ciArtifact.ComponentId
cdPipeline, err := handler.pipelineBuilder.GetCdPipelineById(cdPipelineId)
if err != nil {
handler.Logger.Errorw("no cd pipeline found for given artifact", "err", err, "artifactId", artifactId, "cdPipelineId", cdPipelineId)
return externalCi, ciPipelineId, appId, err
}
ciPipelineId = cdPipeline.CiPipelineId
appId = cdPipeline.AppId
} else {
externalCi = true
ciPipelineId = externalCiPipeline.Id
appId = externalCiPipeline.AppId
ciPipeline, err := handler.ciPipelineRepository.GetCiPipelineByArtifactId(artifactId)
var externalCiPipeline *pipelineConfig.ExternalCiPipeline
if err != nil {
if err == pg.ErrNoRows {
handler.Logger.Infow("no ciPipeline found by artifact Id, fetching external ci-pipeline ", "artifactId", artifactId)
externalCiPipeline, err = handler.ciPipelineRepository.GetExternalCiPipelineByArtifactId(artifactId)
}
if err != nil {
handler.Logger.Errorw("error occurred in fetching ciPipeline/externalCiPipeline by artifact Id ", "err", err, "artifactId", artifactId)
return externalCi, ciPipelineId, appId, err
}
}
if ciPipeline.Id != 0 {
ciPipelineId = ciPipeline.Id
appId = ciPipeline.AppId
} else {
externalCi = true
ciPipelineId = externalCiPipeline.Id
appId = externalCiPipeline.AppId
}
}
return externalCi, ciPipelineId, appId, nil
}
Expand Down
5 changes: 4 additions & 1 deletion api/restHandler/app/PipelineConfigRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type PipelineConfigRestHandlerImpl struct {
imageTaggingService pipeline.ImageTaggingService
deploymentTemplateService generateManifest.DeploymentTemplateService
pipelineRestHandlerEnvConfig *PipelineRestHandlerEnvConfig
ciArtifactRepository repository.CiArtifactRepository
}

func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger,
Expand All @@ -153,7 +154,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
materialRepository pipelineConfig.MaterialRepository, policyService security2.PolicyService,
scanResultRepository security.ImageScanResultRepository, gitProviderRepo repository.GitProviderRepository,
argoUserService argo.ArgoUserService, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
imageTaggingService pipeline.ImageTaggingService) *PipelineConfigRestHandlerImpl {
imageTaggingService pipeline.ImageTaggingService,
ciArtifactRepository repository.CiArtifactRepository) *PipelineConfigRestHandlerImpl {
envConfig := &PipelineRestHandlerEnvConfig{}
err := env.Parse(envConfig)
if err != nil {
Expand Down Expand Up @@ -190,6 +192,7 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
imageTaggingService: imageTaggingService,
deploymentTemplateService: deploymentTemplateService,
pipelineRestHandlerEnvConfig: envConfig,
ciArtifactRepository: ciArtifactRepository,
}
}

Expand Down
3 changes: 2 additions & 1 deletion api/router/ApplicationRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (r ApplicationRouterImpl) initApplicationRouter(router *mux.Router) {
router.Path("/{applicationName}/managed-resources").
Methods("GET").
HandlerFunc(r.handler.ManagedResources)
router.Path("/{name}/rollback").
router.Path("/{name}" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applicationName ?

"/rollback").
Methods("GET").
HandlerFunc(r.handler.Rollback)

Expand Down
48 changes: 26 additions & 22 deletions api/router/pubsub/CiEventHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,22 @@ type ImageDetailsFromCR struct {
}

type CiCompleteEvent struct {
CiProjectDetails []bean2.CiProjectDetails `json:"ciProjectDetails"`
DockerImage string `json:"dockerImage" validate:"required,image-validator"`
Digest string `json:"digest"`
PipelineId int `json:"pipelineId"`
WorkflowId *int `json:"workflowId"`
TriggeredBy int32 `json:"triggeredBy"`
PipelineName string `json:"pipelineName"`
DataSource string `json:"dataSource"`
MaterialType string `json:"materialType"`
Metrics util.CIMetrics `json:"metrics"`
AppName string `json:"appName"`
IsArtifactUploaded bool `json:"isArtifactUploaded"`
FailureReason string `json:"failureReason"`
ImageDetailsFromCR *ImageDetailsFromCR `json:"imageDetailsFromCR"`
CiProjectDetails []bean2.CiProjectDetails `json:"ciProjectDetails"`
DockerImage string `json:"dockerImage" validate:"required,image-validator"`
Digest string `json:"digest"`
PipelineId int `json:"pipelineId"`
WorkflowId *int `json:"workflowId"`
TriggeredBy int32 `json:"triggeredBy"`
PipelineName string `json:"pipelineName"`
DataSource string `json:"dataSource"`
MaterialType string `json:"materialType"`
Metrics util.CIMetrics `json:"metrics"`
AppName string `json:"appName"`
IsArtifactUploaded bool `json:"isArtifactUploaded"`
FailureReason string `json:"failureReason"`
ImageDetailsFromCR *ImageDetailsFromCR `json:"imageDetailsFromCR"`
PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
PluginArtifactStage string `json:"pluginArtifactStage"`
}

func NewCiEventHandlerImpl(logger *zap.SugaredLogger, pubsubClient *pubsub.PubSubClientServiceImpl, webhookService pipeline.WebhookService, ciEventConfig *CiEventConfig) *CiEventHandlerImpl {
Expand Down Expand Up @@ -214,14 +216,16 @@ func (impl *CiEventHandlerImpl) BuildCiArtifactRequest(event CiCompleteEvent) (*
}

request := &pipeline.CiArtifactWebhookRequest{
Image: event.DockerImage,
ImageDigest: event.Digest,
DataSource: event.DataSource,
PipelineName: event.PipelineName,
MaterialInfo: rawMaterialInfo,
UserId: event.TriggeredBy,
WorkflowId: event.WorkflowId,
IsArtifactUploaded: event.IsArtifactUploaded,
Image: event.DockerImage,
ImageDigest: event.Digest,
DataSource: event.DataSource,
PipelineName: event.PipelineName,
MaterialInfo: rawMaterialInfo,
UserId: event.TriggeredBy,
WorkflowId: event.WorkflowId,
IsArtifactUploaded: event.IsArtifactUploaded,
PluginRegistryArtifactDetails: event.PluginRegistryArtifactDetails,
PluginArtifactStage: event.PluginArtifactStage,
}
return request, nil
}
Expand Down
8 changes: 8 additions & 0 deletions api/router/pubsub/WorkflowStatusUpdateHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ func (impl *WorkflowStatusUpdateHandlerImpl) SubscribeCD() error {
impl.logger.Errorw("could not get wf runner", "err", err)
return
}
if wfrStatus == string(v1alpha1.NodeFailed) || wfrStatus == string(v1alpha1.NodeError) {
if len(wfr.ImagePathReservationIds) > 0 {
err := impl.cdHandler.DeactivateImageReservationPathsOnFailure(wfr.ImagePathReservationIds)
if err != nil {
impl.logger.Errorw("error in removing image path reservation ")
}
}
}
if wfrStatus == string(v1alpha1.NodeSucceeded) || wfrStatus == string(v1alpha1.NodeFailed) || wfrStatus == string(v1alpha1.NodeError) {
eventType := util.EventType(0)
if wfrStatus == string(v1alpha1.NodeSucceeded) {
Expand Down
Binary file added assets/ic-plugin-copy-container-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 66 additions & 19 deletions internal/sql/repository/CiArtifactRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ import (
"go.uber.org/zap"
)

type credentialsSource = string
type artifactsSourceType = string

const (
GLOBAL_CONTAINER_REGISTRY credentialsSource = "global_container_registry"
)
const (
CI_RUNNER artifactsSourceType = "CI-RUNNER"
WEBHOOK artifactsSourceType = "EXTERNAL"
PRE_CD artifactsSourceType = "pre_cd"
POST_CD artifactsSourceType = "post_cd"
PRE_CI artifactsSourceType = "pre_ci"
POST_CI artifactsSourceType = "post_ci"
GOCD artifactsSourceType = "GOCD"
)

type CiArtifactWithExtraData struct {
CiArtifact
PayloadSchema string
Expand All @@ -41,23 +57,26 @@ type CiArtifactWithExtraData struct {
}

type CiArtifact struct {
tableName struct{} `sql:"ci_artifact" pg:",discard_unknown_columns"`
Id int `sql:"id,pk"`
PipelineId int `sql:"pipeline_id"` //id of the ci pipeline from which this webhook was triggered
Image string `sql:"image,notnull"`
ImageDigest string `sql:"image_digest,notnull"`
MaterialInfo string `sql:"material_info"` //git material metadata json array string
DataSource string `sql:"data_source,notnull"`
WorkflowId *int `sql:"ci_workflow_id"`
ParentCiArtifact int `sql:"parent_ci_artifact"`
ScanEnabled bool `sql:"scan_enabled,notnull"`
Scanned bool `sql:"scanned,notnull"`
ExternalCiPipelineId int `sql:"external_ci_pipeline_id"`
IsArtifactUploaded bool `sql:"is_artifact_uploaded"`
DeployedTime time.Time `sql:"-"`
Deployed bool `sql:"-"`
Latest bool `sql:"-"`
RunningOnParent bool `sql:"-"`
tableName struct{} `sql:"ci_artifact" pg:",discard_unknown_columns"`
Id int `sql:"id,pk"`
PipelineId int `sql:"pipeline_id"` //id of the ci pipeline from which this webhook was triggered
Image string `sql:"image,notnull"`
ImageDigest string `sql:"image_digest,notnull"`
MaterialInfo string `sql:"material_info"` //git material metadata json array string
DataSource string `sql:"data_source,notnull"` // possible values -> (CI_RUNNER,ext,post_ci,pre_cd,post_cd) CI_runner is for normal build ci
WorkflowId *int `sql:"ci_workflow_id"`
ParentCiArtifact int `sql:"parent_ci_artifact"`
ScanEnabled bool `sql:"scan_enabled,notnull"`
Scanned bool `sql:"scanned,notnull"`
ExternalCiPipelineId int `sql:"external_ci_pipeline_id"`
IsArtifactUploaded bool `sql:"is_artifact_uploaded"`
CredentialsSourceType string `sql:"credentials_source_type"`
CredentialSourceValue string `sql:"credentials_source_value"`
ComponentId int `sql:"component_id"`
DeployedTime time.Time `sql:"-"`
Deployed bool `sql:"-"`
Latest bool `sql:"-"`
RunningOnParent bool `sql:"-"`
sql.AuditLog
}

Expand All @@ -83,6 +102,8 @@ type CiArtifactRepository interface {
GetArtifactsByParentCiWorkflowId(parentCiWorkflowId int) ([]string, error)
FetchArtifactsByCdPipelineIdV2(listingFilterOptions bean.ArtifactsListFilterOptions) ([]CiArtifactWithExtraData, int, error)
FindArtifactByListFilter(listingFilterOptions *bean.ArtifactsListFilterOptions) ([]CiArtifact, int, error)
GetArtifactsByDataSourceAndComponentId(dataSource string, componentId int) ([]CiArtifact, error)
FindCiArtifactByImagePaths(images []string) ([]CiArtifact, error)
}

type CiArtifactRepositoryImpl struct {
Expand Down Expand Up @@ -128,7 +149,7 @@ func (impl CiArtifactRepositoryImpl) GetArtifactParentCiAndWorkflowDetailsByIds(
}

err := impl.dbConnection.Model(&artifacts).
Column("ci_artifact.ci_workflow_id", "ci_artifact.parent_ci_artifact", "ci_artifact.external_ci_pipeline_id", "ci_artifact.id").
Column("ci_artifact.ci_workflow_id", "ci_artifact.parent_ci_artifact", "ci_artifact.external_ci_pipeline_id", "ci_artifact.id", "ci_artifact.pipeline_id").
Where("ci_artifact.id in (?)", pg.In(ids)).
Select()

Expand Down Expand Up @@ -554,7 +575,7 @@ func (impl CiArtifactRepositoryImpl) GetArtifactsByCDPipelineV2(cdPipelineId int
}

func GetCiMaterialInfo(materialInfo string, source string) ([]CiMaterialInfo, error) {
if source != "GOCD" && source != "CI-RUNNER" && source != "EXTERNAL" {
if source != "GOCD" && source != "CI-RUNNER" && source != "EXTERNAL" && source != "post_ci" && source != "pre_cd" && source != "post_cd" {
return nil, fmt.Errorf("datasource: %s not supported", source)
}
var ciMaterials []CiMaterialInfo
Expand Down Expand Up @@ -697,3 +718,29 @@ func (impl CiArtifactRepositoryImpl) FetchArtifactsByCdPipelineIdV2(listingFilte
}
return wfrList, totalCount, nil
}

func (impl CiArtifactRepositoryImpl) GetArtifactsByDataSourceAndComponentId(dataSource string, componentId int) ([]CiArtifact, error) {
var ciArtifacts []CiArtifact
err := impl.dbConnection.
Model(&ciArtifacts).
Where(" data_source=? and component_id=? ", dataSource, componentId).
Select()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("error in getting ci artifacts by data_source and component_id")
return ciArtifacts, err
}
return ciArtifacts, nil
}

func (impl CiArtifactRepositoryImpl) FindCiArtifactByImagePaths(images []string) ([]CiArtifact, error) {
var ciArtifacts []CiArtifact
err := impl.dbConnection.
Model(&ciArtifacts).
Where(" image in (?) ", pg.In(images)).
Select()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("error in getting ci artifacts by data_source and component_id")
return ciArtifacts, err
}
return ciArtifacts, nil
}
Loading