mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 17:05:46 +08:00
Merge pull request #263 from tonistiigi/platforms-print
separate manual and automatically detected platforms
This commit is contained in:
commit
09339bf500
@ -118,7 +118,7 @@ func runInspect(dockerCli command.Cli, in inspectOptions) 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), ", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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), ", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user