From 141de86862898a4b9e35c15f51031952c63c7114 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 22 Dec 2021 09:35:00 -0500 Subject: Revamp Libpod state strings for Docker compat Improve our compatibility with Docker by better handling the state strings that we print in `podman ps`. Docker capitalizes all states in `ps` (we do not) - fix this in our PS code. Also, stop normalizing ContainerStateConfigured to the "Created" state, and instead make it always be Created, with the existing Created state becoming Initialized. I didn't rename the actual states because I'm somewhat reticent to make such a large change a day before we leave for break. It's somewhat confusing that ContainerStateConfigured now returns Created, but internally and externally we're still consistent. [NO NEW TESTS NEEDED] existing tests should catch anything that broke. I also consider this a breaking change. I will flag appropriately on Github. Fixes RHBZ#2010432 and RHBZ#2032561 Signed-off-by: Matthew Heon --- libpod/define/containerstate.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'libpod/define/containerstate.go') diff --git a/libpod/define/containerstate.go b/libpod/define/containerstate.go index fc272beaa..23ba1f451 100644 --- a/libpod/define/containerstate.go +++ b/libpod/define/containerstate.go @@ -37,16 +37,23 @@ const ( ContainerStateStopping ContainerStatus = iota ) -// ContainerStatus returns a string representation for users -// of a container state +// ContainerStatus returns a string representation for users of a container +// state. All results should match Docker's versions (from `docker ps`) as +// closely as possible, given the different set of states we support. func (t ContainerStatus) String() string { switch t { case ContainerStateUnknown: return "unknown" case ContainerStateConfigured: - return "configured" - case ContainerStateCreated: + // The naming here is confusing, but it's necessary for Docker + // compatibility - their Created state is our Configured state. return "created" + case ContainerStateCreated: + // Docker does not have an equivalent to this state, so give it + // a clear name. Most of the time this is a purely transitory + // state between Configured and Running so we don't expect to + // see it much anyways. + return "initialized" case ContainerStateRunning: return "running" case ContainerStateStopped: -- cgit v1.2.3-54-g00ecf