Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:validation for pipeline Type #4670

Merged
merged 39 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e6eb341
Bug(linked ci) : validation added
adi6859 Feb 13, 2024
7f42b03
Bug(linked ci) : sql script added
adi6859 Feb 13, 2024
d3a2bef
Bug(linked ci) : condition check
adi6859 Feb 13, 2024
ad7e9eb
Bug(linked ci) : error handling added
adi6859 Feb 13, 2024
8c325e6
Bug(linked ci) : sql file name updated
adi6859 Feb 13, 2024
661742b
Bug(linked ci) : validation added
adi6859 Feb 14, 2024
fc93d7e
Bug(linked ci) : message changed
adi6859 Feb 14, 2024
7a24161
Merge branch 'main' into bug-linked-ci
adi6859 Feb 19, 2024
6c2ca8f
story (version up) : sql file updated
adi6859 Feb 19, 2024
84266dd
story (version up) : comment added in sql file
adi6859 Feb 19, 2024
e3de8fe
Bug(linked ci) : validation changed
adi6859 Feb 19, 2024
525401f
Bug(linked ci) : validation changed
adi6859 Feb 20, 2024
65792a6
Bug(same image scan detail) : Normal job flag added
adi6859 Feb 21, 2024
2572fd3
Merge branch 'main' into bug-linked-ci
adi6859 Feb 21, 2024
e0d9a37
main merge
adi6859 Apr 12, 2024
ad7b996
Bug(linked ci) : normal job check removed
adi6859 Apr 16, 2024
542a92a
Bug(linked ci) : assets updated
adi6859 Apr 16, 2024
332686f
Bug(linked ci) : normal job added
adi6859 Apr 16, 2024
bee7710
Bug(linked ci) : comment removed
adi6859 Apr 17, 2024
39e2eb4
Merge branch 'main' into bug-linked-ci
adi6859 Apr 19, 2024
109e004
Merge branch 'main' into bug-linked-ci
adi6859 Apr 22, 2024
3764708
Bug(linked ci) : sql file no. updated
adi6859 Apr 22, 2024
829e88a
Merge branch 'main' into bug-linked-ci
adi6859 May 6, 2024
86e0a3b
code commented
adi6859 May 6, 2024
b4c9962
bug(linked ci): sql file updated
adi6859 May 7, 2024
90548f5
bug(linked ci): validation added
adi6859 May 7, 2024
6bea8b9
all comments removed related to bug
adi6859 May 7, 2024
8b58dea
comment added
adi6859 May 7, 2024
48c35e1
logger updated
adi6859 May 7, 2024
e748dff
Merge branch 'main' into bug-linked-ci
adi6859 May 9, 2024
7109f73
code review comment resolved
adi6859 May 9, 2024
f1abd41
error message updated
adi6859 May 10, 2024
655dfc1
Merge branch 'main' into bug-linked-ci
adi6859 May 10, 2024
4515cf0
Merge branch 'main' into bug-linked-ci
adi6859 May 14, 2024
6826685
main merge
adi6859 May 14, 2024
aa33cdd
sql file name changed
adi6859 May 14, 2024
3fad085
Merge branch 'main' into bug-linked-ci
adi6859 May 14, 2024
3ed7b66
sql file no. updated
adi6859 May 14, 2024
0f76bf3
Merge branch 'main' into bug-linked-ci
adi6859 May 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (handler PipelineConfigRestHandlerImpl) PatchCiPipelines(w http.ResponseWri
}
createResp, err := handler.pipelineBuilder.PatchCiPipeline(&patchRequest)
if err != nil {
if err.Error() == bean1.PIPELINE_NAME_ALREADY_EXISTS_ERROR {
if err.Error() == bean1.PIPELINE_NAME_ALREADY_EXISTS_ERROR || err.Error() == bean1.PIPELINE_TYPE_IS_NOT_VALID {
handler.Logger.Errorw("service err, pipeline name already exist ", "err", err)
adi6859 marked this conversation as resolved.
Show resolved Hide resolved
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand Down
9 changes: 9 additions & 0 deletions pkg/bean/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ type ExternalCiConfigRole struct {
type PatchAction int
type PipelineType string

func (pType PipelineType) IsValidPipelineType() bool {
switch pType {
case NORMAL, LINKED, EXTERNAL, CI_JOB, LINKED_CD:
return true
default:
return false
}
}

const (
CREATE PatchAction = iota
UPDATE_SOURCE //update value of SourceTypeConfig
Expand Down
5 changes: 4 additions & 1 deletion pkg/pipeline/CiCdPipelineOrchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,10 @@ func (impl CiCdPipelineOrchestratorImpl) CreateCiConf(createRequest *bean.CiConf
}
// Rollback tx on error.
defer tx.Rollback()

if !ciPipeline.PipelineType.IsValidPipelineType() {
impl.logger.Debugw(" Invalid PipelineType", "ciPipeline.PipelineType", ciPipeline.PipelineType)
return nil, errors.New(bean2.PIPELINE_TYPE_IS_NOT_VALID)
}
ciPipelineObject := &pipelineConfig.CiPipeline{
AppId: createRequest.AppId,
IsManual: ciPipeline.IsManual,
Expand Down
1 change: 1 addition & 0 deletions pkg/pipeline/bean/CiBuildConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Main = "main"
const UniquePlaceHolderForAppName = "$etron"

const PIPELINE_NAME_ALREADY_EXISTS_ERROR = "pipeline name already exist"
const PIPELINE_TYPE_IS_NOT_VALID = "PipelineType is not valid"

type CiBuildConfigBean struct {
Id int `json:"id"`
Expand Down
1 change: 1 addition & 0 deletions scripts/sql/224_pipeline_type.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---- Not Required
1 change: 1 addition & 0 deletions scripts/sql/224_pipeline_type.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE "public"."ci_pipeline" SET ci_pipeline_type='LINKED' WHERE ci_pipeline_type='CI_EXTERNAL';
Loading