-
Notifications
You must be signed in to change notification settings - Fork 12
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
add support for passing in input from STDIN #72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit
pkg/cmd/convert.go
Outdated
@@ -62,12 +63,22 @@ func GetValidatedObject(v *viper.Viper, cmd *cobra.Command, out, outerr io.Write | |||
} | |||
|
|||
var ocObjects []*object.OpenCompose | |||
var data []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the declaration back to the loop where it was before. extending the scope is error prone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
When I run $ opencompose convert -f - It remains stuck, is this behavior okay? |
@surajssd yep, this is the desired behavior, it is waiting for input. |
pkg/cmd/convert.go
Outdated
return nil, fmt.Errorf("unable to read file '%s': %s", file, err) | ||
// Check if the passed resource points to STDIN or not | ||
if file == "-" { | ||
data, err = ioutil.ReadAll(os.Stdin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious: does cobra provide a way to read from STDIN ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@surajssd I didn't find any method in cobra regarding this, do you know something that can help?
How do we test this? |
But, I don't think that we should worry too much about testing this few lines. |
This commit lets passing input from STDIN to opencompose like in the following example - `cat example.yaml | opencompose -f -` An error will be returned if reading from STDIN fails. Fixes redhat-developer#63
'small nit' was fixed. and code looks ok
This commit lets passing input from STDIN to opencompose like in
the following example -
cat example.yaml | opencompose -f -
An error will be returned if reading from STDIN fails.
Fixes #63
ping @tnozicka @surajssd @kadel