mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +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 commit80b77223cd. * Revert "pass stepName to maven utils for mavenBuild" This reverts commita4f99ae160. * use reflection to update command stepName for mavenBuild * Revert "use reflection to update command stepName for mavenBuild" This reverts commitef85c78669. --------- 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:
co-authored by
I557621
Jordi van Liempt
parent
ae4550d0dd
commit
a9bab48557
@@ -25,6 +25,7 @@ func kanikoExecute(config kanikoExecuteOptions, telemetryData *telemetry.CustomD
|
||||
"unsupported status code 401",
|
||||
},
|
||||
},
|
||||
StepName: "kanikoExecute",
|
||||
}
|
||||
|
||||
// reroute command output to logging framework
|
||||
|
||||
+22
-4
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user