mirror of
https://github.com/containers/skopeo.git
synced 2025-09-16 15:00:14 +00:00
Vendor after merging mtrmac/image:docker-certs.d
This commit is contained in:
288
vendor/github.com/containers/storage/store.go
generated
vendored
288
vendor/github.com/containers/storage/store.go
generated
vendored
@@ -3,6 +3,7 @@ package storage
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -14,6 +15,7 @@ import (
|
||||
// register all of the built-in drivers
|
||||
_ "github.com/containers/storage/drivers/register"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
drivers "github.com/containers/storage/drivers"
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
@@ -613,10 +615,6 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
@@ -628,12 +626,6 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
defer ristore.Touch()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
defer rcstore.Touch()
|
||||
@@ -676,11 +668,6 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, o
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
@@ -692,12 +679,6 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, o
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
defer rcstore.Touch()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
rcstore.Load()
|
||||
}
|
||||
if id == "" {
|
||||
id = stringid.GenerateRandomID()
|
||||
}
|
||||
@@ -862,20 +843,10 @@ func (s *store) Metadata(id string) (string, error) {
|
||||
}
|
||||
|
||||
func (s *store) ListImageBigData(id string) ([]string, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
@@ -886,20 +857,10 @@ func (s *store) ListImageBigData(id string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (s *store) ImageBigDataSize(id, key string) (int64, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
@@ -910,20 +871,10 @@ func (s *store) ImageBigDataSize(id, key string) (int64, error) {
|
||||
}
|
||||
|
||||
func (s *store) ImageBigData(id, key string) ([]byte, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
@@ -958,29 +909,11 @@ func (s *store) SetImageBigData(id, key string, data []byte) error {
|
||||
}
|
||||
|
||||
func (s *store) ListContainerBigData(id string) ([]string, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -991,29 +924,10 @@ func (s *store) ListContainerBigData(id string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (s *store) ContainerBigDataSize(id, key string) (int64, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -1024,29 +938,10 @@ func (s *store) ContainerBigDataSize(id, key string) (int64, error) {
|
||||
}
|
||||
|
||||
func (s *store) ContainerBigData(id, key string) ([]byte, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -1057,29 +952,10 @@ func (s *store) ContainerBigData(id, key string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (s *store) SetContainerBigData(id, key string, data []byte) error {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -1765,20 +1641,10 @@ func (s *store) Layers() ([]Layer, error) {
|
||||
}
|
||||
|
||||
func (s *store) Images() ([]Image, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
@@ -1789,29 +1655,11 @@ func (s *store) Images() ([]Image, error) {
|
||||
}
|
||||
|
||||
func (s *store) Containers() ([]Container, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -1841,16 +1689,6 @@ func (s *store) Image(id string) (*Image, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
@@ -1900,29 +1738,10 @@ func (s *store) ImagesByTopLayer(id string) ([]*Image, error) {
|
||||
}
|
||||
|
||||
func (s *store) Container(id string) (*Container, error) {
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -1933,10 +1752,6 @@ func (s *store) Container(id string) (*Container, error) {
|
||||
}
|
||||
|
||||
func (s *store) ContainerByLayer(id string) (*Container, error) {
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1951,11 +1766,6 @@ func (s *store) ContainerByLayer(id string) (*Container, error) {
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -1980,29 +1790,10 @@ func (s *store) ContainerByLayer(id string) (*Container, error) {
|
||||
}
|
||||
|
||||
func (s *store) ContainerDirectory(id string) (string, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -2023,29 +1814,11 @@ func (s *store) ContainerDirectory(id string) (string, error) {
|
||||
}
|
||||
|
||||
func (s *store) ContainerRunDirectory(id string) (string, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
@@ -2187,11 +1960,64 @@ func stringSliceWithoutValue(slice []string, value string) []string {
|
||||
return modified
|
||||
}
|
||||
|
||||
const configFile = "/etc/containers/storage.conf"
|
||||
|
||||
// OptionsConfig represents the "storage.options" TOML config table.
|
||||
type OptionsConfig struct {
|
||||
// AdditionalImagesStores is the location of additional read/only
|
||||
// Image stores. Usually used to access Networked File System
|
||||
// for shared image content
|
||||
AdditionalImageStores []string `toml:"additionalimagestores"`
|
||||
}
|
||||
|
||||
// TOML-friendly explicit tables used for conversions.
|
||||
type tomlConfig struct {
|
||||
Storage struct {
|
||||
Driver string `toml:"driver"`
|
||||
RunRoot string `toml:"runroot"`
|
||||
GraphRoot string `toml:"graphroot"`
|
||||
Options struct{ OptionsConfig } `toml:"options"`
|
||||
} `toml:"storage"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
DefaultStoreOptions.RunRoot = "/var/run/containers/storage"
|
||||
DefaultStoreOptions.GraphRoot = "/var/lib/containers/storage"
|
||||
DefaultStoreOptions.GraphDriverName = os.Getenv("STORAGE_DRIVER")
|
||||
DefaultStoreOptions.GraphDriverOptions = strings.Split(os.Getenv("STORAGE_OPTS"), ",")
|
||||
DefaultStoreOptions.GraphDriverName = "overlay"
|
||||
|
||||
data, err := ioutil.ReadFile(configFile)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
fmt.Printf("Failed to read %s %v\n", configFile, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
config := new(tomlConfig)
|
||||
|
||||
if _, err := toml.Decode(string(data), config); err != nil {
|
||||
fmt.Printf("Failed to parse %s %v\n", configFile, err.Error())
|
||||
return
|
||||
}
|
||||
if config.Storage.Driver != "" {
|
||||
DefaultStoreOptions.GraphDriverName = config.Storage.Driver
|
||||
}
|
||||
if config.Storage.RunRoot != "" {
|
||||
DefaultStoreOptions.RunRoot = config.Storage.RunRoot
|
||||
}
|
||||
if config.Storage.GraphRoot != "" {
|
||||
DefaultStoreOptions.GraphRoot = config.Storage.GraphRoot
|
||||
}
|
||||
for _, s := range config.Storage.Options.AdditionalImageStores {
|
||||
DefaultStoreOptions.GraphDriverOptions = append(DefaultStoreOptions.GraphDriverOptions, fmt.Sprintf("%s.imagestore=%s", config.Storage.Driver, s))
|
||||
}
|
||||
|
||||
if os.Getenv("STORAGE_DRIVER") != "" {
|
||||
DefaultStoreOptions.GraphDriverName = os.Getenv("STORAGE_DRIVER")
|
||||
}
|
||||
if os.Getenv("STORAGE_OPTS") != "" {
|
||||
DefaultStoreOptions.GraphDriverOptions = append(DefaultStoreOptions.GraphDriverOptions, strings.Split(os.Getenv("STORAGE_OPTS"), ",")...)
|
||||
}
|
||||
if len(DefaultStoreOptions.GraphDriverOptions) == 1 && DefaultStoreOptions.GraphDriverOptions[0] == "" {
|
||||
DefaultStoreOptions.GraphDriverOptions = nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user