You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-07-13 01:30:24 +02:00
Improve validation of configuration (#3125)
* Implemented validation for the option possibleValues * Has been added the option mandatoryIf to config with validation * Fixed issues found during code review * improved golang template * Fixed tests. Added validation for mandatoryIf option * Fix typo * Fixed tests * Validation was refactored. Added options * Added default value for parameters with possibleValues option * Validation was moved after the configuration resolution * Canceled some default values Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com> Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4f5efc88d7
commit
46bafc40a3
@ -11,6 +11,7 @@ import (
|
||||
"github.com/SAP/jenkins-library/pkg/log"
|
||||
"github.com/SAP/jenkins-library/pkg/splunk"
|
||||
"github.com/SAP/jenkins-library/pkg/telemetry"
|
||||
"github.com/SAP/jenkins-library/pkg/validation"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -71,6 +72,15 @@ func NpmExecuteScriptsCommand() *cobra.Command {
|
||||
log.RegisterHook(logCollector)
|
||||
}
|
||||
|
||||
validation, err := validation.New(validation.WithJSONNamesForStructFields(), validation.WithPredefinedErrorMessages())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = validation.ValidateStruct(stepConfig); err != nil {
|
||||
log.SetErrorCategory(log.ErrorConfiguration)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
|
Reference in New Issue
Block a user