Add the configuration file used to setup storage to podman info

Users have no idea what storage configuration file is used to setup
storage, so adding this to podman info, should make it easier to
discover.

This requires a revendor of containers/storage

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2019-01-07 10:01:44 -05:00
parent a219431a31
commit b367855d5f
4 changed files with 15 additions and 3 deletions

View File

@ -61,6 +61,7 @@ registries:
- docker.io - docker.io
- registry.access.redhat.com - registry.access.redhat.com
store: store:
ConfigFile: /etc/containers/storage.conf
ContainerStore: ContainerStore:
number: 37 number: 37
GraphDriverName: overlay GraphDriverName: overlay

View File

@ -13,6 +13,7 @@ import (
"time" "time"
"github.com/containers/libpod/pkg/rootless" "github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/util"
"github.com/containers/libpod/utils" "github.com/containers/libpod/utils"
"github.com/containers/storage/pkg/system" "github.com/containers/storage/pkg/system"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -115,6 +116,7 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
func (r *Runtime) storeInfo() (map[string]interface{}, error) { func (r *Runtime) storeInfo() (map[string]interface{}, error) {
// lets say storage driver in use, number of images, number of containers // lets say storage driver in use, number of images, number of containers
info := map[string]interface{}{} info := map[string]interface{}{}
info["ConfigFile"] = util.StorageConfigFile()
info["GraphRoot"] = r.store.GraphRoot() info["GraphRoot"] = r.store.GraphRoot()
info["RunRoot"] = r.store.RunRoot() info["RunRoot"] = r.store.RunRoot()
info["GraphDriverName"] = r.store.GraphDriverName() info["GraphDriverName"] = r.store.GraphDriverName()

View File

@ -314,7 +314,7 @@ func GetDefaultStoreOptions() (storage.StoreOptions, string, error) {
return storageOpts, volumePath, err return storageOpts, volumePath, err
} }
storageConf := filepath.Join(os.Getenv("HOME"), ".config/containers/storage.conf") storageConf := StorageConfigFile()
if _, err := os.Stat(storageConf); err == nil { if _, err := os.Stat(storageConf); err == nil {
storage.ReloadConfigurationFile(storageConf, &storageOpts) storage.ReloadConfigurationFile(storageConf, &storageOpts)
} else if os.IsNotExist(err) { } else if os.IsNotExist(err) {
@ -334,3 +334,11 @@ func GetDefaultStoreOptions() (storage.StoreOptions, string, error) {
} }
return storageOpts, volumePath, nil return storageOpts, volumePath, nil
} }
// StorageConfigFile returns the path to the storage config file used
func StorageConfigFile() string {
if rootless.IsRootless() {
return filepath.Join(os.Getenv("HOME"), ".config/containers/storage.conf")
}
return storage.DefaultConfigFile
}

View File

@ -2992,7 +2992,8 @@ func copyStringInterfaceMap(m map[string]interface{}) map[string]interface{} {
return ret return ret
} }
const defaultConfigFile = "/etc/containers/storage.conf" // DefaultConfigFile path to the system wide storage.conf file
const DefaultConfigFile = "/etc/containers/storage.conf"
// ThinpoolOptionsConfig represents the "storage.options.thinpool" // ThinpoolOptionsConfig represents the "storage.options.thinpool"
// TOML config table. // TOML config table.
@ -3237,7 +3238,7 @@ func init() {
DefaultStoreOptions.GraphRoot = "/var/lib/containers/storage" DefaultStoreOptions.GraphRoot = "/var/lib/containers/storage"
DefaultStoreOptions.GraphDriverName = "" DefaultStoreOptions.GraphDriverName = ""
ReloadConfigurationFile(defaultConfigFile, &DefaultStoreOptions) ReloadConfigurationFile(DefaultConfigFile, &DefaultStoreOptions)
} }
func GetDefaultMountOptions() ([]string, error) { func GetDefaultMountOptions() ([]string, error) {