1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

simplify parameters

Signed-off-by: Fabian Reh <fabian.reh@sap.com>
This commit is contained in:
Fabian Reh 2021-04-07 10:11:17 +02:00
parent 51ac8bc3d3
commit 0bfc582808
No known key found for this signature in database
GPG Key ID: 242831AEEE9DA2DD

View File

@ -35,11 +35,8 @@ type checkmarxExecuteScanUtils interface {
PathMatch(pattern, name string) (bool, error)
}
type checkmarxExecuteScanUtilsBundle struct{}
func newCheckmarxExecuteScanUtils() checkmarxExecuteScanUtils {
utils := checkmarxExecuteScanUtilsBundle{}
return &utils
type checkmarxExecuteScanUtilsBundle struct {
workspace string
}
func (checkmarxExecuteScanUtilsBundle) PathMatch(pattern, name string) (bool, error) {
@ -79,13 +76,14 @@ func checkmarxExecuteScan(config checkmarxExecuteScanOptions, _ *telemetry.Custo
log.Entry().WithError(err).Fatalf("Failed to create Checkmarx client talking to URL %v", config.ServerURL)
}
influx.step_data.fields.checkmarx = false
if err := runScan(config, sys, "./", influx, newCheckmarxExecuteScanUtils()); err != nil {
utils := checkmarxExecuteScanUtilsBundle{workspace: "./"}
if err := runScan(config, sys, influx, utils); err != nil {
log.Entry().WithError(err).Fatal("Failed to execute Checkmarx scan.")
}
influx.step_data.fields.checkmarx = true
}
func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, workspace string, influx *checkmarxExecuteScanInflux, utils checkmarxExecuteScanUtils) error {
func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, influx *checkmarxExecuteScanInflux, utils checkmarxExecuteScanUtilsBundle) error {
teamID := config.TeamID
if len(teamID) == 0 {
team, err := loadTeam(sys, config.TeamName)
@ -131,7 +129,7 @@ func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, workspace
}
}
err = uploadAndScan(config, sys, project, workspace, influx, utils)
err = uploadAndScan(config, sys, project, utils.workspace, influx, utils)
if err != nil {
return errors.Wrap(err, "failed to run scan and upload result")
}