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

@ -117,7 +117,7 @@ func runInspect(dockerCli command.Cli, in inspectOptions, args []string) error {
if len(n.Flags) > 0 { if len(n.Flags) > 0 {
fmt.Fprintf(w, "Flags:\t%s\n", strings.Join(n.Flags, " ")) fmt.Fprintf(w, "Flags:\t%s\n", strings.Join(n.Flags, " "))
} }
fmt.Fprintf(w, "Platforms:\t%s\n", strings.Join(platformutil.Format(platformutil.Dedupe(append(n.Platforms, ngi.drivers[i].platforms...))), ", ")) fmt.Fprintf(w, "Platforms:\t%s\n", strings.Join(platformutil.FormatInGroups(n.Platforms, ngi.drivers[i].platforms), ", "))
} }
} }
} }

View File

@ -126,11 +126,10 @@ func printngi(w io.Writer, ngi *nginfo) {
if d.info != nil { if d.info != nil {
status = d.info.Status.String() status = d.info.Status.String()
} }
p := append(n.Platforms, d.platforms...)
if err != "" { if err != "" {
fmt.Fprintf(w, " %s\t%s\t%s\n", n.Name, n.Endpoint, err) fmt.Fprintf(w, " %s\t%s\t%s\n", n.Name, n.Endpoint, err)
} else { } else {
fmt.Fprintf(w, " %s\t%s\t%s\t%s\n", n.Name, n.Endpoint, status, strings.Join(platformutil.Format(p), ", ")) fmt.Fprintf(w, " %s\t%s\t%s\t%s\n", n.Name, n.Endpoint, status, strings.Join(platformutil.FormatInGroups(n.Platforms, d.platforms), ", "))
} }
} }
} }

View File

@ -53,6 +53,27 @@ func Dedupe(in []specs.Platform) []specs.Platform {
return out 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 { func Format(in []specs.Platform) []string {
if len(in) == 0 { if len(in) == 0 {
return nil return nil