-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvalidate.go
33 lines (28 loc) · 1.1 KB
/
validate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package config
import (
"fmt"
"slices"
)
// ValidateLLPkgConfig performs structural validation of the configuration.
// Validates upstream installer and package metadata requirements.
func ValidateLLPkgConfig(config LLPkgConfig) error {
return validateUpstreamConfig(config.Upstream)
}
// validateUpstreamConfig performs detailed validation of upstream configuration parameters.
func validateUpstreamConfig(config UpstreamConfig) error {
// 1. check if upstream installer is valid
if config.Installer.Name == "" {
return fmt.Errorf("missing required installer type: upstream.installer.name must be specified")
}
if !slices.Contains(ValidInstallers, config.Installer.Name) {
return fmt.Errorf("unsupported installer type: %s (valid options: %v)", config.Installer.Name, ValidInstallers)
}
// 2. check if package is valid
if config.Package.Name == "" {
return fmt.Errorf("missing required package identifier: upstream.package.name cannot be empty")
}
if config.Package.Version == "" {
return fmt.Errorf("missing required version specification: upstream.package.version cannot be empty")
}
return nil
}