From 60a7f58c1a4274106cf11f9d5f104bfcb979162b Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Wed, 15 Sep 2021 17:27:23 -0400 Subject: [PATCH] feat: update dag put to use the newer flags --- dag.go | 8 ++++---- options/dag.go | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dag.go b/dag.go index cf5886f07..da6985049 100644 --- a/dag.go +++ b/dag.go @@ -15,8 +15,8 @@ func (s *Shell) DagGet(ref string, out interface{}) error { return s.Request("dag/get", ref).Exec(context.Background(), out) } -func (s *Shell) DagPut(data interface{}, ienc, kind string) (string, error) { - return s.DagPutWithOpts(data, options.Dag.InputEnc(ienc), options.Dag.Kind(kind)) +func (s *Shell) DagPut(data interface{}, inputCodec, storeCodec string) (string, error) { + return s.DagPutWithOpts(data, options.Dag.InputCodec(inputCodec), options.Dag.StoreCodec(storeCodec)) } func (s *Shell) DagPutWithOpts(data interface{}, opts ...options.DagPutOption) (string, error) { @@ -49,8 +49,8 @@ func (s *Shell) DagPutWithOpts(data interface{}, opts ...options.DagPutOption) ( return out.Cid.Target, s. Request("dag/put"). - Option("input-enc", cfg.InputEnc). - Option("format", cfg.Kind). + Option("input-codec", cfg.InputCodec). + Option("store-codec", cfg.StoreCodec). Option("pin", cfg.Pin). Option("hash", cfg.Hash). Body(fileReader). diff --git a/options/dag.go b/options/dag.go index 3db2890cc..4b13843f5 100644 --- a/options/dag.go +++ b/options/dag.go @@ -2,10 +2,10 @@ package options // DagPutSettings is a set of DagPut options. type DagPutSettings struct { - InputEnc string - Kind string - Pin string - Hash string + InputCodec string + StoreCodec string + Pin string + Hash string } // DagPutOption is a single DagPut option. @@ -14,10 +14,10 @@ type DagPutOption func(opts *DagPutSettings) error // DagPutOptions applies the given options to a DagPutSettings instance. func DagPutOptions(opts ...DagPutOption) (*DagPutSettings, error) { options := &DagPutSettings{ - InputEnc: "dag-json", - Kind: "dag-cbor", - Pin: "false", - Hash: "sha2-256", + InputCodec: "dag-json", + StoreCodec: "dag-cbor", + Pin: "false", + Hash: "sha2-256", } for _, opt := range opts { @@ -42,20 +42,20 @@ func (dagOpts) Pin(pin string) DagPutOption { } } -// InputEnc is an option for Dag.Put which specifies the input encoding of the -// data. Default is "json", most formats/codecs support "raw". -func (dagOpts) InputEnc(enc string) DagPutOption { +// InputCodec is an option for Dag.Put which specifies the input encoding of the +// data. Default is "dag-json". +func (dagOpts) InputCodec(codec string) DagPutOption { return func(opts *DagPutSettings) error { - opts.InputEnc = enc + opts.InputCodec = codec return nil } } -// Kind is an option for Dag.Put which specifies the format that the dag -// will be added as. Default is "cbor". -func (dagOpts) Kind(kind string) DagPutOption { +// StoreCodec is an option for Dag.Put which specifies the codec that the stored +// object will be encoded with. Default is "dag-cbor". +func (dagOpts) StoreCodec(codec string) DagPutOption { return func(opts *DagPutSettings) error { - opts.Kind = kind + opts.StoreCodec = codec return nil } }