1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

feat: add validation for application name (#5123)

* feat: add validation for application name

* improve error message

---------

Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
This commit is contained in:
Srinikitha Kondreddy 2024-10-09 11:34:54 +02:00 committed by GitHub
parent 41536720c1
commit 129e20d713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,10 +2,12 @@ package cts
import (
"fmt"
"regexp"
"strings"
"github.com/SAP/jenkins-library/pkg/command"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
"strings"
)
type fileUtils interface {
@ -60,6 +62,7 @@ const (
abapUserKey = "ABAP_USER"
abapPasswordKey = "ABAP_PASSWORD"
defaultConfigFileName = "ui5-deploy.yaml"
pattern = "^[a-zA-Z0-9_]+$"
)
// WithConnection ...
@ -189,6 +192,10 @@ func getFioriDeployStatement(
log.Entry().Debug("No application package found in piper config.")
}
if len(app.Name) > 0 {
re := regexp.MustCompile(pattern)
if !re.MatchString(app.Name) {
fmt.Errorf("application name '%s' contains spaces or special characters. It is not according to the '%s'", app.Name, pattern)
}
log.Entry().Debugf("application name '%s' used from piper config", app.Name)
cmd = append(cmd, "--name", app.Name)
} else {