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

feat(protecode): rename artifactVersion to version (#2813)

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
This commit is contained in:
Christopher Fenner 2021-05-05 19:52:13 +02:00 committed by GitHub
parent 534cba767c
commit aaa1869ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View File

@ -330,14 +330,14 @@ func correctDockerConfigEnvVar(config *protecodeExecuteScanOptions) {
func getTarName(config *protecodeExecuteScanOptions) string {
// remove original version
fileName := strings.TrimSuffix(config.ScanImage, ":"+config.ArtifactVersion)
fileName := strings.TrimSuffix(config.ScanImage, ":"+config.Version)
// remove sha digest if exists
sha256 := "@sha256"
if index := strings.Index(fileName, sha256); index > -1 {
fileName = fileName[:index]
}
// append trimmed version
if version := handleArtifactVersion(config.ArtifactVersion); len(version) > 0 {
if version := handleArtifactVersion(config.Version); len(version) > 0 {
fileName = fileName + "_" + version
}
fileName = strings.ReplaceAll(fileName, "/", "_")

View File

@ -32,7 +32,7 @@ type protecodeExecuteScanOptions struct {
VerifyOnly bool `json:"verifyOnly,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
ArtifactVersion string `json:"artifactVersion,omitempty"`
Version string `json:"version,omitempty"`
PullRequestName string `json:"pullRequestName,omitempty"`
}
@ -168,7 +168,7 @@ func addProtecodeExecuteScanFlags(cmd *cobra.Command, stepConfig *protecodeExecu
cmd.Flags().BoolVar(&stepConfig.VerifyOnly, "verifyOnly", false, "Whether the step shall only apply verification checks or whether it does a full scan and check cycle")
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User which is used for the protecode scan")
cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password which is used for the user")
cmd.Flags().StringVar(&stepConfig.ArtifactVersion, "artifactVersion", os.Getenv("PIPER_artifactVersion"), "The version of the artifact to allow identification in protecode backend")
cmd.Flags().StringVar(&stepConfig.Version, "version", os.Getenv("PIPER_version"), "The version of the artifact to allow identification in protecode backend")
cmd.Flags().StringVar(&stepConfig.PullRequestName, "pullRequestName", os.Getenv("PIPER_pullRequestName"), "The name of the pull request")
cmd.MarkFlagRequired("serverUrl")
@ -362,7 +362,7 @@ func protecodeExecuteScanMetadata() config.StepData {
Aliases: []config.Alias{},
},
{
Name: "artifactVersion",
Name: "version",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
@ -372,7 +372,7 @@ func protecodeExecuteScanMetadata() config.StepData {
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
Aliases: []config.Alias{{Name: "artifactVersion"}},
},
{
Name: "pullRequestName",

View File

@ -417,7 +417,7 @@ func TestGetTarName(t *testing.T) {
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
assert.Equal(t, c.expect, getTarName(&protecodeExecuteScanOptions{ScanImage: c.image, ArtifactVersion: c.version}))
assert.Equal(t, c.expect, getTarName(&protecodeExecuteScanOptions{ScanImage: c.image, Version: c.version}))
})
}
}

View File

@ -202,7 +202,10 @@ spec:
- $(vaultPath)/protecode
- $(vaultBasePath)/$(vaultPipelineName)/protecode
- $(vaultBasePath)/GROUP-SECRETS/protecode
- name: artifactVersion
- name: version
aliases:
- name: artifactVersion
deprecated: true
type: string
description: The version of the artifact to allow identification in protecode backend
resourceRef: