summaryrefslogtreecommitdiff
path: root/libpod/adapter/info_remote.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-02 14:56:19 -0600
committerbaude <bbaude@redhat.com>2019-01-07 12:43:57 -0600
commit41fb81d074f57bcf562e7dee78a78896e9a0bc64 (patch)
treecfb79058783d99bcfd58c1e8d46e70686c5ab834 /libpod/adapter/info_remote.go
parente796f522f6b74a9fef16976709e773f6395ef5e2 (diff)
downloadpodman-41fb81d074f57bcf562e7dee78a78896e9a0bc64.tar.gz
podman-41fb81d074f57bcf562e7dee78a78896e9a0bc64.tar.bz2
podman-41fb81d074f57bcf562e7dee78a78896e9a0bc64.zip
Add ability to build golang remote client
Add the ability to build a remote client in golang that uses all the same front-end cli code and output code. The initial limitations here are that it can only be a local client while the bridge and resolver code is being written for the golang varlink client. Tests and docs will be added in subsequent PRs. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/adapter/info_remote.go')
-rw-r--r--libpod/adapter/info_remote.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/libpod/adapter/info_remote.go b/libpod/adapter/info_remote.go
new file mode 100644
index 000000000..3b691ed17
--- /dev/null
+++ b/libpod/adapter/info_remote.go
@@ -0,0 +1,56 @@
+// +build remoteclient
+
+package adapter
+
+import (
+ "encoding/json"
+
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
+)
+
+// Info returns information for the host system and its components
+func (r RemoteRuntime) Info() ([]libpod.InfoData, error) {
+ // TODO the varlink implementation for info should be updated to match the output for regular info
+ var (
+ reply []libpod.InfoData
+ hostInfo map[string]interface{}
+ store map[string]interface{}
+ )
+
+ registries := make(map[string]interface{})
+ insecureRegistries := make(map[string]interface{})
+ conn, err := r.Connect()
+ if err != nil {
+ return nil, err
+ }
+ defer conn.Close()
+ info, err := iopodman.GetInfo().Call(conn)
+ if err != nil {
+ return nil, err
+ }
+
+ // info.host -> map[string]interface{}
+ h, err := json.Marshal(info.Host)
+ if err != nil {
+ return nil, err
+ }
+ json.Unmarshal(h, &hostInfo)
+
+ // info.store -> map[string]interface{}
+ s, err := json.Marshal(info.Store)
+ if err != nil {
+ return nil, err
+ }
+ json.Unmarshal(s, &store)
+
+ registries["registries"] = info.Registries
+ insecureRegistries["registries"] = info.Insecure_registries
+
+ // Add everything to the reply
+ reply = append(reply, libpod.InfoData{Type: "host", Data: hostInfo})
+ reply = append(reply, libpod.InfoData{Type: "registries", Data: registries})
+ reply = append(reply, libpod.InfoData{Type: "insecure registries", Data: insecureRegistries})
+ reply = append(reply, libpod.InfoData{Type: "store", Data: store})
+ return reply, nil
+}