Fix profile updates and validate configuration before apply
This commit is contained in:
parent
b552ec49cb
commit
2bf14948d7
1 changed files with 372 additions and 12 deletions
|
|
@ -72,7 +72,10 @@ func keys[V any](m map[string]V) []string {
|
|||
func loadConfig(path string) (config, error) {
|
||||
var c config
|
||||
_, err := toml.DecodeFile(path, &c)
|
||||
return c, err
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
return c, c.validate()
|
||||
}
|
||||
|
||||
func parseSize(value string, base uint64) (uint64, error) {
|
||||
|
|
@ -112,7 +115,11 @@ func (c config) properties(name string) ([]property, error) {
|
|||
}
|
||||
quota := uint64(math.MaxUint64)
|
||||
if p.CPU != "" {
|
||||
quota, err = strconv.ParseUint(strings.TrimSuffix(p.CPU, "%"), 10, 64)
|
||||
percentage, ok := strings.CutSuffix(p.CPU, "%")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("CPUQuota: expected a percentage, got %q", p.CPU)
|
||||
}
|
||||
quota, err = strconv.ParseUint(percentage, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("CPUQuota: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue