diff options
author | Matthew Heon <mheon@redhat.com> | 2021-01-12 11:48:53 -0500 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-01-12 11:48:53 -0500 |
commit | befd40b57d4e99cccd32ba6867a85c1da816fe5e (patch) | |
tree | 694513c032cffd4180838566f5f307045cf44bfc /libpod/driver | |
parent | 1b9366d650200d0f2029d628fa00d1fd318631aa (diff) | |
download | podman-befd40b57d4e99cccd32ba6867a85c1da816fe5e.tar.gz podman-befd40b57d4e99cccd32ba6867a85c1da816fe5e.tar.bz2 podman-befd40b57d4e99cccd32ba6867a85c1da816fe5e.zip |
Exorcise Driver code from libpod/define
The libpod/define code should not import any large dependencies,
as it is intended to be structures and definitions only. It
included the libpod/driver package for information on the storage
driver, though, which brought in all of c/storage. Split the
driver package so that define has the struct, and thus does not
need to import Driver. And simplify the driver code while we're
at it.
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/driver')
-rw-r--r-- | libpod/driver/driver.go | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/libpod/driver/driver.go b/libpod/driver/driver.go index 85eda5a21..de71c1f6e 100644 --- a/libpod/driver/driver.go +++ b/libpod/driver/driver.go @@ -1,40 +1,17 @@ package driver import ( - cstorage "github.com/containers/storage" + "github.com/containers/podman/v2/libpod/define" + "github.com/containers/storage" ) -// Data handles the data for a storage driver -type Data struct { - Name string `json:"Name"` - Data map[string]string `json:"Data"` -} - -// GetDriverName returns the name of the driver for the given store -func GetDriverName(store cstorage.Store) (string, error) { - driver, err := store.GraphDriver() - if err != nil { - return "", err - } - return driver.String(), nil -} - -// GetDriverMetadata returns the metadata regarding the driver for the layer in the given store -func GetDriverMetadata(store cstorage.Store, layerID string) (map[string]string, error) { +// GetDriverData returns information on a given store's running graph driver. +func GetDriverData(store storage.Store, layerID string) (*define.DriverData, error) { driver, err := store.GraphDriver() if err != nil { return nil, err } - return driver.Metadata(layerID) -} - -// GetDriverData returns the Data struct with information of the driver used by the store -func GetDriverData(store cstorage.Store, layerID string) (*Data, error) { - name, err := GetDriverName(store) - if err != nil { - return nil, err - } - metaData, err := GetDriverMetadata(store, layerID) + metaData, err := driver.Metadata(layerID) if err != nil { return nil, err } @@ -42,8 +19,8 @@ func GetDriverData(store cstorage.Store, layerID string) (*Data, error) { delete(metaData, "MergedDir") } - return &Data{ - Name: name, + return &define.DriverData{ + Name: driver.String(), Data: metaData, }, nil } |