Skip to content

Commit

Permalink
Merge pull request #6685 from aschmahmann/fix/6527
Browse files Browse the repository at this point in the history
Pinning interop: Pin ls returns appropriate zero value
  • Loading branch information
Stebalien authored Oct 7, 2019
2 parents f97ed7d + 69bb578 commit 14a0952
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"context"
"encoding/json"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -367,6 +368,17 @@ Example:
},
Type: &PinLsOutputWrapper{},
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 {
quiet, _ := req.Options[pinQuietOptionName].(bool)
stream, _ := req.Options[pinStreamOptionName].(bool)
Expand Down Expand Up @@ -403,7 +415,7 @@ type PinLsOutputWrapper struct {

// PinLsList is a set of pins with their type
type PinLsList struct {
Keys map[string]PinLsType `json:",omitempty"`
Keys map[string]PinLsType
}

// PinLsType contains the type of a pin
Expand Down

0 comments on commit 14a0952

Please sign in to comment.