c8d/push: Parse source labels with multiple sources

Distribution source label can specify multiple repositories - in this
case value is a comma separated list of source repositories.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-03-31 15:35:45 +02:00
parent cb788bea9c
commit 4a34c501c1
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -219,14 +219,16 @@ func extractDistributionSources(labels map[string]string) []distributionSource {
// if yes, read it as source
for k, v := range labels {
if reg := strings.TrimPrefix(k, labelDistributionSource); reg != k {
ref, err := reference.ParseNamed(reg + "/" + v)
if err != nil {
continue
}
for _, repo := range strings.Split(v, ",") {
ref, err := reference.ParseNamed(reg + "/" + repo)
if err != nil {
continue
}
sources = append(sources, distributionSource{
registryRef: ref,
})
sources = append(sources, distributionSource{
registryRef: ref,
})
}
}
}