mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-27 03:21:09 +01:00
refactor: replace gperr with standard errors package and simplify string parsing
- Replace gperr.Error return types with standard error across test files - Replace gperr.New with errors.New in validation and serialization tests - Update API documentation in README files to use error instead of gperr.Error - Simplify string parsing using strings.Cut in docker/label.go - Update benchmarks to use NewTestEntrypoint and remove task package dependency
This commit is contained in:
@@ -54,7 +54,7 @@ func ParseLabels(labels map[string]string, aliases ...string) (types.LabelMap, e
|
||||
// Move deeper into the nested map
|
||||
m, ok := currentMap[k].(types.LabelMap)
|
||||
if !ok && currentMap[k] != "" {
|
||||
errs.Add(gperr.Errorf("expect mapping, got %T", currentMap[k]).Subject(lbl))
|
||||
errs.AddSubject(fmt.Errorf("expect mapping, got %T", currentMap[k]), lbl)
|
||||
continue
|
||||
} else if !ok {
|
||||
m = make(types.LabelMap)
|
||||
@@ -83,15 +83,7 @@ func ExpandWildcard(labels map[string]string, aliases ...string) {
|
||||
}
|
||||
// lbl is "proxy.X..." where X is alias or wildcard
|
||||
rest := lbl[len(nsProxyDot):] // "X..." or "X.suffix"
|
||||
dotIdx := strings.IndexByte(rest, '.')
|
||||
var alias, suffix string
|
||||
if dotIdx == -1 {
|
||||
alias = rest
|
||||
} else {
|
||||
alias = rest[:dotIdx]
|
||||
suffix = rest[dotIdx+1:]
|
||||
}
|
||||
|
||||
alias, suffix, _ := strings.Cut(rest, ".")
|
||||
if alias == WildcardAlias {
|
||||
delete(labels, lbl)
|
||||
if suffix == "" || strings.Count(value, "\n") > 1 {
|
||||
@@ -121,15 +113,10 @@ func ExpandWildcard(labels map[string]string, aliases ...string) {
|
||||
continue
|
||||
}
|
||||
rest := lbl[len(nsProxyDot):]
|
||||
dotIdx := strings.IndexByte(rest, '.')
|
||||
if dotIdx == -1 {
|
||||
alias, suffix, ok := strings.Cut(rest, ".")
|
||||
if !ok || alias == "" || alias[0] == '#' {
|
||||
continue
|
||||
}
|
||||
alias := rest[:dotIdx]
|
||||
if alias[0] == '#' {
|
||||
continue
|
||||
}
|
||||
suffix := rest[dotIdx+1:]
|
||||
|
||||
idx, known := aliasSet[alias]
|
||||
if !known {
|
||||
|
||||
Reference in New Issue
Block a user