shiplift
shiplift copied to clipboard
[RFC] Logs tty
trafficstars
PoC for fixing https://github.com/softprops/shiplift/issues/295. Works well enough as a workaround for my use case, but the current implementation still has some issues which I would like to get feedback on how to best resolve:
- The library user needs to correctly choose between
logs_ttyandlogs, and choosing the wrong one will either produce additional garbage in stout from multiplexing headers or fail to return any input at all. The approach taken by the docker CLI is to run aninspectfirst to determine if the container uses tty: https://github.com/docker/cli/blob/86e1f04b5f115fb0b4bbd51e0e4a68233072d24b/cli/command/container/logs.go#L53. This would require an additional request, but imo worth it to allows to have a single method without any additional arguments that always returns the correct result. - The
impltypes returned by the different streams are not compatible, an alternative would be to returnBox<dyn Stream<Item = _> + Unpin>. Overhead is probably pretty minimal compared to network IO. - Current implementation does a lot of unnecessary allocations which are probably easily avoidable for someone who knows more about
Stream-munging than I do.
Oh one more issue, the logs_tty function now never terminates as long as the container is alive even when you don't set tail. Not sure how to correctly detect the end of the current output.
Requested @softprops review here because I really don't know :shrug: