@cryptotaxi247 / kubo / commits / 2e8b0bfee

change names of ipfs dag put flags to make changes clearer

(cherry picked from commit 29206790564e6678986773557e2c7251e3ec0ac0)

Adin Schmahmann committed Sep 15, 2021 at 15:16 UTC 2e8b0bfee780e357f7045c4c763b8878f11271db
5 files changed +29 -29
core/commands/dag/dag.go
+2 -2
@@ -84,8 +84,8 @@ into an object of the specified format.
84 cmds.FileArg("object data", true, true, "The object to put").EnableStdin(),
85 },
86 Options: []cmds.Option{
87 - cmds.StringOption("format", "f", "Format that the object will be added as.").WithDefault("dag-cbor"),
88 - cmds.StringOption("input-enc", "Format that the input object will be.").WithDefault("dag-json"),
87 + cmds.StringOption("store-codec", "s", "Codec that the stored object will be encoded with").WithDefault("dag-cbor"),
88 + cmds.StringOption("input-codec", "i", "Codec that the input object is encoded in").WithDefault("dag-json"),
89 cmds.BoolOption("pin", "Pin this object when adding."),
90 cmds.StringOption("hash", "Hash function to use").WithDefault("sha2-256"),
91 },
core/commands/dag/put.go
+7 -7
@@ -31,17 +31,17 @@ func dagPut(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) e
31 return err
32 }
33
34 - ienc, _ := req.Options["input-enc"].(string)
35 - format, _ := req.Options["format"].(string)
34 + inputCodec, _ := req.Options["input-codec"].(string)
35 + storeCodec, _ := req.Options["store-codec"].(string)
36 hash, _ := req.Options["hash"].(string)
37 dopin, _ := req.Options["pin"].(bool)
38
39 var icodec mc.Code
40 - if err := icodec.Set(ienc); err != nil {
40 + if err := icodec.Set(inputCodec); err != nil {
41 return err
42 }
43 - var fcodec mc.Code
44 - if err := fcodec.Set(format); err != nil {
43 + var scodec mc.Code
44 + if err := scodec.Set(storeCodec); err != nil {
45 return err
46 }
47 var mhType mc.Code
@@ -51,7 +51,7 @@ func dagPut(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) e
51
52 cidPrefix := cid.Prefix{
53 Version: 1,
54 - Codec: uint64(fcodec),
54 + Codec: uint64(scodec),
55 MhType: uint64(mhType),
56 MhLength: -1,
57 }
@@ -60,7 +60,7 @@ func dagPut(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) e
60 if err != nil {
61 return err
62 }
63 - encoder, err := multicodec.LookupEncoder(uint64(fcodec))
63 + encoder, err := multicodec.LookupEncoder(uint64(scodec))
64 if err != nil {
65 return err
66 }
test/sharness/t0053-dag.sh
+17 -17
@@ -45,7 +45,7 @@ test_dag_cmd() {
45 '
46
47 test_expect_success "can add an ipld object using dag-json to dag-json" '
48 - IPLDHASH=$(cat ipld_object | ipfs dag put --input-enc=dag-json -f dag-json)
48 + IPLDHASH=$(cat ipld_object | ipfs dag put -i dag-json -s dag-json)
49 '
50
51 test_expect_success "CID looks correct" '
@@ -54,7 +54,7 @@ test_dag_cmd() {
54 '
55
56 test_expect_success "can add an ipld object using dag-json to dag-cbor" '
57 - IPLDHASH=$(cat ipld_object | ipfs dag put --input-enc=dag-json -f dag-cbor)
57 + IPLDHASH=$(cat ipld_object | ipfs dag put -i dag-json -s dag-cbor)
58 '
59
60 test_expect_success "CID looks correct" '
@@ -75,7 +75,7 @@ test_dag_cmd() {
75 # (1) dag-cbor input
76
77 test_expect_success "can add a dag-cbor input block stored as dag-cbor" '
78 - IPLDCBORHASH=$(cat ipld_object_dagcbor | ipfs dag put --input-enc=dag-cbor -f dag-cbor)
78 + IPLDCBORHASH=$(cat ipld_object_dagcbor | ipfs dag put -i dag-cbor -s dag-cbor)
79 '
80
81 test_expect_success "dag-cbor CID looks correct" '
@@ -84,7 +84,7 @@ test_dag_cmd() {
84 '
85
86 test_expect_success "can add a dag-cbor input block stored as dag-pb" '
87 - IPLDPBHASH=$(cat ipld_object_dagcbor | ipfs dag put --input-enc=dag-cbor -f dag-pb)
87 + IPLDPBHASH=$(cat ipld_object_dagcbor | ipfs dag put -i dag-cbor -s dag-pb)
88 '
89
90 test_expect_success "dag-pb CID looks correct" '
@@ -93,7 +93,7 @@ test_dag_cmd() {
93 '
94
95 test_expect_success "can add a dag-cbor input block stored as dag-json" '
96 - IPLDJSONHASH=$(cat ipld_object_dagcbor | ipfs dag put --input-enc=dag-cbor -f dag-json)
96 + IPLDJSONHASH=$(cat ipld_object_dagcbor | ipfs dag put -i dag-cbor -s dag-json)
97 '
98
99 test_expect_success "dag-json CID looks correct" '
@@ -104,7 +104,7 @@ test_dag_cmd() {
104 # (2) dag-json input
105
106 test_expect_success "can add a dag-json input block stored as dag-cbor" '
107 - IPLDCBORHASH=$(cat ipld_object_dagjson | ipfs dag put --input-enc=dag-json -f dag-cbor)
107 + IPLDCBORHASH=$(cat ipld_object_dagjson | ipfs dag put -i dag-json -s dag-cbor)
108 '
109
110 test_expect_success "dag-cbor CID looks correct" '
@@ -113,7 +113,7 @@ test_dag_cmd() {
113 '
114
115 test_expect_success "can add a dag-json input block stored as dag-pb" '
116 - IPLDPBHASH=$(cat ipld_object_dagjson | ipfs dag put --input-enc=dag-json -f dag-pb)
116 + IPLDPBHASH=$(cat ipld_object_dagjson | ipfs dag put -i dag-json -s dag-pb)
117 '
118
119 test_expect_success "dag-pb CID looks correct" '
@@ -122,7 +122,7 @@ test_dag_cmd() {
122 '
123
124 test_expect_success "can add a dag-json input block stored as dag-json" '
125 - IPLDJSONHASH=$(cat ipld_object_dagjson | ipfs dag put --input-enc=dag-json -f dag-json)
125 + IPLDJSONHASH=$(cat ipld_object_dagjson | ipfs dag put -i dag-json -s dag-json)
126 '
127
128 test_expect_success "dag-json CID looks correct" '
@@ -133,7 +133,7 @@ test_dag_cmd() {
133 # (3) dag-pb input
134
135 test_expect_success "can add a dag-pb input block stored as dag-cbor" '
136 - IPLDCBORHASH=$(cat ipld_object_dagpb | ipfs dag put --input-enc=dag-pb -f dag-cbor)
136 + IPLDCBORHASH=$(cat ipld_object_dagpb | ipfs dag put -i dag-pb -s dag-cbor)
137 '
138
139 test_expect_success "dag-cbor CID looks correct" '
@@ -142,7 +142,7 @@ test_dag_cmd() {
142 '
143
144 test_expect_success "can add a dag-pb input block stored as dag-pb" '
145 - IPLDPBHASH=$(cat ipld_object_dagpb | ipfs dag put --input-enc=dag-pb -f dag-pb)
145 + IPLDPBHASH=$(cat ipld_object_dagpb | ipfs dag put -i dag-pb -s dag-pb)
146 '
147
148 test_expect_success "dag-pb CID looks correct" '
@@ -151,7 +151,7 @@ test_dag_cmd() {
151 '
152
153 test_expect_success "can add a dag-pb input block stored as dag-json" '
154 - IPLDJSONHASH=$(cat ipld_object_dagpb | ipfs dag put --input-enc=dag-pb -f dag-json)
154 + IPLDJSONHASH=$(cat ipld_object_dagpb | ipfs dag put -i dag-pb -s dag-json)
155 '
156
157 test_expect_success "dag-json CID looks correct" '
@@ -245,7 +245,7 @@ test_dag_cmd() {
245 '
246
247 test_expect_success "retrieved object hashes back correctly" '
248 - IPLDHASH2=$(cat ipld_obj_out | ipfs dag put --input-enc=dag-json -f dag-cbor) &&
248 + IPLDHASH2=$(cat ipld_obj_out | ipfs dag put -i dag-json -s dag-cbor) &&
249 test "$IPLDHASH" = "$IPLDHASH2"
250 '
251
@@ -272,7 +272,7 @@ test_dag_cmd() {
272 '
273
274 test_expect_success "non-canonical dag-cbor input is normalized" '
275 - HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=dag-cbor --input-enc=dag-cbor) &&
275 + HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put -s dag-cbor -i dag-cbor) &&
276 test $HASH = "bafyreiawx7ona7oa2ptcoh6vwq4q6bmd7x2ibtkykld327bgb7t73ayrqm" ||
277 test_fsh echo $HASH
278 '
@@ -283,7 +283,7 @@ test_dag_cmd() {
283 '
284
285 test_expect_success "add an ipld with pin" '
286 - PINHASH=$(printf {\"foo\":\"bar\"} | ipfs dag put --input-enc=dag-json --pin=true)
286 + PINHASH=$(printf {\"foo\":\"bar\"} | ipfs dag put -i dag-json --pin=true)
287 '
288
289 test_expect_success "after gc, objects still accessible" '
@@ -307,7 +307,7 @@ test_dag_cmd() {
307
308 test_expect_success "dag put with json dag-pb works" '
309 ipfs dag get $HASH > pbjson &&
310 - cat pbjson | ipfs dag put --format=dag-pb --input-enc=dag-json > dag_put_out
310 + cat pbjson | ipfs dag put --store-codec=dag-pb --input-codec=dag-json > dag_put_out
311 '
312
313 test_expect_success "dag put with dag-pb works output looks good" '
@@ -317,7 +317,7 @@ test_dag_cmd() {
317
318 test_expect_success "dag put with raw dag-pb works" '
319 ipfs block get $HASH > pbraw &&
320 - cat pbraw | ipfs dag put --format=dag-pb --input-enc=dag-pb > dag_put_out
320 + cat pbraw | ipfs dag put --store-codec=dag-pb --input-codec=dag-pb > dag_put_out
321 '
322
323 test_expect_success "dag put with dag-pb works output looks good" '
@@ -327,7 +327,7 @@ test_dag_cmd() {
327
328 test_expect_success "dag put with raw node works" '
329 echo "foo bar" > raw_node_in &&
330 - HASH=$(ipfs dag put --format=raw --input-enc=raw -- raw_node_in) &&
330 + HASH=$(ipfs dag put --store-codec=raw --input-codec=raw -- raw_node_in) &&
331 ipfs block get "$HASH" > raw_node_out &&
332 test_cmp raw_node_in raw_node_out'
333
test/sharness/t0055-dag-put-json-new-line.sh
+2 -2
@@ -14,8 +14,8 @@ test_expect_success 'create test JSON files' '
14 '
15
16 test_expect_success 'puts as CBOR work' '
17 - GOT_HASH_WITHOUT_NEWLINE="$(cat without_newline.json | ipfs dag put -f dag-cbor)"
18 - GOT_HASH_WITH_NEWLINE="$(cat with_newline.json | ipfs dag put -f dag-cbor)"
17 + GOT_HASH_WITHOUT_NEWLINE="$(cat without_newline.json | ipfs dag put -s dag-cbor)"
18 + GOT_HASH_WITH_NEWLINE="$(cat with_newline.json | ipfs dag put -s dag-cbor)"
19 '
20
21 test_expect_success 'put hashes with or without newline are equal' '
test/sharness/t0280-plugin-git.sh
+1 -1
@@ -17,7 +17,7 @@ test_expect_success "prepare test data" '
17
18 test_dag_git() {
19 test_expect_success "add objects via dag put" '
20 - find objects -type f -exec ipfs dag put --format=git-raw --input-enc=0x300078 --hash=sha1 {} \; -exec echo -n \; > hashes
20 + find objects -type f -exec ipfs dag put --store-codec=git-raw --input-codec=0x300078 --hash=sha1 {} \; -exec echo -n \; > hashes
21 '
22
23 test_expect_success "successfully get added objects" '