Deprecate input-enc, add input-format, handle graceful upgrade #8416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref: #8415
Here's a proposal for handling a graceful transition for input-enc behaviour for 0.10.0.
Ideally I'd like
input-enc
to not be shown on thehelp
output but in lieu of that I thought adding a "DEPRECATED" notice might be a good idea.The behaviour here is:
input-format
then use that, ignoringinput-enc
input-format
or aninput-enc
then defaultinput-format
todag-json
input-format
but do supply aninput-enc
then map as per current behaviour in https://github.com/ipfs/go-ipfs/blob/master/core/coredag/dagtransl.go - which is essentially accepting input as bytes presumed to be informat
codec except in the case ofjson
where we switch todag-json
.There is some laxity around
input-enc
that doesn't currently exist - it'll accept any valid codec too and just push that intoinput-format
so it can be used as an alias forinput-format
in that case (I mainly did this to get the proper error output for a bad value).This makes https://github.com/ipfs/js-ipfs/blob/870d446f/packages/ipfs-http-client/test/dag.spec.js pass except for the missing
cid-version
and new default of CIDv1.So,
ipfs dag put --input-enc=raw --format=dag-pb
works as per previous versions in that it's going to assume you're giving it bytes of a valid dag-pb block. This would beipfs dag put --input-format=dag-pb --format=dag-pb
in the new style, whereasipfs dag put --input-format=raw --format=dag-pb
is not going to work because you can't just stick a single byte array into a dag-pb codec, that's invalid.For another example,
ipfs dag put --input-enc=raw --format=dag-cbor
is going to be the same asipfs dag put --input-enc=raw --format=dag-cbor
, butipfs dag put --input-format=raw --format=dag-cbor
is entirely different and would encode your incoming bytes as a single terminal CBOR with the "byte string" prefix.