Unverified 提交 14a09525 作者: Steven Allen 提交者: GitHub

Merge pull request #6685 from aschmahmann/fix/6527

Pinning interop: Pin ls returns appropriate zero value
...@@ -2,6 +2,7 @@ package commands ...@@ -2,6 +2,7 @@ package commands
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"io" "io"
"os" "os"
...@@ -367,6 +368,17 @@ Example: ...@@ -367,6 +368,17 @@ Example:
}, },
Type: &PinLsOutputWrapper{}, Type: &PinLsOutputWrapper{},
Encoders: cmds.EncoderMap{ Encoders: cmds.EncoderMap{
cmds.JSON: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinLsOutputWrapper) error {
stream, _ := req.Options[pinStreamOptionName].(bool)
enc := json.NewEncoder(w)
if stream {
return enc.Encode(out.PinLsObject)
}
return enc.Encode(out.PinLsList)
}),
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinLsOutputWrapper) error { cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinLsOutputWrapper) error {
quiet, _ := req.Options[pinQuietOptionName].(bool) quiet, _ := req.Options[pinQuietOptionName].(bool)
stream, _ := req.Options[pinStreamOptionName].(bool) stream, _ := req.Options[pinStreamOptionName].(bool)
...@@ -403,7 +415,7 @@ type PinLsOutputWrapper struct { ...@@ -403,7 +415,7 @@ type PinLsOutputWrapper struct {
// PinLsList is a set of pins with their type // PinLsList is a set of pins with their type
type PinLsList struct { type PinLsList struct {
Keys map[string]PinLsType `json:",omitempty"` Keys map[string]PinLsType
} }
// PinLsType contains the type of a pin // PinLsType contains the type of a pin
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论