Skip to content

fix: App create api validations #5019

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

Merged
merged 7 commits into from
May 2, 2024
Merged
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions api/restHandler/CoreAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,25 @@ func (handler CoreAppRestHandlerImpl) ValidateAppWorkflowRequest(createAppWorkfl
if ciPipeline.AppId != workflow.CiPipeline.ParentAppId {
return fmt.Errorf("invalid parentAppId '%v' for the given parentCiPipeline '%v'", workflow.CiPipeline.ParentAppId, workflow.CiPipeline.ParentCiPipeline), http.StatusBadRequest
}
parentMaterialMap := make(map[int]*pipelineConfig.CiPipelineMaterial)
for _, material := range ciPipeline.CiPipelineMaterials {
parentMaterialMap[material.GitMaterialId] = material
}
for _, requestPipelineMaterial := range workflow.CiPipeline.CiPipelineMaterialsConfig {
parentMaterial, ok := parentMaterialMap[requestPipelineMaterial.GitMaterialId]
if !ok {
return fmt.Errorf("invalid material id - request material id should match parent material id for linked ci, request material id - '%v' ", requestPipelineMaterial.GitMaterialId), http.StatusBadRequest
}
if requestPipelineMaterial.Value != parentMaterial.Value {
return fmt.Errorf(" parentMaterialValue and request material value should match for linked ci - parent material value - %v child value %v ", requestPipelineMaterial.Value), http.StatusBadRequest
}
if requestPipelineMaterial.Type != parentMaterial.Type {
return fmt.Errorf(" parentMaterialType and request material value should match for linked ci - parent material type - %v child type %v ", requestPipelineMaterial.Type), http.StatusBadRequest
}
if requestPipelineMaterial.CheckoutPath != parentMaterial.CheckoutPath {
return fmt.Errorf(" parentMaterialType and request material CheckoutPath should match for linked ci - parent material CheckoutPath - %v child CheckoutPath %v ", requestPipelineMaterial.CheckoutPath), http.StatusBadRequest
}
}
}
ciMaterialCheckoutPaths := make([]string, 0)
for _, ciPipelineMaterialConfig := range workflow.CiPipeline.CiPipelineMaterialsConfig {
Expand Down
Loading