Skip to content

Commit 115c62a

Browse files
committed
chore: main merge
2 parents add60a9 + 12a5f50 commit 115c62a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1824
-417
lines changed

.github/workflows/pr-issue-validator.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,20 @@ jobs:
3939
TITLE: ${{ github.event.pull_request.title }}
4040
run: |
4141
set -x
42+
echo "base or target repo : ${{ github.event.pull_request.base.repo.full_name }}"
43+
echo "head or source repo : ${{ github.event.pull_request.head.repo.full_name }}"
44+
if [[ ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.event.pull_request.base.repo.full_name }} ]]; then
45+
export forked=false
46+
else
47+
export forked=true
48+
fi
49+
echo "forked: $forked"
4250
if [[ "$TITLE" == *"doc:"* || "$TITLE" == *"docs:"* || "$TITLE" == *"chore:"* || "$TITLE" == *"release:"* || "$TITLE" == *"Release:"* ]]; then
4351
echo "Skipping validation as this is a PR for documentation or chore."
52+
if [[ $forked == true ]]; then
53+
echo "PR:Ready-to-Review, exiting gracefully"
54+
exit 0
55+
fi
4456
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
4557
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
4658
exit 0
@@ -78,6 +90,10 @@ jobs:
7890
echo "issue_num is : $issue_num"
7991
else
8092
echo "No Issue number detected hence failing the PR Validation check."
93+
if [[ $forked == true ]]; then
94+
echo "PR:Issue-verification-failed, exiting forcefully!"
95+
exit 1
96+
fi
8197
gh pr edit $PRNUM --add-label "PR:Issue-verification-failed"
8298
gh pr edit $PRNUM --remove-label "PR:Ready-to-Review"
8399
exit 1
@@ -105,17 +121,31 @@ jobs:
105121
if [[ $(echo "$text" | jq -r '.state') == "open" ]]; then
106122
echo "Issue #$issue_num is open"
107123
echo "Issue reference found in the pull request body."
124+
if [[ $forked == true ]]; then
125+
echo "PR:Ready-to-Review, exiting gracefully"
126+
exit 0
127+
fi
108128
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
109129
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
110130
exit 0
111131
else
112132
echo "Issue #$issue_num is not open"
133+
if [[ $forked == true ]]; then
134+
echo "PR:Issue-verification-failed, exiting forcefully!"
135+
exit 1
136+
fi
137+
gh pr edit $PRNUM --add-label "PR:Issue-verification-failed"
138+
gh pr edit $PRNUM --remove-label "PR:Ready-to-Review"
113139
exit 1
114140
fi
115141
else
116142
echo "Invalid Response Code obtained - error code: $response_code"
117143
echo "No valid issue reference found in the pull request body."
118144
gh pr comment $PRNUM --body "PR is not linked to any issue, please make the corresponding changes in the body."
145+
if [[ $forked == true ]]; then
146+
echo "PR:Issue-verification-failed, exiting forcefully!"
147+
exit 1
148+
fi
119149
gh pr edit $PRNUM --add-label "PR:Issue-verification-failed"
120150
gh pr edit $PRNUM --remove-label "PR:Ready-to-Review"
121151
exit 1

Wire.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ func InitializeApp() (*App, error) {
965965
argocdServer.NewArgoClientWrapperServiceImpl,
966966
wire.Bind(new(argocdServer.ArgoClientWrapperService), new(*argocdServer.ArgoClientWrapperServiceImpl)),
967967

968+
pipeline.NewPluginInputVariableParserImpl,
969+
wire.Bind(new(pipeline.PluginInputVariableParser), new(*pipeline.PluginInputVariableParserImpl)),
970+
968971
pipeline.NewPipelineConfigListenerServiceImpl,
969972
wire.Bind(new(pipeline.PipelineConfigListenerService), new(*pipeline.PipelineConfigListenerServiceImpl)),
970973
)

api/bean/CustomTag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type CustomTag struct {
66
TagPattern string `json:"tagPattern"`
77
AutoIncreasingNumber int `json:"counterX"`
88
Metadata string `json:"metadata"`
9+
Enabled bool `json:"enabled"`
910
}
1011

1112
type CustomTagErrorResponse struct {

api/bean/ValuesOverrideRequest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,7 @@ type ArtifactsListFilterOptions struct {
123123

124124
//excludeWfRunners
125125
ExcludeWfrIds []int
126+
127+
//pluginStage
128+
PluginStage string
126129
}

api/restHandler/PipelineTriggerRestHandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (handler PipelineTriggerRestHandlerImpl) OverrideConfig(w http.ResponseWrit
133133
span.End()
134134
if err != nil {
135135
handler.logger.Errorw("request err, OverrideConfig", "err", err, "payload", overrideRequest)
136-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
136+
common.WriteJsonResp(w, err, err.Error(), http.StatusInternalServerError)
137137
return
138138
}
139139
res := map[string]interface{}{"releaseId": mergeResp}

api/restHandler/app/BuildPipelineRestHandler.go

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ func (handler PipelineConfigRestHandlerImpl) TriggerCiPipeline(w http.ResponseWr
596596
resp, err := handler.ciHandler.HandleCIManual(ciTriggerRequest)
597597
if errors.Is(err, bean1.ErrImagePathInUse) {
598598
handler.Logger.Errorw("service err duplicate image tag, TriggerCiPipeline", "err", err, "payload", ciTriggerRequest)
599-
common.WriteJsonResp(w, err, response, http.StatusConflict)
599+
common.WriteJsonResp(w, err, err, http.StatusConflict)
600600
return
601601
}
602602
if err != nil {
@@ -1976,27 +1976,49 @@ func (handler PipelineConfigRestHandlerImpl) extractCipipelineMetaForImageTags(a
19761976
externalCi = false
19771977
ciPipelineId = 0
19781978
appId = 0
1979-
1980-
ciPipeline, err := handler.ciPipelineRepository.GetCiPipelineByArtifactId(artifactId)
1981-
var externalCiPipeline *pipelineConfig.ExternalCiPipeline
1979+
ciArtifact, err := handler.ciArtifactRepository.Get(artifactId)
19821980
if err != nil {
1983-
if err == pg.ErrNoRows {
1984-
handler.Logger.Infow("no ciPipeline found by artifact Id, fetching external ci-pipeline ", "artifactId", artifactId)
1985-
externalCiPipeline, err = handler.ciPipelineRepository.GetExternalCiPipelineByArtifactId(artifactId)
1986-
}
1981+
handler.Logger.Errorw("Error in fetching ci artifact by ci artifact id", "err", err)
1982+
return externalCi, ciPipelineId, appId, err
1983+
}
1984+
if ciArtifact.DataSource == repository.POST_CI {
1985+
ciPipelineId = ciArtifact.ComponentId
1986+
ciPipeline, err := handler.pipelineBuilder.GetCiPipelineById(ciPipelineId)
19871987
if err != nil {
1988-
handler.Logger.Errorw("error occurred in fetching ciPipeline/externalCiPipeline by artifact Id ", "err", err, "artifactId", artifactId)
1988+
handler.Logger.Errorw("no ci pipeline found for given artifact", "err", err, "artifactId", artifactId, "ciPipelineId", ciPipelineId)
19891989
return externalCi, ciPipelineId, appId, err
19901990
}
1991-
}
1992-
1993-
if ciPipeline.Id != 0 {
1994-
ciPipelineId = ciPipeline.Id
19951991
appId = ciPipeline.AppId
1992+
} else if ciArtifact.DataSource == repository.PRE_CD || ciArtifact.DataSource == repository.POST_CD {
1993+
cdPipelineId := ciArtifact.ComponentId
1994+
cdPipeline, err := handler.pipelineBuilder.GetCdPipelineById(cdPipelineId)
1995+
if err != nil {
1996+
handler.Logger.Errorw("no cd pipeline found for given artifact", "err", err, "artifactId", artifactId, "cdPipelineId", cdPipelineId)
1997+
return externalCi, ciPipelineId, appId, err
1998+
}
1999+
ciPipelineId = cdPipeline.CiPipelineId
2000+
appId = cdPipeline.AppId
19962001
} else {
1997-
externalCi = true
1998-
ciPipelineId = externalCiPipeline.Id
1999-
appId = externalCiPipeline.AppId
2002+
ciPipeline, err := handler.ciPipelineRepository.GetCiPipelineByArtifactId(artifactId)
2003+
var externalCiPipeline *pipelineConfig.ExternalCiPipeline
2004+
if err != nil {
2005+
if err == pg.ErrNoRows {
2006+
handler.Logger.Infow("no ciPipeline found by artifact Id, fetching external ci-pipeline ", "artifactId", artifactId)
2007+
externalCiPipeline, err = handler.ciPipelineRepository.GetExternalCiPipelineByArtifactId(artifactId)
2008+
}
2009+
if err != nil {
2010+
handler.Logger.Errorw("error occurred in fetching ciPipeline/externalCiPipeline by artifact Id ", "err", err, "artifactId", artifactId)
2011+
return externalCi, ciPipelineId, appId, err
2012+
}
2013+
}
2014+
if ciPipeline.Id != 0 {
2015+
ciPipelineId = ciPipeline.Id
2016+
appId = ciPipeline.AppId
2017+
} else {
2018+
externalCi = true
2019+
ciPipelineId = externalCiPipeline.Id
2020+
appId = externalCiPipeline.AppId
2021+
}
20002022
}
20012023
return externalCi, ciPipelineId, appId, nil
20022024
}

api/restHandler/app/PipelineConfigRestHandler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ type PipelineConfigRestHandlerImpl struct {
130130
imageTaggingService pipeline.ImageTaggingService
131131
deploymentTemplateService generateManifest.DeploymentTemplateService
132132
pipelineRestHandlerEnvConfig *PipelineRestHandlerEnvConfig
133+
ciArtifactRepository repository.CiArtifactRepository
133134
}
134135

135136
func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger,
@@ -153,7 +154,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
153154
materialRepository pipelineConfig.MaterialRepository, policyService security2.PolicyService,
154155
scanResultRepository security.ImageScanResultRepository, gitProviderRepo repository.GitProviderRepository,
155156
argoUserService argo.ArgoUserService, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
156-
imageTaggingService pipeline.ImageTaggingService) *PipelineConfigRestHandlerImpl {
157+
imageTaggingService pipeline.ImageTaggingService,
158+
ciArtifactRepository repository.CiArtifactRepository) *PipelineConfigRestHandlerImpl {
157159
envConfig := &PipelineRestHandlerEnvConfig{}
158160
err := env.Parse(envConfig)
159161
if err != nil {
@@ -190,6 +192,7 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
190192
imageTaggingService: imageTaggingService,
191193
deploymentTemplateService: deploymentTemplateService,
192194
pipelineRestHandlerEnvConfig: envConfig,
195+
ciArtifactRepository: ciArtifactRepository,
193196
}
194197
}
195198

api/router/ApplicationRouter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func (r ApplicationRouterImpl) initApplicationRouter(router *mux.Router) {
7979
router.Path("/{applicationName}/managed-resources").
8080
Methods("GET").
8181
HandlerFunc(r.handler.ManagedResources)
82-
router.Path("/{name}/rollback").
82+
router.Path("/{name}" +
83+
"/rollback").
8384
Methods("GET").
8485
HandlerFunc(r.handler.Rollback)
8586

api/router/pubsub/CiEventHandler.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,22 @@ type ImageDetailsFromCR struct {
6161
}
6262

6363
type CiCompleteEvent struct {
64-
CiProjectDetails []bean2.CiProjectDetails `json:"ciProjectDetails"`
65-
DockerImage string `json:"dockerImage" validate:"required,image-validator"`
66-
Digest string `json:"digest"`
67-
PipelineId int `json:"pipelineId"`
68-
WorkflowId *int `json:"workflowId"`
69-
TriggeredBy int32 `json:"triggeredBy"`
70-
PipelineName string `json:"pipelineName"`
71-
DataSource string `json:"dataSource"`
72-
MaterialType string `json:"materialType"`
73-
Metrics util.CIMetrics `json:"metrics"`
74-
AppName string `json:"appName"`
75-
IsArtifactUploaded bool `json:"isArtifactUploaded"`
76-
FailureReason string `json:"failureReason"`
77-
ImageDetailsFromCR *ImageDetailsFromCR `json:"imageDetailsFromCR"`
64+
CiProjectDetails []bean2.CiProjectDetails `json:"ciProjectDetails"`
65+
DockerImage string `json:"dockerImage" validate:"required,image-validator"`
66+
Digest string `json:"digest"`
67+
PipelineId int `json:"pipelineId"`
68+
WorkflowId *int `json:"workflowId"`
69+
TriggeredBy int32 `json:"triggeredBy"`
70+
PipelineName string `json:"pipelineName"`
71+
DataSource string `json:"dataSource"`
72+
MaterialType string `json:"materialType"`
73+
Metrics util.CIMetrics `json:"metrics"`
74+
AppName string `json:"appName"`
75+
IsArtifactUploaded bool `json:"isArtifactUploaded"`
76+
FailureReason string `json:"failureReason"`
77+
ImageDetailsFromCR *ImageDetailsFromCR `json:"imageDetailsFromCR"`
78+
PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
79+
PluginArtifactStage string `json:"pluginArtifactStage"`
7880
}
7981

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

216218
request := &pipeline.CiArtifactWebhookRequest{
217-
Image: event.DockerImage,
218-
ImageDigest: event.Digest,
219-
DataSource: event.DataSource,
220-
PipelineName: event.PipelineName,
221-
MaterialInfo: rawMaterialInfo,
222-
UserId: event.TriggeredBy,
223-
WorkflowId: event.WorkflowId,
224-
IsArtifactUploaded: event.IsArtifactUploaded,
219+
Image: event.DockerImage,
220+
ImageDigest: event.Digest,
221+
DataSource: event.DataSource,
222+
PipelineName: event.PipelineName,
223+
MaterialInfo: rawMaterialInfo,
224+
UserId: event.TriggeredBy,
225+
WorkflowId: event.WorkflowId,
226+
IsArtifactUploaded: event.IsArtifactUploaded,
227+
PluginRegistryArtifactDetails: event.PluginRegistryArtifactDetails,
228+
PluginArtifactStage: event.PluginArtifactStage,
225229
}
226230
return request, nil
227231
}

api/router/pubsub/WorkflowStatusUpdateHandler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ func (impl *WorkflowStatusUpdateHandlerImpl) SubscribeCD() error {
125125
impl.logger.Errorw("could not get wf runner", "err", err)
126126
return
127127
}
128+
if wfrStatus == string(v1alpha1.NodeFailed) || wfrStatus == string(v1alpha1.NodeError) {
129+
if len(wfr.ImagePathReservationIds) > 0 {
130+
err := impl.cdHandler.DeactivateImageReservationPathsOnFailure(wfr.ImagePathReservationIds)
131+
if err != nil {
132+
impl.logger.Errorw("error in removing image path reservation ")
133+
}
134+
}
135+
}
128136
if wfrStatus == string(v1alpha1.NodeSucceeded) || wfrStatus == string(v1alpha1.NodeFailed) || wfrStatus == string(v1alpha1.NodeError) {
129137
eventType := util.EventType(0)
130138
if wfrStatus == string(v1alpha1.NodeSucceeded) {

0 commit comments

Comments
 (0)