separate manual and automatically detected platforms

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2020-04-24 20:08:43 -07:00
parent d89e3f3014
commit 4804824c78
3 changed files with 23 additions and 3 deletions

View File

@ -53,6 +53,27 @@ func Dedupe(in []specs.Platform) []specs.Platform {
return out
}
func FormatInGroups(gg ...[]specs.Platform) []string {
m := map[string]struct{}{}
out := make([]string, 0, len(gg))
for i, g := range gg {
for _, p := range g {
p := platforms.Normalize(p)
key := platforms.Format(p)
if _, ok := m[key]; ok {
continue
}
m[key] = struct{}{}
v := platforms.Format(p)
if i == 0 {
v += "*"
}
out = append(out, v)
}
}
return out
}
func Format(in []specs.Platform) []string {
if len(in) == 0 {
return nil