Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commands: remove EnableStdin support for StringArg [v2] #2902

Merged
merged 3 commits into from
Jun 28, 2016
Merged

commands: remove EnableStdin support for StringArg [v2] #2902

merged 3 commits into from
Jun 28, 2016

Conversation

atomgardner
Copy link
Contributor

@atomgardner atomgardner commented Jun 24, 2016

With verbose flag:

  • remove EnableStdin() flags on all StringArg,
  • remove all unneeded parsing code for StringArg, and print an
    informative message if ipfs begins reading from a CharDevice,
  • remove broken go tests for EnableStdin cli parsing, and add some
    trivial test cases for reading FileArg from stdin,
  • add a panic to prevent EnableStdin from being set on
    StringArg in the future.

Resolves: #2877, #2870, #2868
License: MIT
Signed-off-by: Thomas Gardner [email protected]

@Kubuxu Kubuxu added this to the ipfs-0.4.3 milestone Jun 24, 2016
@@ -325,6 +301,10 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
var file files.File
var err error
if fpath == "-" {
stdInfo, _ := stdin.Stat()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this error shouldn't happen in practice but we should check for it either way.
Log it under log.Error with some "This shouldn't happen" message.

@Kubuxu
Copy link
Member

Kubuxu commented Jun 24, 2016

@thomas-gardner great work on that, I left a comment and thing left to do is changing sharness tests to accommodate this change. Also I am writing down why we decided to make this change and what we are changing.

@Kubuxu Kubuxu added status/in-progress In progress need/review Needs a review and removed status/in-progress In progress labels Jun 24, 2016
@Kubuxu
Copy link
Member

Kubuxu commented Jun 24, 2016

In this PR we are removing support of direct stdin handling for non-file type arguments in go-ipfs. There are two main reasons why we decided for it:

  • making non-file type arguments being piped into ipfs process behave as expected is very difficult task. It is connected with fact that on CLI side there is very limited logic running and this logic can't decided if some argument will be used or not. This lead to introduction of regression that caused --help to hang (Required String arugments with stdin handling enabled block --help #2868). Some of you will say: "It was working before", my response is: "No it wasn't". We were cheating by treating console differently from other types of inputs which became a problem with docker and embedded nodes.
  • behaviour like that is unprecedented before in any other command. It can be replicated with much more flexibility using the xargs command, is explicit and familiar to users and doesn't expose us to implementation edge cases.

Those are two main reasons for removal of direct stdin handling for non-file type arguments in ipfs command.

@Kubuxu
Copy link
Member

Kubuxu commented Jun 24, 2016

As I am really co-creator of this issue/PR @whyrusleeping you would have to look at it.


if _, err := io.WriteString(fstdin, content); err != nil {
t.Fatal(err)
}
return fstdin
}

test([]string{"stdinenabled", "value1", "value2"}, nil, []string{"value1", "value2"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that all these tests need to be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whyrusleeping Presently yes, or they'll need to be changed. If you think it's dire, I can add a test funciton to read through the SilceFile and check filenames, which should allow for some less trivial File/String/stdin/error combos.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely want to have solid coverage over this. I'm not in favor of mass removing tests like this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i noticed you added a bunch in now)

With verbose flag:
* remove EnableStdin() flags on all StringArg,

* remove all unneeded parsing code for StringArg, and print an
* informative message if `ipfs` begins reading from a CharDevice,

* remove broken go tests for EnableStdin cli parsing, and add some
* trivial test cases for reading FileArg from stdin,

* add a panic to prevent EnableStdin from being set on
* StringArg in the future.

Resolves: #2877, #2870
License: MIT
Signed-off-by: Thomas Gardner <[email protected]>
License: MIT
Signed-off-by: Thomas Gardner <[email protected]>
License: MIT
Signed-off-by: Thomas Gardner <[email protected]>
@Kubuxu
Copy link
Member

Kubuxu commented Jun 28, 2016

LGTM

test_expect_success "ipfs cat accept hash from stdin" '
echo "$HASH" | ipfs cat >actual
test_expect_success "ipfs cat accept hash from built input" '
echo "$HASH" | xargs ipfs cat >actual
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this had been reverted, @whyrusleeping @Kubuxu -- the tests on master show it's still here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want this test file have 0 (or minimal) changes in rc4.

@Kubuxu Kubuxu self-assigned this Aug 27, 2016
@Kubuxu Kubuxu removed their assignment Mar 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants