fix(label): expand wildcard labels before unmarshaling and add corresponding test

This commit is contained in:
yusing
2025-06-09 20:46:39 +08:00
parent 421aaecba4
commit 25fbcc4ab9
3 changed files with 60 additions and 19 deletions

View File

@@ -127,8 +127,6 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container)
m, err := docker.ParseLabels(container.Labels)
errs.Add(err)
var wildcardProps docker.LabelMap
for alias, entryMapAny := range m {
if len(alias) == 0 {
errs.Add(gperr.New("empty alias"))
@@ -150,11 +148,6 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container)
}
}
if alias == docker.WildcardAlias {
wildcardProps = entryMap
continue
}
// check if it is an alias reference
switch alias[0] {
case aliasRefPrefix, aliasRefPrefixAlt:
@@ -189,14 +182,6 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container)
routes[alias] = r
}
}
if wildcardProps != nil {
for _, re := range routes {
if err := serialization.MapUnmarshalValidate(wildcardProps, re); err != nil {
errs.Add(err.Subject(docker.WildcardAlias))
break
}
}
}
return routes, errs.Error()
}