github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/libpod/driver/driver.go (about) 1 package driver 2 3 import ( 4 cstorage "github.com/containers/storage" 5 ) 6 7 // Data handles the data for a storage driver 8 type Data struct { 9 Name string `json:"Name"` 10 Data map[string]string `json:"Data"` 11 } 12 13 // GetDriverName returns the name of the driver for the given store 14 func GetDriverName(store cstorage.Store) (string, error) { 15 driver, err := store.GraphDriver() 16 if err != nil { 17 return "", err 18 } 19 return driver.String(), nil 20 } 21 22 // GetDriverMetadata returns the metadata regarding the driver for the layer in the given store 23 func GetDriverMetadata(store cstorage.Store, layerID string) (map[string]string, error) { 24 driver, err := store.GraphDriver() 25 if err != nil { 26 return nil, err 27 } 28 return driver.Metadata(layerID) 29 } 30 31 // GetDriverData returns the Data struct with information of the driver used by the store 32 func GetDriverData(store cstorage.Store, layerID string) (*Data, error) { 33 name, err := GetDriverName(store) 34 if err != nil { 35 return nil, err 36 } 37 metaData, err := GetDriverMetadata(store, layerID) 38 if err != nil { 39 return nil, err 40 } 41 if mountTimes, err := store.Mounted(layerID); mountTimes == 0 || err != nil { 42 delete(metaData, "MergedDir") 43 } 44 45 return &Data{ 46 Name: name, 47 Data: metaData, 48 }, nil 49 }