context: implement lazy loading, and other improvements by thaJeztah · Pull Request #3847 · docker/cli (original) (raw)

Could we shorten the error to "context does not exist" in this case? The name is already in the NAME column, so I think that load context "nosuchcontext" doesn't add much value here.
This could still make the "context does not exist" invisible, if the name is long though.

Yes, I was looking at that originally; the tricky bit here was that the error is produced in a part of the code that's called in quite some places, and I couldn't immediately judge if removing the name from the error would hide relevant information (which context failed to load?) in all of those cases. We can definitely look at this again, and perhaps improve. I also want to add the --no-trunc option (have some of that stashed locally), but will keep that for a follow-up.

I tweaked things a bit; changedc the load context "name of context" to context "name of context", and changed does not exist to not found;

NAME              DESCRIPTION                               DOCKER ENDPOINT               ERROR
default           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   
nosuchcontext *                                                                           context "nosuchcontext": context not found: …

We could also the default order of the columns to: NAME, ENDPOINT, ERROR, DESCRIPTION.
Name and endpoint seem to be the most important bits, error in most cases should be empty so shouldn't take up much space, and truncating description is probably the least harmful.

I stuck with current conventions of putting the ERROR as last column, but also agree that I always was a bit on the fence for DESCRIPTION altogether; perhaps NAME, ENDPOINT, DESCRIPTION, ERROR? Let's fine-tune this in a follow up.