Skip to content

Commit b7de827

Browse files
Merge pull request #6341 from nalind/add-imagestore-flag
Support "--imagestore" global flags
2 parents 33739ef + fc748f8 commit b7de827

File tree

8 files changed

+28
-5
lines changed

8 files changed

+28
-5
lines changed

cmd/buildah/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func getStore(c *cobra.Command) (storage.Store, error) {
3232
options.GraphRoot = globalFlagResults.Root
3333
options.RunRoot = globalFlagResults.RunRoot
3434
}
35+
if c.Flag("imagestore").Changed {
36+
options.ImageStore = globalFlagResults.ImageStore
37+
}
3538
if c.Flag("storage-driver").Changed {
3639
options.GraphDriverName = globalFlagResults.StorageDriver
3740
// If any options setup in config, these should be dropped if user overrode the driver

cmd/buildah/common_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestMain(m *testing.M) {
2929
flag.StringVar(&options.GraphRoot, "root", "", "storage root dir")
3030
flag.StringVar(&options.RunRoot, "runroot", "", "storage state dir")
3131
flag.StringVar(&options.GraphDriverName, "storage-driver", "", "storage driver")
32+
flag.StringVar(&options.ImageStore, "imagestore", "", "storage imagestore")
3233
flag.StringVar(&testSystemContext.SystemRegistriesConfPath, "registries-conf", "", "registries list")
3334
flag.BoolVar(&debug, "debug", false, "turn on debug logging")
3435
flag.Parse()
@@ -58,6 +59,7 @@ func TestGetStore(t *testing.T) {
5859
flags := testCmd.PersistentFlags()
5960
flags.String("root", storeOptions.GraphRoot, "")
6061
flags.String("runroot", storeOptions.RunRoot, "")
62+
flags.String("imagestore", storeOptions.ImageStore, "")
6163
flags.String("storage-driver", storeOptions.GraphDriverName, "")
6264
flags.String("signature-policy", "", "")
6365
if err := flags.MarkHidden("signature-policy"); err != nil {

cmd/buildah/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type globalFlags struct {
2828
LogLevel string
2929
Root string
3030
RunRoot string
31+
ImageStore string
3132
StorageDriver string
3233
RegistriesConf string
3334
RegistriesConfDir string
@@ -98,6 +99,7 @@ func init() {
9899
rootCmd.PersistentFlags().StringVar(&globalFlagResults.RunRoot, "runroot", storageOptions.RunRoot, "storage state dir")
99100
rootCmd.PersistentFlags().StringVar(&globalFlagResults.CgroupManager, "cgroup-manager", defaultContainerConfig.Engine.CgroupManager, "cgroup manager")
100101
rootCmd.PersistentFlags().StringVar(&globalFlagResults.StorageDriver, "storage-driver", storageOptions.GraphDriverName, "storage-driver")
102+
rootCmd.PersistentFlags().StringVar(&globalFlagResults.ImageStore, "imagestore", storageOptions.ImageStore, "storage imagestore")
101103
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.StorageOpts, "storage-opt", defaultStoreDriverOptions, "storage driver option")
102104
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.UserNSUID, "userns-uid-map", []string{}, "default `ctrID:hostID:length` UID mapping to use")
103105
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.UserNSGID, "userns-gid-map", []string{}, "default `ctrID:hostID:length` GID mapping to use")

docs/buildah.1.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ The CGroup manager to use for container cgroups. Supported values are cgroupfs o
2727
Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
2828
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.
2929

30+
**--imagestore** *path*
31+
32+
Path under which content for pulled and built images will be stored. By default, the configured **--root** location
33+
is used for pulled and built images as well as containers. If the storage driver is
34+
*overlay*, then any images which have previously been written to the **--root** location will still
35+
be available.
36+
37+
This will override the *imagestore* option in containers-storage.conf(5).
38+
3039
**--log-level** **value**
3140

3241
The log level to be used. Either "trace", "debug", "info", "warn", "error", "fatal", or "panic", defaulting to "warn".
@@ -53,13 +62,13 @@ be used, as the default behavior of using the system-wide configuration
5362

5463
**--root** **value**
5564

56-
Storage root dir (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users)
57-
Default root dir is configured in /etc/containers/storage.conf
65+
Storage root dir (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users).
66+
The default root dir is configured in /etc/containers/storage.conf.
5867

5968
**--runroot** **value**
6069

61-
Storage state dir (default: "/run/containers/storage" for UID 0, "/run/user/$UID" for other users)
62-
Default state dir is configured in /etc/containers/storage.conf
70+
Storage state dir (default: "/run/containers/storage" for UID 0, "/run/user/$UID" for other users).
71+
The default state dir is configured in /etc/containers/storage.conf.
6372

6473
**--short-name-alias-conf** *path*
6574

info.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func storeInfo(store storage.Store) (map[string]any, error) {
133133
info := map[string]any{}
134134
info["GraphRoot"] = store.GraphRoot()
135135
info["RunRoot"] = store.RunRoot()
136+
info["GraphImageStore"] = store.ImageStore()
136137
info["GraphDriverName"] = store.GraphDriverName()
137138
info["GraphOptions"] = store.GraphOptions()
138139
statusPairs, err := store.Status()
@@ -144,6 +145,7 @@ func storeInfo(store storage.Store) (map[string]any, error) {
144145
status[pair[0]] = pair[1]
145146
}
146147
info["GraphStatus"] = status
148+
147149
images, err := store.Images()
148150
if err != nil {
149151
logrus.Error(err, "error getting number of images")

tests/copy/copy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func main() {
141141

142142
rootCmd.PersistentFlags().StringVar(&storeOptions.GraphRoot, "root", "", "storage root")
143143
rootCmd.PersistentFlags().StringVar(&storeOptions.RunRoot, "runroot", "", "runtime root")
144+
rootCmd.PersistentFlags().StringVar(&storeOptions.ImageStore, "imagestore", "", "storage imagestore")
144145
rootCmd.PersistentFlags().StringVar(&storeOptions.GraphDriverName, "storage-driver", "", "storage driver")
145146
rootCmd.PersistentFlags().StringSliceVar(&storeOptions.GraphDriverOptions, "storage-opt", nil, "storage option")
146147
rootCmd.PersistentFlags().StringVar(&systemContext.SystemRegistriesConfPath, "registries-conf", "", "location of registries.conf")

tests/helpers.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ function run_buildah() {
391391
retry=$(( retry - 1 ))
392392

393393
# stdout is only emitted upon error; this echo is to help a debugger
394-
echo "${_LOG_PROMPT} $BUILDAH_BINARY $*"
394+
echo "${_LOG_PROMPT} ${BUILDAH_BINARY} $*"
395395
run env CONTAINERS_CONF=${CONTAINERS_CONF:-$(dirname ${BASH_SOURCE})/containers.conf} timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${BUILDAH_BINARY} ${BUILDAH_REGISTRY_OPTS} ${ROOTDIR_OPTS} "$@"
396396
# without "quotes", multiple lines are glommed together into one
397397
if [ -n "$output" ]; then

tests/imgtype/imgtype.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func main() {
4040
root := flag.String("root", storeOptions.GraphRoot, "storage root directory")
4141
runroot := flag.String("runroot", storeOptions.RunRoot, "storage runtime directory")
4242
driver := flag.String("storage-driver", storeOptions.GraphDriverName, "storage driver")
43+
imagestore := flag.String("imagestore", storeOptions.ImageStore, "storage imagestore")
4344
opts := flag.String("storage-opts", "", "storage option list (comma separated)")
4445
policy := flag.String("signature-policy", "", "signature policy file")
4546
mtype := flag.String("expected-manifest-type", define.OCIv1ImageManifest, "expected manifest type")
@@ -77,6 +78,9 @@ func main() {
7778
storeOptions.GraphDriverName = *driver
7879
storeOptions.GraphDriverOptions = nil
7980
}
81+
if imagestore != nil {
82+
storeOptions.ImageStore = *imagestore
83+
}
8084
if opts != nil && *opts != "" {
8185
storeOptions.GraphDriverOptions = strings.Split(*opts, ",")
8286
}

0 commit comments

Comments
 (0)