infrablocks / ruby_terraform

A simple Ruby wrapper for invoking terraform commands.
MIT License
109 stars 33 forks source link

Allow output streams (stdout, stderr) to be provided rather than assuming $stdout and $stderr. #13

Closed tobyclemson closed 5 years ago

tobyclemson commented 6 years ago

Further context for this available in PR #12.

tobyclemson commented 6 years ago

@cbaines said:

I'm interested in capturing the output, in near real time if possible, as I'd like to make it available in a web interface. I think this change should enable changing $stdout and $stderr for the duration of the Terraform command, in a similar manor to how the Output command works.

and

I think the real time aspect of this might be a bit difficult, as it looks like that would require modifying the lino gem to use something like the background functionality of open4, so I'd be interested if you have any thoughts on that?

Thoughts:

I think what you really want here is a way to inject the streams used for stdout/stderr into a command with the command defaulting to $stdout / $stderr if none is passed. That way you don't need to change globals to get the intended effect.

With respect to real time streaming, my understanding is that the output is already being streamed but it is buffered and flushed periodically such that it's not quite real time. This may be good enough.

Potentially this could be made more real time using the approach outlined in https://stackoverflow.com/questions/10409140/streaming-data-from-stdout. This would need to be a change to lino.

tobyclemson commented 5 years ago

All standard streams are now configurable as of version 0.30.0.