inspectFormatWrite renders the context for a list of nodes.
(fmtCtx formatter.Context, refs []string, getRef inspect.GetRefFunc)
| 193 | |
| 194 | // inspectFormatWrite renders the context for a list of nodes. |
| 195 | func inspectFormatWrite(fmtCtx formatter.Context, refs []string, getRef inspect.GetRefFunc) error { |
| 196 | if fmtCtx.Format != nodeInspectPrettyTemplate { |
| 197 | return inspect.Inspect(fmtCtx.Output, refs, string(fmtCtx.Format), getRef) |
| 198 | } |
| 199 | return fmtCtx.Write(&nodeInspectContext{}, func(format func(subContext formatter.SubContext) error) error { |
| 200 | for _, ref := range refs { |
| 201 | nodeI, _, err := getRef(ref) |
| 202 | if err != nil { |
| 203 | return err |
| 204 | } |
| 205 | node, ok := nodeI.(swarm.Node) |
| 206 | if !ok { |
| 207 | return fmt.Errorf("got wrong object to inspect :%v", ok) |
| 208 | } |
| 209 | if err := format(&nodeInspectContext{Node: node}); err != nil { |
| 210 | return err |
| 211 | } |
| 212 | } |
| 213 | return nil |
| 214 | }) |
| 215 | } |
| 216 | |
| 217 | type nodeInspectContext struct { |
| 218 | swarm.Node |
searching dependent graphs…