PowerShell/Microsoft.PowerShell.Kubectl

issues when wrapping docker.exe

Opened this issue ยท 1 comments

Hey James -

Not an issue, just a comment. I did a similar thing for Docker (links below) - created a quick wrapper that took advantage of Docker's (barely documented) ability to return JSON. But even then there were a few things returned from docker.exe that had to be programmatically cleaned up:

  • often Docker date text wouldn't convert cleanly to DateTime objects
  • image file size included the unit in the text: 150MB, 229KB - bleh, we can't sort with that - so I added a property SizeKB with the values convert to KB

This special processing doesn't run for all docker.exe commands, just the ones that return tabular data, i.e. images, ps and history. Other commands are just run with docker.exe normally with stdout returned as-is; converting everything to an object seemed unnecessary - and I don't have that much free time. :-)

I agree with you, having a framework that could auto-generate wrapper functions would be useful but given the datetime and image file size issues I had with just a tiny subset of docker.exe commands I'd say the devil is definitely in the details. These exception cases aren't insurmountable but you'd want to really focus on a specific set of the most useful native exes. As far as which ones to include in that: besides Docker, I'd check what tools are used by developers most these days and maybe also check what popular UNIX/Linux tools don't have a PS Core equivalent yet.

Hope you find this useful!

-Dan Ward

https://www.powershellgallery.com/packages/Invoke-Docker-PSObject/1.0.5
https://github.com/DTW-DanWard/Invoke-Docker-PSObject

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.53. Please mark this comment with ๐Ÿ‘ or ๐Ÿ‘Ž to give our bot feedback!

Links: app homepage, dashboard and code for this bot.