mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
chore: modernize code (#857)
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/857 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Reviewed-by: Gusted <gusted@noreply.code.forgejo.org> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-committed-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
886bf2a4f3
commit
27f425987c
49 changed files with 316 additions and 363 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -270,10 +271,8 @@ func (s *Node) UnmarshalYAML(node *yaml.Node) error {
|
|||
return node.Decode(&b)
|
||||
} else if def.AllowedValues != nil {
|
||||
s := node.Value
|
||||
for _, v := range *def.AllowedValues {
|
||||
if s == v {
|
||||
return nil
|
||||
}
|
||||
if slices.Contains(*def.AllowedValues, s) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%sExpected one of %s got %s", formatLocation(node), strings.Join(*def.AllowedValues, ","), s)
|
||||
} else if def.Null != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue