2020-05-13 14:51:48 +02:00
package cmd
import (
"bytes"
"encoding/json"
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
2022-04-27 13:30:43 +02:00
"reflect"
2020-05-13 14:51:48 +02:00
"strconv"
2020-08-26 14:09:00 +02:00
"strings"
2020-05-13 14:51:48 +02:00
"time"
2020-07-23 10:26:50 +02:00
"github.com/SAP/jenkins-library/pkg/abaputils"
2020-05-13 14:51:48 +02:00
"github.com/SAP/jenkins-library/pkg/command"
piperhttp "github.com/SAP/jenkins-library/pkg/http"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/telemetry"
"github.com/pkg/errors"
)
2020-07-23 10:26:50 +02:00
func abapEnvironmentRunATCCheck ( options abapEnvironmentRunATCCheckOptions , telemetryData * telemetry . CustomData ) {
// Mapping for options
2020-11-04 13:33:31 +02:00
subOptions := convertATCOptions ( & options )
2020-05-13 14:51:48 +02:00
2020-07-31 14:43:23 +02:00
c := & command . Command { }
2020-05-13 14:51:48 +02:00
c . Stdout ( log . Entry ( ) . Writer ( ) )
c . Stderr ( log . Entry ( ) . Writer ( ) )
2022-07-06 14:29:04 +02:00
autils := abaputils . AbapUtils {
2020-07-31 14:43:23 +02:00
Exec : c ,
}
var err error
2020-05-13 14:51:48 +02:00
client := piperhttp . Client { }
cookieJar , _ := cookiejar . New ( nil )
clientOptions := piperhttp . ClientOptions {
CookieJar : cookieJar ,
}
client . SetOptions ( clientOptions )
2020-07-23 10:26:50 +02:00
var details abaputils . ConnectionDetailsHTTP
2022-07-06 14:29:04 +02:00
// If Host flag is empty read ABAP endpoint from Service Key instead. Otherwise take ABAP system endpoint from config instead
2020-05-13 14:51:48 +02:00
if err == nil {
2020-07-31 14:43:23 +02:00
details , err = autils . GetAbapCommunicationArrangementInfo ( subOptions , "" )
2020-05-13 14:51:48 +02:00
}
var resp * http . Response
2022-07-06 14:29:04 +02:00
// Fetch Xcrsf-Token
2020-05-13 14:51:48 +02:00
if err == nil {
credentialsOptions := piperhttp . ClientOptions {
Username : details . User ,
Password : details . Password ,
CookieJar : cookieJar ,
}
client . SetOptions ( credentialsOptions )
details . XCsrfToken , err = fetchXcsrfToken ( "GET" , details , nil , & client )
}
if err == nil {
2022-01-12 13:02:27 +02:00
resp , err = triggerATCRun ( options , details , & client )
2020-05-13 14:51:48 +02:00
}
if err == nil {
2022-01-12 13:02:27 +02:00
err = fetchAndPersistATCResults ( resp , details , & client , options . AtcResultsFileName , options . GenerateHTML )
2020-05-13 14:51:48 +02:00
}
if err != nil {
log . Entry ( ) . WithError ( err ) . Fatal ( "step execution failed" )
}
2020-09-24 07:41:06 +02:00
log . Entry ( ) . Info ( "ATC run completed successfully. If there are any results from the respective run they will be listed in the logs above as well as being saved in the output .xml file" )
2020-05-13 14:51:48 +02:00
}
2022-01-12 13:02:27 +02:00
func fetchAndPersistATCResults ( resp * http . Response , details abaputils . ConnectionDetailsHTTP , client piperhttp . Sender , atcResultFileName string , generateHTML bool ) error {
2020-05-13 14:51:48 +02:00
var err error
2022-07-06 14:29:04 +02:00
abapEndpoint := details . URL
2020-05-13 14:51:48 +02:00
location := resp . Header . Get ( "Location" )
details . URL = abapEndpoint + location
location , err = pollATCRun ( details , nil , client )
if err == nil {
details . URL = abapEndpoint + location
resp , err = getResultATCRun ( "GET" , details , nil , client )
}
2022-07-06 14:29:04 +02:00
// Parse response
2020-05-13 14:51:48 +02:00
var body [ ] byte
if err == nil {
body , err = ioutil . ReadAll ( resp . Body )
}
if err == nil {
defer resp . Body . Close ( )
2022-01-12 13:02:27 +02:00
err = logAndPersistATCResult ( body , atcResultFileName , generateHTML )
2020-05-13 14:51:48 +02:00
}
if err != nil {
return fmt . Errorf ( "Handling ATC result failed: %w" , err )
}
return nil
}
2022-01-12 13:02:27 +02:00
func triggerATCRun ( config abapEnvironmentRunATCCheckOptions , details abaputils . ConnectionDetailsHTTP , client piperhttp . Sender ) ( * http . Response , error ) {
bodyString , err := buildATCRequestBody ( config )
if err != nil {
return nil , err
}
2020-05-13 14:51:48 +02:00
var resp * http . Response
2022-01-12 13:02:27 +02:00
abapEndpoint := details . URL
2022-03-14 10:49:51 +02:00
log . Entry ( ) . Infof ( "Request Body: %s" , bodyString )
2022-07-06 14:29:04 +02:00
body := [ ] byte ( bodyString )
2022-01-12 13:02:27 +02:00
details . URL = abapEndpoint + "/sap/bc/adt/api/atc/runs?clientWait=false"
resp , err = runATC ( "POST" , details , body , client )
return resp , err
}
func buildATCRequestBody ( config abapEnvironmentRunATCCheckOptions ) ( bodyString string , err error ) {
atcConfig , err := resolveATCConfiguration ( config )
2020-05-13 14:51:48 +02:00
if err != nil {
2022-01-12 13:02:27 +02:00
return "" , err
}
// Create string for the run parameters
variant := "ABAP_CLOUD_DEVELOPMENT_DEFAULT"
if atcConfig . CheckVariant != "" {
variant = atcConfig . CheckVariant
}
log . Entry ( ) . Infof ( "ATC Check Variant: %s" , variant )
runParameters := ` checkVariant=" ` + variant + ` " `
if atcConfig . Configuration != "" {
runParameters += ` configuration=" ` + atcConfig . Configuration + ` " `
}
2022-04-27 13:30:43 +02:00
var objectSetString string
2022-07-06 14:29:04 +02:00
// check if OSL Objectset is present
2022-04-27 13:30:43 +02:00
if ! reflect . DeepEqual ( abaputils . ObjectSet { } , atcConfig . ObjectSet ) {
objectSetString = abaputils . BuildOSLString ( atcConfig . ObjectSet )
}
2022-07-06 14:29:04 +02:00
// if initial - check if ATC Object set is present
2022-04-27 13:30:43 +02:00
if objectSetString == "" && ( len ( atcConfig . Objects . Package ) != 0 || len ( atcConfig . Objects . SoftwareComponent ) != 0 ) {
objectSetString , err = getATCObjectSet ( atcConfig )
}
if objectSetString == "" {
return objectSetString , fmt . Errorf ( "Error while parsing ATC test run object set config. No object set has been provided. Please configure the objects you want to be checked for the respective test run" )
}
2022-01-12 13:02:27 +02:00
2022-04-27 13:30:43 +02:00
bodyString = ` <?xml version="1.0" encoding="UTF-8"?><atc:runparameters xmlns:atc="http://www.sap.com/adt/atc" xmlns:obj="http://www.sap.com/adt/objectset" ` + runParameters + ` > ` + objectSetString + ` </atc:runparameters> `
2022-01-12 13:02:27 +02:00
return bodyString , err
}
func resolveATCConfiguration ( config abapEnvironmentRunATCCheckOptions ) ( atcConfig ATCConfiguration , err error ) {
if config . AtcConfig != "" {
2022-04-27 13:30:43 +02:00
// Configuration defaults to ATC Config
2022-01-12 13:02:27 +02:00
log . Entry ( ) . Infof ( "ATC Configuration: %s" , config . AtcConfig )
atcConfigFile , err := abaputils . ReadConfigFile ( config . AtcConfig )
if err != nil {
return atcConfig , err
}
2022-07-06 14:29:04 +02:00
if err := json . Unmarshal ( atcConfigFile , & atcConfig ) ; err != nil {
log . Entry ( ) . WithError ( err ) . Warning ( "failed to unmarschal json" )
}
return atcConfig , nil
2022-01-12 13:02:27 +02:00
} else if config . Repositories != "" {
// Fallback / EasyMode is the Repositories configuration
log . Entry ( ) . Infof ( "ATC Configuration derived from: %s" , config . Repositories )
2022-06-28 11:02:15 +02:00
repositories , err := abaputils . GetRepositories ( ( & abaputils . RepositoriesConfig { Repositories : config . Repositories } ) , false )
2022-01-12 13:02:27 +02:00
if err != nil {
return atcConfig , err
}
for _ , repository := range repositories {
atcConfig . Objects . SoftwareComponent = append ( atcConfig . Objects . SoftwareComponent , SoftwareComponent { Name : repository . Name } )
}
return atcConfig , nil
} else {
// Fail if no configuration is provided
return atcConfig , errors . New ( "No configuration provided - please provide either an ATC configuration file or a repository configuration file" )
2020-05-13 14:51:48 +02:00
}
}
2022-01-12 13:02:27 +02:00
func getATCObjectSet ( ATCConfig ATCConfiguration ) ( objectSet string , err error ) {
objectSet += ` <obj:objectSet> `
2022-07-06 14:29:04 +02:00
// Build SC XML body
2022-01-12 13:02:27 +02:00
if len ( ATCConfig . Objects . SoftwareComponent ) != 0 {
objectSet += "<obj:softwarecomponents>"
for _ , s := range ATCConfig . Objects . SoftwareComponent {
objectSet += ` <obj:softwarecomponent value=" ` + s . Name + ` "/> `
2020-08-26 14:09:00 +02:00
}
2022-01-12 13:02:27 +02:00
objectSet += "</obj:softwarecomponents>"
2020-08-26 14:09:00 +02:00
}
2020-05-13 14:51:48 +02:00
2022-07-06 14:29:04 +02:00
// Build Package XML body
2020-05-13 14:51:48 +02:00
if len ( ATCConfig . Objects . Package ) != 0 {
2022-01-12 13:02:27 +02:00
objectSet += "<obj:packages>"
2020-05-13 14:51:48 +02:00
for _ , s := range ATCConfig . Objects . Package {
2022-01-12 13:02:27 +02:00
objectSet += ` <obj:package value=" ` + s . Name + ` " includeSubpackages=" ` + strconv . FormatBool ( s . IncludeSubpackages ) + ` "/> `
2020-05-13 14:51:48 +02:00
}
2022-01-12 13:02:27 +02:00
objectSet += "</obj:packages>"
2020-05-13 14:51:48 +02:00
}
2022-01-12 13:02:27 +02:00
objectSet += ` </obj:objectSet> `
return objectSet , nil
2020-05-13 14:51:48 +02:00
}
2022-07-06 14:29:04 +02:00
func logAndPersistATCResult ( body [ ] byte , atcResultFileName string , generateHTML bool ) error {
2020-05-13 14:51:48 +02:00
if len ( body ) == 0 {
return fmt . Errorf ( "Parsing ATC result failed: %w" , errors . New ( "Body is empty, can't parse empty body" ) )
}
2020-11-02 15:17:13 +02:00
responseBody := string ( body )
log . Entry ( ) . Debugf ( "Response body: %s" , responseBody )
if strings . HasPrefix ( responseBody , "<html>" ) {
return errors . New ( "The Software Component could not be checked. Please make sure the respective Software Component has been cloned successfully on the system" )
}
2020-05-13 14:51:48 +02:00
parsedXML := new ( Result )
2022-07-06 14:29:04 +02:00
if err := xml . Unmarshal ( [ ] byte ( body ) , & parsedXML ) ; err != nil {
log . Entry ( ) . WithError ( err ) . Warning ( "failed to unmarschal xml response" )
}
2020-08-26 14:09:00 +02:00
if len ( parsedXML . Files ) == 0 {
log . Entry ( ) . Info ( "There were no results from this run, most likely the checked Software Components are empty or contain no ATC findings" )
}
2020-11-02 15:17:13 +02:00
2022-07-06 14:29:04 +02:00
err := ioutil . WriteFile ( atcResultFileName , body , 0 o644 )
2020-09-01 00:33:46 +02:00
if err == nil {
2021-04-21 20:13:02 +02:00
log . Entry ( ) . Infof ( "Writing %s file was successful" , atcResultFileName )
2020-05-13 14:51:48 +02:00
var reports [ ] piperutils . Path
2020-08-26 14:09:00 +02:00
reports = append ( reports , piperutils . Path { Target : atcResultFileName , Name : "ATC Results" , Mandatory : true } )
2020-05-13 14:51:48 +02:00
for _ , s := range parsedXML . Files {
for _ , t := range s . ATCErrors {
2021-01-28 14:06:13 +02:00
log . Entry ( ) . Infof ( "%s in file '%s': %s in line %s found by %s" , t . Severity , s . Key , t . Message , t . Line , t . Source )
2020-05-13 14:51:48 +02:00
}
}
2022-07-06 14:29:04 +02:00
if generateHTML {
2021-04-21 20:13:02 +02:00
htmlString := generateHTMLDocument ( parsedXML )
htmlStringByte := [ ] byte ( htmlString )
atcResultHTMLFileName := strings . Trim ( atcResultFileName , ".xml" ) + ".html"
2022-07-06 14:29:04 +02:00
err = ioutil . WriteFile ( atcResultHTMLFileName , htmlStringByte , 0 o644 )
2021-04-21 20:13:02 +02:00
if err == nil {
log . Entry ( ) . Info ( "Writing " + atcResultHTMLFileName + " file was successful" )
reports = append ( reports , piperutils . Path { Target : atcResultFileName , Name : "ATC Results HTML file" , Mandatory : true } )
}
}
piperutils . PersistReportsAndLinks ( "abapEnvironmentRunATCCheck" , "" , reports , nil )
2020-05-13 14:51:48 +02:00
}
if err != nil {
2021-04-21 20:13:02 +02:00
return fmt . Errorf ( "Writing results failed: %w" , err )
2020-05-13 14:51:48 +02:00
}
return nil
}
2020-07-23 10:26:50 +02:00
func runATC ( requestType string , details abaputils . ConnectionDetailsHTTP , body [ ] byte , client piperhttp . Sender ) ( * http . Response , error ) {
2022-03-14 10:49:51 +02:00
log . Entry ( ) . WithField ( "ABAP endpoint: " , details . URL ) . Info ( "triggering ATC run" )
2020-05-13 14:51:48 +02:00
header := make ( map [ string ] [ ] string )
header [ "X-Csrf-Token" ] = [ ] string { details . XCsrfToken }
header [ "Content-Type" ] = [ ] string { "application/vnd.sap.atc.run.parameters.v1+xml; charset=utf-8;" }
2022-03-14 10:49:51 +02:00
resp , err := client . SendRequest ( requestType , details . URL , bytes . NewBuffer ( body ) , header , nil )
2022-07-06 14:29:04 +02:00
_ = logResponseBody ( resp )
if err != nil || ( resp != nil && resp . StatusCode == 400 ) { // send request does not seem to produce error with StatusCode 400!!!
2022-03-14 10:49:51 +02:00
err = abaputils . HandleHTTPError ( resp , err , "triggering ATC run failed with Status: " + resp . Status , details )
2021-08-04 17:31:16 +02:00
log . SetErrorCategory ( log . ErrorService )
2022-03-14 10:49:51 +02:00
return resp , fmt . Errorf ( "triggering ATC run failed: %w" , err )
2020-05-13 14:51:48 +02:00
}
2022-03-14 10:49:51 +02:00
defer resp . Body . Close ( )
return resp , err
}
func logResponseBody ( resp * http . Response ) error {
var bodyText [ ] byte
var readError error
if resp != nil {
bodyText , readError = ioutil . ReadAll ( resp . Body )
if readError != nil {
return readError
}
log . Entry ( ) . Infof ( "Response body: %s" , bodyText )
}
return nil
2020-05-13 14:51:48 +02:00
}
2020-07-23 10:26:50 +02:00
func fetchXcsrfToken ( requestType string , details abaputils . ConnectionDetailsHTTP , body [ ] byte , client piperhttp . Sender ) ( string , error ) {
2020-11-02 15:17:13 +02:00
log . Entry ( ) . WithField ( "ABAP Endpoint: " , details . URL ) . Debug ( "Fetching Xcrsf-Token" )
2020-05-13 14:51:48 +02:00
details . URL += "/sap/bc/adt/api/atc/runs/00000000000000000000000000000000"
details . XCsrfToken = "fetch"
header := make ( map [ string ] [ ] string )
header [ "X-Csrf-Token" ] = [ ] string { details . XCsrfToken }
header [ "Accept" ] = [ ] string { "application/vnd.sap.atc.run.v1+xml" }
req , err := client . SendRequest ( requestType , details . URL , bytes . NewBuffer ( body ) , header , nil )
if err != nil {
2021-08-04 17:31:16 +02:00
log . SetErrorCategory ( log . ErrorInfrastructure )
2020-05-13 14:51:48 +02:00
return "" , fmt . Errorf ( "Fetching Xcsrf-Token failed: %w" , err )
}
defer req . Body . Close ( )
2020-10-08 11:08:58 +02:00
2020-05-13 14:51:48 +02:00
token := req . Header . Get ( "X-Csrf-Token" )
return token , err
}
2020-07-23 10:26:50 +02:00
func pollATCRun ( details abaputils . ConnectionDetailsHTTP , body [ ] byte , client piperhttp . Sender ) ( string , error ) {
2020-05-13 14:51:48 +02:00
log . Entry ( ) . WithField ( "ABAP endpoint" , details . URL ) . Info ( "Polling ATC run status" )
for {
resp , err := getHTTPResponseATCRun ( "GET" , details , nil , client )
if err != nil {
return "" , fmt . Errorf ( "Getting HTTP response failed: %w" , err )
}
bodyText , err := ioutil . ReadAll ( resp . Body )
if err != nil {
return "" , fmt . Errorf ( "Reading response body failed: %w" , err )
}
x := new ( Run )
2022-07-06 14:29:04 +02:00
if err := xml . Unmarshal ( bodyText , & x ) ; err != nil {
log . Entry ( ) . WithError ( err ) . Warning ( "failed to unmarschal xml response" )
}
2020-05-13 14:51:48 +02:00
log . Entry ( ) . WithField ( "StatusCode" , resp . StatusCode ) . Info ( "Status: " + x . Status )
if x . Status == "Not Created" {
return "" , err
}
if x . Status == "Completed" {
return x . Link [ 0 ] . Key , err
}
if x . Status == "" {
return "" , fmt . Errorf ( "Could not get any response from ATC poll: %w" , errors . New ( "Status from ATC run is empty. Either it's not an ABAP system or ATC run hasn't started" ) )
}
time . Sleep ( 5 * time . Second )
}
}
2020-07-23 10:26:50 +02:00
func getHTTPResponseATCRun ( requestType string , details abaputils . ConnectionDetailsHTTP , body [ ] byte , client piperhttp . Sender ) ( * http . Response , error ) {
2020-05-13 14:51:48 +02:00
header := make ( map [ string ] [ ] string )
header [ "Accept" ] = [ ] string { "application/vnd.sap.atc.run.v1+xml" }
2022-03-14 10:49:51 +02:00
resp , err := client . SendRequest ( requestType , details . URL , bytes . NewBuffer ( body ) , header , nil )
2020-05-13 14:51:48 +02:00
if err != nil {
2022-03-14 10:49:51 +02:00
return resp , fmt . Errorf ( "Getting ATC run status failed: %w" , err )
2020-05-13 14:51:48 +02:00
}
2022-03-14 10:49:51 +02:00
return resp , err
2020-05-13 14:51:48 +02:00
}
2020-07-23 10:26:50 +02:00
func getResultATCRun ( requestType string , details abaputils . ConnectionDetailsHTTP , body [ ] byte , client piperhttp . Sender ) ( * http . Response , error ) {
2020-05-13 14:51:48 +02:00
log . Entry ( ) . WithField ( "ABAP Endpoint: " , details . URL ) . Info ( "Getting ATC results" )
header := make ( map [ string ] [ ] string )
header [ "x-csrf-token" ] = [ ] string { details . XCsrfToken }
header [ "Accept" ] = [ ] string { "application/vnd.sap.atc.checkstyle.v1+xml" }
2022-03-14 10:49:51 +02:00
resp , err := client . SendRequest ( requestType , details . URL , bytes . NewBuffer ( body ) , header , nil )
2020-05-13 14:51:48 +02:00
if err != nil {
2022-03-14 10:49:51 +02:00
return resp , fmt . Errorf ( "Getting ATC run results failed: %w" , err )
2020-05-13 14:51:48 +02:00
}
2022-03-14 10:49:51 +02:00
return resp , err
2020-05-13 14:51:48 +02:00
}
2020-11-02 15:17:13 +02:00
func convertATCOptions ( options * abapEnvironmentRunATCCheckOptions ) abaputils . AbapEnvironmentOptions {
subOptions := abaputils . AbapEnvironmentOptions { }
subOptions . CfAPIEndpoint = options . CfAPIEndpoint
subOptions . CfServiceInstance = options . CfServiceInstance
subOptions . CfServiceKeyName = options . CfServiceKeyName
subOptions . CfOrg = options . CfOrg
subOptions . CfSpace = options . CfSpace
subOptions . Host = options . Host
subOptions . Password = options . Password
subOptions . Username = options . Username
return subOptions
}
2021-04-21 20:13:02 +02:00
func generateHTMLDocument ( parsedXML * Result ) ( htmlDocumentString string ) {
htmlDocumentString = ` <!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><title>ATC Results</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style>table,th,td { border: 1px solid black;border-collapse:collapse;}th,td { padding: 5px;text-align:left;font-size:medium;}</style></head><body><h1 style="text-align:left;font-size:large">ATC Results</h1><table style="width:100%"><tr><th>Severity</th><th>File</th><th>Message</th><th>Line</th><th>Checked by</th></tr> `
var htmlDocumentStringError , htmlDocumentStringWarning , htmlDocumentStringInfo , htmlDocumentStringDefault string
for _ , s := range parsedXML . Files {
for _ , t := range s . ATCErrors {
var trBackgroundColor string
if t . Severity == "error" {
trBackgroundColor = "rgba(227,85,0)"
htmlDocumentStringError += ` <tr style="background-color: ` + trBackgroundColor + ` "> ` + ` <td> ` + t . Severity + ` </td> ` + ` <td> ` + s . Key + ` </td> ` + ` <td> ` + t . Message + ` </td> ` + ` <td style="text-align:center"> ` + t . Line + ` </td> ` + ` <td> ` + t . Source + ` </td> ` + ` </tr> `
}
if t . Severity == "warning" {
trBackgroundColor = "rgba(255,175,0, 0.75)"
htmlDocumentStringWarning += ` <tr style="background-color: ` + trBackgroundColor + ` "> ` + ` <td> ` + t . Severity + ` </td> ` + ` <td> ` + s . Key + ` </td> ` + ` <td> ` + t . Message + ` </td> ` + ` <td style="text-align:center"> ` + t . Line + ` </td> ` + ` <td> ` + t . Source + ` </td> ` + ` </tr> `
}
if t . Severity == "info" {
trBackgroundColor = "rgba(255,175,0, 0.2)"
htmlDocumentStringInfo += ` <tr style="background-color: ` + trBackgroundColor + ` "> ` + ` <td> ` + t . Severity + ` </td> ` + ` <td> ` + s . Key + ` </td> ` + ` <td> ` + t . Message + ` </td> ` + ` <td style="text-align:center"> ` + t . Line + ` </td> ` + ` <td> ` + t . Source + ` </td> ` + ` </tr> `
}
if t . Severity != "info" && t . Severity != "warning" && t . Severity != "error" {
trBackgroundColor = "rgba(255,175,0, 0)"
htmlDocumentStringDefault += ` <tr style="background-color: ` + trBackgroundColor + ` "> ` + ` <td> ` + t . Severity + ` </td> ` + ` <td> ` + s . Key + ` </td> ` + ` <td> ` + t . Message + ` </td> ` + ` <td style="text-align:center"> ` + t . Line + ` </td> ` + ` <td> ` + t . Source + ` </td> ` + ` </tr> `
}
}
}
htmlDocumentString += htmlDocumentStringError + htmlDocumentStringWarning + htmlDocumentStringInfo + htmlDocumentStringDefault + ` </table></body></html> `
return htmlDocumentString
}
2022-07-06 14:29:04 +02:00
// ATCConfiguration object for parsing yaml config of software components and packages
2022-01-12 13:02:27 +02:00
type ATCConfiguration struct {
2022-04-27 13:30:43 +02:00
CheckVariant string ` json:"checkvariant,omitempty" `
Configuration string ` json:"configuration,omitempty" `
Objects ATCObjects ` json:"atcobjects" `
ObjectSet abaputils . ObjectSet ` json:"objectset,omitempty" `
2020-05-13 14:51:48 +02:00
}
2022-07-06 14:29:04 +02:00
// ATCObjects in form of packages and software components to be checked
2020-05-13 14:51:48 +02:00
type ATCObjects struct {
Package [ ] Package ` json:"package" `
SoftwareComponent [ ] SoftwareComponent ` json:"softwarecomponent" `
}
2022-07-06 14:29:04 +02:00
// Package for ATC run to be checked
2020-05-13 14:51:48 +02:00
type Package struct {
Name string ` json:"name" `
IncludeSubpackages bool ` json:"includesubpackage" `
}
2022-07-06 14:29:04 +02:00
// SoftwareComponent for ATC run to be checked
2020-05-13 14:51:48 +02:00
type SoftwareComponent struct {
Name string ` json:"name" `
}
2022-07-06 14:29:04 +02:00
// Run Object for parsing XML
2020-05-13 14:51:48 +02:00
type Run struct {
XMLName xml . Name ` xml:"run" `
Status string ` xml:"status,attr" `
Link [ ] Link ` xml:"link" `
}
2022-07-06 14:29:04 +02:00
// Link of XML object
2020-05-13 14:51:48 +02:00
type Link struct {
Key string ` xml:"href,attr" `
Value string ` xml:",chardata" `
}
2022-07-06 14:29:04 +02:00
// Result from ATC check for all files that were checked
2020-05-13 14:51:48 +02:00
type Result struct {
XMLName xml . Name ` xml:"checkstyle" `
Files [ ] File ` xml:"file" `
}
2022-07-06 14:29:04 +02:00
// File that contains ATC check with error for checked file
2020-05-13 14:51:48 +02:00
type File struct {
Key string ` xml:"name,attr" `
Value string ` xml:",chardata" `
ATCErrors [ ] ATCError ` xml:"error" `
}
2022-07-06 14:29:04 +02:00
// ATCError with message
2020-05-13 14:51:48 +02:00
type ATCError struct {
2021-01-28 14:06:13 +02:00
Text string ` xml:",chardata" `
Message string ` xml:"message,attr" `
Source string ` xml:"source,attr" `
Line string ` xml:"line,attr" `
Severity string ` xml:"severity,attr" `
2020-05-13 14:51:48 +02:00
}