Always show RemoteSocket.Exists in json

The `Exists` field of the `RemoteSocket` struct is marshaled to json with the
`omitempty` setting. This has the disadvantage that by default `podman info`
shows a `remotePath` entry (the remote path is set in
`pkg/domain/infra/abi/systems.go`: `(*ContainerEngine).Info`) but not that this
path does not exist:
```
❯ podman info --format json | jq .host.remoteSocket
{
  "path": "/run/user/1000/podman/podman.sock"
}
```

By removing the `omitempty`, we ensure that the existence is always shown:
```
❯ bin/podman info --format json | jq .host.remoteSocket
{
  "path": "/run/user/1000/podman/podman.sock",
  "exists": false
}
```

Signed-off-by: Dan Čermák <dcermak@suse.com>
This commit is contained in:
Dan Čermák
2023-08-01 23:53:42 +02:00
parent 0fb5b3acf0
commit dd4f47dd98
2 changed files with 3 additions and 1 deletions

View File

@ -68,7 +68,7 @@ type HostInfo struct {
// RemoteSocket describes information about the API socket
type RemoteSocket struct {
Path string `json:"path,omitempty"`
Exists bool `json:"exists,omitempty"`
Exists bool `json:"exists"`
}
// SlirpInfo describes the slirp executable that is being used

View File

@ -118,6 +118,8 @@ var _ = Describe("Podman Info", func() {
Expect(session).Should(Exit(0))
if IsRemote() {
Expect(session.OutputToString()).To(ContainSubstring("true"))
} else {
Expect(session.OutputToString()).To(ContainSubstring("false"))
}
})