Add host.serviceIsRemote to podman info results

Developers asked for a deterministic field to verify if podman is
running via API or linked directly to libpod library.

$ podman info --format '{{.Host.ServiceIsRemote}}'
false
$ podman-remote info --format '{{.Host.ServiceIsRemote}}'
true
$ podman --remote info --format '{{.Host.ServiceIsRemote}}'
true

* docs/conf.py formatted via black

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce
2021-05-10 13:58:20 -07:00
parent 76c8577040
commit 8ad40a85d5
4 changed files with 48 additions and 34 deletions

View File

@ -78,6 +78,8 @@ func info(cmd *cobra.Command, args []string) error {
return err return err
} }
info.Host.ServiceIsRemote = registry.IsRemote()
switch { switch {
case report.IsJSON(inFormat): case report.IsJSON(inFormat):
b, err := json.MarshalIndent(info, "", " ") b, err := json.MarshalIndent(info, "", " ")

View File

@ -29,10 +29,7 @@ author = "team"
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = ["sphinx_markdown_tables", "recommonmark"]
"sphinx_markdown_tables",
"recommonmark"
]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"] templates_path = ["_templates"]
@ -66,26 +63,27 @@ html_css_files = [
# -- Extension configuration ------------------------------------------------- # -- Extension configuration -------------------------------------------------
def convert_markdown_title(app, docname, source): def convert_markdown_title(app, docname, source):
# Process markdown files only # Process markdown files only
docpath = app.env.doc2path(docname) docpath = app.env.doc2path(docname)
if docpath.endswith(".md"): if docpath.endswith(".md"):
# Convert pandoc title line into eval_rst block for recommonmark # Convert pandoc title line into eval_rst block for recommonmark
source[0] = re.sub( source[0] = re.sub(r"^% (.*)", r"```eval_rst\n.. title:: \g<1>\n```", source[0])
r"^% (.*)",
r"```eval_rst\n.. title:: \g<1>\n```",
source[0])
def setup(app): def setup(app):
app.connect("source-read", convert_markdown_title) app.connect("source-read", convert_markdown_title)
app.add_config_value( app.add_config_value(
"recommonmark_config", { "recommonmark_config",
{
"enable_eval_rst": True, "enable_eval_rst": True,
"enable_auto_doc_ref": False, "enable_auto_doc_ref": False,
"enable_auto_toc_tree": False, "enable_auto_toc_tree": False,
"enable_math": False, "enable_math": False,
"enable_inline_math": False, "enable_inline_math": False,
}, True) },
True,
)
app.add_transform(AutoStructify) app.add_transform(AutoStructify)

View File

@ -21,7 +21,7 @@ type SecurityInfo struct {
SELinuxEnabled bool `json:"selinuxEnabled"` SELinuxEnabled bool `json:"selinuxEnabled"`
} }
//HostInfo describes the libpod host // HostInfo describes the libpod host
type HostInfo struct { type HostInfo struct {
Arch string `json:"arch"` Arch string `json:"arch"`
BuildahVersion string `json:"buildahVersion"` BuildahVersion string `json:"buildahVersion"`
@ -38,8 +38,11 @@ type HostInfo struct {
MemTotal int64 `json:"memTotal"` MemTotal int64 `json:"memTotal"`
OCIRuntime *OCIRuntimeInfo `json:"ociRuntime"` OCIRuntime *OCIRuntimeInfo `json:"ociRuntime"`
OS string `json:"os"` OS string `json:"os"`
// RemoteSocket returns the UNIX domain socket the Podman service is listening on
RemoteSocket *RemoteSocket `json:"remoteSocket,omitempty"` RemoteSocket *RemoteSocket `json:"remoteSocket,omitempty"`
RuntimeInfo map[string]interface{} `json:"runtimeInfo,omitempty"` RuntimeInfo map[string]interface{} `json:"runtimeInfo,omitempty"`
// ServiceIsRemote is true when the podman/libpod service is remote to the client
ServiceIsRemote bool `json:"serviceIsRemote"`
Security SecurityInfo `json:"security"` Security SecurityInfo `json:"security"`
Slirp4NetNS SlirpInfo `json:"slirp4netns,omitempty"` Slirp4NetNS SlirpInfo `json:"slirp4netns,omitempty"`
SwapFree int64 `json:"swapFree"` SwapFree int64 `json:"swapFree"`

View File

@ -124,4 +124,15 @@ var _ = Describe("Podman Info", func() {
} }
}) })
It("verify ServiceIsRemote", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.ServiceIsRemote}}"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
if podmanTest.RemoteTest {
Expect(session.OutputToString()).To(ContainSubstring("true"))
} else {
Expect(session.OutputToString()).To(ContainSubstring("false"))
}
})
}) })