summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-15 14:44:46 -0600
committerbaude <bbaude@redhat.com>2019-01-15 16:01:25 -0600
commite68f03ae45adbaa539c7470aa5f99dc870c185dc (patch)
tree186737d7a6578d48496a25233831bc7465381e57 /libpod
parent341f91da480bbf337dfb13107389307835b1f0c3 (diff)
downloadpodman-e68f03ae45adbaa539c7470aa5f99dc870c185dc.tar.gz
podman-e68f03ae45adbaa539c7470aa5f99dc870c185dc.tar.bz2
podman-e68f03ae45adbaa539c7470aa5f99dc870c185dc.zip
Embed runtime struct in super localRuntime
We clean up the code by eliminating stuttering references when we embed the runtime struct into localRuntime. Makes for less change in the future as well. ++ jhonce Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/adapter/runtime.go4
-rw-r--r--libpod/adapter/runtime_remote.go40
2 files changed, 20 insertions, 24 deletions
diff --git a/libpod/adapter/runtime.go b/libpod/adapter/runtime.go
index b49c91403..1f3599082 100644
--- a/libpod/adapter/runtime.go
+++ b/libpod/adapter/runtime.go
@@ -15,8 +15,8 @@ import (
// LocalRuntime describes a typical libpod runtime
type LocalRuntime struct {
- Runtime *libpod.Runtime
- Remote bool
+ *libpod.Runtime
+ Remote bool
}
// ContainerImage ...
diff --git a/libpod/adapter/runtime_remote.go b/libpod/adapter/runtime_remote.go
index 48dcf76a9..8ef8fe167 100644
--- a/libpod/adapter/runtime_remote.go
+++ b/libpod/adapter/runtime_remote.go
@@ -22,17 +22,13 @@ type RemoteImageRuntime struct{}
// RemoteRuntime describes a wrapper runtime struct
type RemoteRuntime struct {
- Conn *varlink.Connection
+ Conn *varlink.Connection
+ Remote bool
}
-//func (r *LocalRuntime) LookupContainer(idOrName string) (*Container, error) {
-// if _, err := runtime.Runtime.LookupContainer(args[0]); err != nil {
-
// LocalRuntime describes a typical libpod runtime
type LocalRuntime struct {
- Runtime *RemoteRuntime
- Remote bool
- Conn *varlink.Connection
+ *RemoteRuntime
}
// GetRuntime returns a LocalRuntime struct with the actual runtime embedded in it
@@ -42,12 +38,14 @@ func GetRuntime(c *cli.Context) (*LocalRuntime, error) {
if err != nil {
return nil, err
}
- runtime.Conn = conn
- return &LocalRuntime{
- Runtime: &runtime,
- Remote: true,
- Conn: conn,
- }, nil
+ rr := RemoteRuntime{
+ Conn: conn,
+ Remote: true,
+ }
+ foo := LocalRuntime{
+ &rr,
+ }
+ return &foo, nil
}
// Shutdown is a bogus wrapper for compat with the libpod runtime
@@ -272,18 +270,14 @@ func (ci *ContainerImage) History(ctx context.Context) ([]*image.History, error)
return imageHistories, nil
}
-// LookupContainer ...
+// LookupContainer gets basic information about container over a varlink
+// connection and then translates it to a *Container
func (r *RemoteRuntime) LookupContainer(idOrName string) (*Container, error) {
container, err := iopodman.GetContainer().Call(r.Conn, idOrName)
if err != nil {
return nil, err
}
-
- ctr, err := listContainerDataToContainer(container)
- if err != nil {
- return nil, err
- }
- return ctr, nil
+ return listContainerDataToContainer(container)
}
// listContainerDataToContainer takes a varlink listcontainerData struct and makes
@@ -294,6 +288,8 @@ func listContainerDataToContainer(listData iopodman.ListContainerData) (*Contain
return nil, err
}
rc := remoteContainer{
+ // TODO commented out attributes will be populated when podman-remote ps
+ // is implemented. They are not needed yet for basic container operations.
ID: listData.Id,
Image: listData.Image,
ImageID: listData.Imageid,
@@ -301,13 +297,13 @@ func listContainerDataToContainer(listData iopodman.ListContainerData) (*Contain
Created: created,
RunningFor: listData.Runningfor,
Status: listData.Status,
- //ports: //map[ocicni.portmapping]
+ //ports:
RootFsSize: listData.Rootfssize,
RWSize: listData.Rwsize,
Names: listData.Names,
//Labels:
//Mounts
- //ContainerRunning: listData.r
+ //ContainerRunning:
//namespaces:
}
return &Container{rc}, nil