2017-06-27 13:45:25 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
is "github.com/containers/image/storage"
|
|
|
|
"github.com/containers/storage"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getStore(c *cli.Context) (storage.Store, error) {
|
|
|
|
options := storage.DefaultStoreOptions
|
2017-06-16 17:24:00 +00:00
|
|
|
if c.GlobalIsSet("root") {
|
2017-06-30 19:10:57 +00:00
|
|
|
options.GraphRoot = c.GlobalString("root")
|
2017-06-16 17:24:00 +00:00
|
|
|
}
|
|
|
|
if c.GlobalIsSet("runroot") {
|
2017-06-30 19:10:57 +00:00
|
|
|
options.RunRoot = c.GlobalString("runroot")
|
|
|
|
}
|
|
|
|
|
2017-06-27 13:45:25 +00:00
|
|
|
if c.GlobalIsSet("storage-driver") {
|
|
|
|
options.GraphDriverName = c.GlobalString("storage-driver")
|
|
|
|
}
|
|
|
|
if c.GlobalIsSet("storage-opt") {
|
|
|
|
opts := c.GlobalStringSlice("storage-opt")
|
|
|
|
if len(opts) > 0 {
|
|
|
|
options.GraphDriverOptions = opts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
store, err := storage.GetStore(options)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
is.Transport.SetStore(store)
|
|
|
|
return store, nil
|
|
|
|
}
|