Skip to content

Commit

Permalink
Merge branch 'master' into 1084565-infra-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
o-liver authored Apr 8, 2024
2 parents b6b3676 + 3ae51e2 commit d6b09ae
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions pkg/checkmarxone/checkmarxone.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,10 +825,11 @@ func (sys *SystemInstance) CreateProject(projectName string, groupIDs []string)
func (sys *SystemInstance) CreateProjectInApplication(projectName, applicationID string, groupIDs []string) (Project, error) {
var project Project
jsonData := map[string]interface{}{
"name": projectName,
"groups": groupIDs,
"origin": cxOrigin,
"criticality": 3, // default
"name": projectName,
"groups": groupIDs,
"origin": cxOrigin,
"criticality": 3, // default
"applicationIds": []string{applicationID},
// multiple additional parameters exist as options
}

Expand All @@ -839,17 +840,7 @@ func (sys *SystemInstance) CreateProjectInApplication(projectName, applicationID

header := http.Header{}
header.Set("Content-Type", "application/json")

data, err := sendRequest(sys, http.MethodPost, fmt.Sprintf("/projects/application/%v", applicationID), bytes.NewBuffer(jsonValue), header, []int{})

if err != nil && err.Error()[0:8] == "HTTP 404" { // At some point, the api /projects/applications will be removed and instead the normal /projects API will do the job.
jsonData["applicationIds"] = []string{applicationID}
jsonValue, err = json.Marshal(data)
if err != nil {
return project, err
}
data, err = sendRequest(sys, http.MethodPost, "/projects", bytes.NewReader(jsonValue), header, []int{})
}
data, err := sendRequest(sys, http.MethodPost, "/projects", bytes.NewReader(jsonValue), header, []int{})

if err != nil {
return project, errors.Wrapf(err, "failed to create project %v under %v", projectName, applicationID)
Expand Down

0 comments on commit d6b09ae

Please sign in to comment.