Merge pull request #11 from sqshq/config_validation_for_absent_sample_script
Address crash reports: added validation to return user-friendly error if sampling script is not specified
This commit is contained in:
commit
dd6077d6a6
|
@ -43,15 +43,16 @@ func (c *Config) validate() {
|
||||||
|
|
||||||
func validateItemsScripts(title string, items []Item) {
|
func validateItemsScripts(title string, items []Item) {
|
||||||
for _, i := range items {
|
for _, i := range items {
|
||||||
if i.InitScript != nil && i.MultiStepInitScript != nil {
|
|
||||||
validateItemScripts(title, i)
|
validateItemScripts(title, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func validateItemScripts(title string, i Item) {
|
func validateItemScripts(title string, i Item) {
|
||||||
if i.InitScript != nil && i.MultiStepInitScript != nil {
|
if i.InitScript != nil && i.MultiStepInitScript != nil {
|
||||||
console.Exit(fmt.Sprintf("Config validation error: both init and multistep-init scripts are not allowed in '%s'", title))
|
console.Exit(fmt.Sprintf("Config validation error: both init and multistep-init scripts are not allowed for '%s'", title))
|
||||||
|
}
|
||||||
|
if i.SampleScript == nil {
|
||||||
|
console.Exit(fmt.Sprintf("Config validation error: sample script should be specified for '%s'", title))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ func validateLabelsUniqueness(title string, items []Item) {
|
||||||
for _, i := range items {
|
for _, i := range items {
|
||||||
label := *i.Label
|
label := *i.Label
|
||||||
if _, contains := labels[label]; contains {
|
if _, contains := labels[label]; contains {
|
||||||
console.Exit(fmt.Sprintf("Config validation error: item labels should be unique. Please rename '%s' in '%s'", label, title))
|
console.Exit(fmt.Sprintf("Config validation error: item labels should be unique. Please rename '%s' for '%s'", label, title))
|
||||||
}
|
}
|
||||||
labels[label] = true
|
labels[label] = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue