1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-16 11:09:33 +02:00
sap-jenkins-library/pkg/versioning/descriptorUtils.go
Christopher Fenner 3a14a91ae5
refactor(versioning): simplify versioning model method (#2825)
* rename artifactVersion to version

* simplify versioningModel
2021-05-14 09:35:31 +02:00

31 lines
1.2 KiB
Go

package versioning
import (
"github.com/Masterminds/sprig"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
)
// DetermineProjectCoordinatesWithCustomVersion resolves the coordinates of the project for use in 3rd party scan tools
// It considers a custom version if provided instead of using the GAV version adapted according to the versionScheme
func DetermineProjectCoordinatesWithCustomVersion(nameTemplate, versionScheme, customVersion string, gav Coordinates) (string, string) {
name, version := DetermineProjectCoordinates(nameTemplate, versionScheme, gav)
if len(customVersion) > 0 {
log.Entry().Infof("Using custom version: %v", customVersion)
return name, customVersion
}
return name, version
}
// DetermineProjectCoordinates resolves the coordinates of the project for use in 3rd party scan tools
func DetermineProjectCoordinates(nameTemplate, versionScheme string, gav Coordinates) (string, string) {
projectName, err := piperutils.ExecuteTemplateFunctions(nameTemplate, sprig.HermeticTxtFuncMap(), gav)
if err != nil {
log.Entry().Warnf("Unable to resolve project name: %v", err)
}
projectVersion := ApplyVersioningModel(versionScheme, gav.Version)
return projectName, projectVersion
}