inspectFormatWrite renders the context for a list of secrets.
(fmtCtx formatter.Context, refs []string, getRef inspect.GetRefFunc)
| 126 | |
| 127 | // inspectFormatWrite renders the context for a list of secrets. |
| 128 | func inspectFormatWrite(fmtCtx formatter.Context, refs []string, getRef inspect.GetRefFunc) error { |
| 129 | if fmtCtx.Format != secretInspectPrettyTemplate { |
| 130 | return inspect.Inspect(fmtCtx.Output, refs, string(fmtCtx.Format), getRef) |
| 131 | } |
| 132 | return fmtCtx.Write(&secretInspectContext{}, func(format func(subContext formatter.SubContext) error) error { |
| 133 | for _, ref := range refs { |
| 134 | secretI, _, err := getRef(ref) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | secret, ok := secretI.(swarm.Secret) |
| 139 | if !ok { |
| 140 | return fmt.Errorf("got wrong object to inspect :%v", ok) |
| 141 | } |
| 142 | if err := format(&secretInspectContext{Secret: secret}); err != nil { |
| 143 | return err |
| 144 | } |
| 145 | } |
| 146 | return nil |
| 147 | }) |
| 148 | } |
| 149 | |
| 150 | type secretInspectContext struct { |
| 151 | swarm.Secret |
no test coverage detected
searching dependent graphs…