File: store_supported.go

package info (click to toggle)
podman 5.7.0%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,824 kB
  • sloc: sh: 4,700; python: 2,798; perl: 1,885; ansic: 1,484; makefile: 977; ruby: 42; csh: 8
file content (64 lines) | stat: -rw-r--r-- 1,908 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//go:build (linux || freebsd) && !remote

package main

import (
	"fmt"
	"os"

	"github.com/containers/podman/v5/pkg/domain/entities"
	"go.podman.io/storage"
	"go.podman.io/storage/types"
)

var (
	globalStore storage.Store
	engineMode  = entities.ABIMode
)

func init() {
	if defaultStoreOptions, err := storage.DefaultStoreOptions(); err == nil {
		globalStorageOptions = defaultStoreOptions
	}
	if storageConf, ok := os.LookupEnv("CONTAINERS_STORAGE_CONF"); ok {
		options := globalStorageOptions
		if types.ReloadConfigurationFileIfNeeded(storageConf, &options) == nil {
			globalStorageOptions = options
		}
	}
	fl := mainCmd.PersistentFlags()
	fl.StringVar(&globalStorageOptions.GraphDriverName, "storage-driver", "", "storage driver used to manage images and containers")
	fl.StringVar(&globalStorageOptions.GraphRoot, "root", "", "where images and containers will be stored")
	fl.StringVar(&globalStorageOptions.RunRoot, "runroot", "", "where volatile state information will be stored")
	fl.StringArrayVar(&globalStorageOptions.GraphDriverOptions, "storage-opt", nil, "storage driver options")
	fl.StringVar(&globalStorageOptions.ImageStore, "imagestore", "", "where to store just some parts of images")
	fl.BoolVar(&globalStorageOptions.TransientStore, "transient-store", false, "enable transient container storage")
}

func storeBefore() error {
	defaultStoreOptions, err := storage.DefaultStoreOptions()
	if err != nil {
		fmt.Fprintf(os.Stderr, "selecting storage options: %v", err)
		return nil
	}
	globalStorageOptions = defaultStoreOptions
	store, err := storage.GetStore(globalStorageOptions)
	if err != nil {
		return err
	}
	globalStore = store
	if podmanConfig.URI != "" {
		engineMode = entities.TunnelMode
	} else {
		engineMode = entities.ABIMode
	}
	return nil
}

func storeAfter() error {
	if globalStore != nil {
		_, err := globalStore.Shutdown(false)
		return err
	}
	return nil
}