1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-02-21 19:48:53 +02:00

feat (url-logger) Implement logic for a selection classifier (#4411)

* forcing the urls finder to relaxed

* adding a classifier map

* passing the stepName to the kaniko command executor bundle

* pass stepName to maven utils for mavenBuild

* improve enabling of Maven access log generation

* Revert "improve enabling of Maven access log generation"

This reverts commit 80b77223cdc674e843b3df3f710e3536153a79a9.

* Revert "pass stepName to maven utils for mavenBuild"

This reverts commit a4f99ae16048a693f3e4ad4c043a58a49bf33de3.

* use reflection to update command stepName for mavenBuild

* Revert "use reflection to update command stepName for mavenBuild"

This reverts commit ef85c78669b65d608e723f18b453607f03fc2c77.

---------

Co-authored-by: I557621 <jordi.van.liempt@sap.com>
Co-authored-by: Jordi van Liempt <35920075+jliempt@users.noreply.github.com>
This commit is contained in:
Anil Keshav 2023-06-26 08:47:11 +02:00 committed by GitHub
parent ae4550d0dd
commit a9bab48557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View File

@ -25,6 +25,7 @@ func kanikoExecute(config kanikoExecuteOptions, telemetryData *telemetry.CustomD
"unsupported status code 401",
},
},
StepName: "kanikoExecute",
}
// reroute command output to logging framework

View File

@ -5,9 +5,10 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"mvdan.cc/xurls/v2"
"os"
"sync"
"mvdan.cc/xurls/v2"
)
type (
@ -89,9 +90,26 @@ func (cl *URLLogger) WriteURLsLogToJSON() error {
func (cl *URLLogger) Parse(buf bytes.Buffer) {
cl.buf.Lock()
defer cl.buf.Unlock()
cl.buf.data = append(cl.buf.data, parseURLs(buf.Bytes())...)
classifier := returnURLStrictClassifier(cl.stepName)
cl.buf.data = append(cl.buf.data, parseURLs(buf.Bytes(), classifier)...)
}
func parseURLs(src []byte) [][]byte {
return xurls.Strict().FindAll(src, -1)
func parseURLs(src []byte, classifier string) [][]byte {
if classifier == "Strict" {
return xurls.Strict().FindAll(src, -1)
} else {
return xurls.Relaxed().FindAll(src, -1)
}
}
func returnURLStrictClassifier(stepName string) string {
switch stepName {
// golang cli output urls without the http protocol hence making the search less strict
//ToDo: other cases where the url is without protocol
case "golangBuild":
return "Relaxed"
default:
return "Strict"
}
}