Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into whitesource-sbt-c…
Browse files Browse the repository at this point in the history
…onfig-fix
  • Loading branch information
maxatsap committed Dec 14, 2022
2 parents 94532e1 + c16fba8 commit f800750
Show file tree
Hide file tree
Showing 105 changed files with 1,897 additions and 1,286 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ jobs:
- name: Generate Golang Docs
run: go run pkg/documentation/generator.go --docuDir=documentation/docs/steps/ --customDefaultFile resources/default_pipeline_environment.yml

- run: docker pull squidfunk/mkdocs-material:8.3.6

- name: Build
run: |
docker run \
-u $(id -u):$(id -g) \
-v ${GITHUB_WORKSPACE}/documentation:/docs \
squidfunk/mkdocs-material:latest build --clean --strict
squidfunk/mkdocs-material:8.5.11 build --clean --strict
- name: Provide Docs Metadata
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/integration-tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:
needs:
- build_piper
- build_integration_tests
- start
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.build_integration_tests.outputs.matrix) }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
needs:
- build_piper
- build_integration_tests
- start
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.build_integration_tests.outputs.matrix) }}
Expand Down
10 changes: 5 additions & 5 deletions cmd/abapEnvironmentAssembleConfirm_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions cmd/abapEnvironmentAssemblePackages_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/abapEnvironmentBuild_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 24 additions & 26 deletions cmd/abapEnvironmentPushATCSystemConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func runAbapEnvironmentPushATCSystemConfig(config *abapEnvironmentPushATCSystemC
// Determine the host, user and password, either via the input parameters or via a cloud foundry service key.
connectionDetails, err := autils.GetAbapCommunicationArrangementInfo(subOptions, "/sap/opu/odata4/sap/satc_ci_cf_api/srvd_a2x/sap/satc_ci_cf_sv_api/0001")
if err != nil {
return errors.Wrap(err, "Parameters for the ABAP Connection not available")
return errors.Errorf("Parameters for the ABAP Connection not available: %v", err)
}

cookieJar, err := cookiejar.New(nil)
if err != nil {
return errors.Wrap(err, "could not create a Cookie Jar")
return errors.Errorf("could not create a Cookie Jar: %v", err)
}
clientOptions := piperhttp.ClientOptions{
MaxRequestDuration: 180 * time.Second,
Expand All @@ -62,6 +62,10 @@ func runAbapEnvironmentPushATCSystemConfig(config *abapEnvironmentPushATCSystemC
}
client.SetOptions(clientOptions)

if connectionDetails.XCsrfToken, err = fetchXcsrfTokenFromHead(connectionDetails, client); err != nil {
return err
}

return pushATCSystemConfig(config, connectionDetails, client)

}
Expand Down Expand Up @@ -122,7 +126,7 @@ func checkATCSystemConfigurationFile(config *abapEnvironmentPushATCSystemConfigO
//check if parsedConfigurationJson is not initial or Configuration Name not supplied
if reflect.DeepEqual(parsedConfigurationJson, emptyConfigurationJson) ||
parsedConfigurationJson.ConfName == "" {
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, fmt.Errorf("pushing ATC System Configuration failed. Reason: Configured File does not contain required ATC System Configuration attributes (File: " + config.AtcSystemConfigFilePath + ")")
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured File does not contain required ATC System Configuration attributes (File: " + config.AtcSystemConfigFilePath + ")")
}

return parsedConfigurationJson, atcSystemConfiguartionJsonFile, nil
Expand All @@ -140,7 +144,7 @@ func readATCSystemConfigurationFile(config *abapEnvironmentPushATCSystemConfigOp
}

if len(filelocation) == 0 {
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, fmt.Errorf("pushing ATC System Configuration failed. Reason: Configured Filelocation is empty (File: " + config.AtcSystemConfigFilePath + ")")
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured Filelocation is empty (File: " + config.AtcSystemConfigFilePath + ")")
}

filename, err = filepath.Abs(filelocation[0])
Expand All @@ -152,23 +156,19 @@ func readATCSystemConfigurationFile(config *abapEnvironmentPushATCSystemConfigOp
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, err
}
if len(atcSystemConfiguartionJsonFile) == 0 {
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, fmt.Errorf("pushing ATC System Configuration failed. Reason: Configured File is empty (File: " + config.AtcSystemConfigFilePath + ")")
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured File is empty (File: " + config.AtcSystemConfigFilePath + ")")
}

err = json.Unmarshal(atcSystemConfiguartionJsonFile, &parsedConfigurationJson)
if err != nil {
return emptyConfigurationJson, atcSystemConfiguartionJsonFile, err
return emptyConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Unmarshal Error of ATC Configuration File ("+config.AtcSystemConfigFilePath+"): %v", err)
}

return parsedConfigurationJson, atcSystemConfiguartionJsonFile, err
}

func handlePushConfiguration(config *abapEnvironmentPushATCSystemConfigOptions, confUUID string, configDoesExist bool, atcSystemConfiguartionJsonFile []byte, connectionDetails abaputils.ConnectionDetailsHTTP, client piperhttp.Sender) error {
var err error
connectionDetails.XCsrfToken, err = fetchXcsrfTokenFromHead(connectionDetails, client)
if err != nil {
return err
}
if configDoesExist {
err = doPatchATCSystemConfig(config, confUUID, atcSystemConfiguartionJsonFile, connectionDetails, client)
if err != nil {
Expand Down Expand Up @@ -199,7 +199,7 @@ func fetchXcsrfTokenFromHead(connectionDetails abaputils.ConnectionDetailsHTTP,
resp, err := abaputils.GetHTTPResponse("HEAD", connectionDetails, nil, client)
if err != nil {
err = abaputils.HandleHTTPError(resp, err, "authentication on the ABAP system failed", connectionDetails)
return connectionDetails.XCsrfToken, err
return connectionDetails.XCsrfToken, errors.Errorf("X-Csrf-Token fetch failed for Service ATC System Configuration: %v", err)
}
defer resp.Body.Close()

Expand Down Expand Up @@ -285,25 +285,24 @@ func buildParsedATCSystemConfigBaseJsonBody(confUUID string, atcSystemConfiguart
var outputString string = ``

if err := json.Unmarshal([]byte(atcSystemConfiguartionJsonFile), &i); err != nil {
log.Entry().Errorf("problem with unmarshall input "+atcSystemConfiguartionJsonFile, err)
return outputString, err
return outputString, errors.Errorf("problem with unmarshall input "+atcSystemConfiguartionJsonFile+": %v", err)
}
if m, ok := i.(map[string]interface{}); ok {
delete(m, "_priorities")
}

output, err := json.Marshal(i)
if err != nil {
log.Entry().Errorf("problem with marshall output "+atcSystemConfiguartionJsonFile, err)
if output, err := json.Marshal(i); err != nil {
return outputString, errors.Errorf("problem with marshall output "+atcSystemConfiguartionJsonFile+": %v", err)
} else {
output = output[1:] // remove leading '{'
outputString = string(output)
//injecting the configuration ID
confIDString := `{"conf_id":"` + confUUID + `",`
outputString = confIDString + outputString

return outputString, err
}
//injecting the configuration ID
output = output[1:] // remove leading '{'
outputString = string(output)
confIDString := `{"conf_id":"` + confUUID + `",`
outputString = confIDString + outputString

return outputString, err
}

func addPatchConfigBaseChangeset(inputString string, confUUID string, configBaseJsonBody string) string {
Expand Down Expand Up @@ -419,9 +418,8 @@ func checkConfigExistsInBackend(config *abapEnvironmentPushATCSystemConfigOption
}

var parsedoDataResponse parsedOdataResp
err = json.Unmarshal(body, &parsedoDataResponse)
if err != nil {
return false, configName, configUUID, configLastChangedAt, err
if err = json.Unmarshal(body, &parsedoDataResponse); err != nil {
return false, configName, configUUID, configLastChangedAt, errors.New("GET Request for check existence of ATC System Configuration - Unexpected Response - Problem with Unmarshal body: " + string(body))
}
if len(parsedoDataResponse.Value) > 0 {
configUUID = parsedoDataResponse.Value[0].ConfUUID
Expand Down Expand Up @@ -502,7 +500,7 @@ func getErrorDetailsFromBody(resp *http.Response, bodyText []byte) (errorString
}
}

return errorString, errors.New("Could not parse the JSON error response")
return errorString, errors.New("Could not parse the JSON error response. stringified body " + string(bodyText))

}

Expand Down
Loading

0 comments on commit f800750

Please sign in to comment.