Commit Graph

23 Commits

Author SHA1 Message Date
openshift-merge-bot[bot] 427a733a40 Merge pull request #2306 from kolyshkin/modernize
Use `slices` and `maps` more where appropriate
2025-04-01 22:00:08 +00:00
Kir Kolyshkin b15d254157 Use any instead of interface{}
It's available since Go 1.18 (see https://pkg.go.dev/builtin#any).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 15:37:25 -07:00
Kir Kolyshkin 3d62792c40 cmd/containers-storage: simplify
Simplify the code that finds the command.

While at it, rename cmd to name to avoid using cmd and command together.

Best reviewed with --ignore-all-space.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 15:09:03 -07:00
Giuseppe Scrivano c8652a508e store: drop rootless from arguments
drop the rootless argument from DefaultStoreOptions and
UpdateStoreOptions since this can be retrieved internally through the
unshare package.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-16 21:13:28 +01:00
Aditya R fe64c4e56c store: add support to split ImageStore
Allow storage users to split the filesystem of containers vs image
store, `imagestore` if configured will pull images in image storage
instead of the `graphRoot` while keeping the other parts still in the
originally configured `graphRoot`.

overlay: set workdir and upperdir according to splitstore
If splitstore is set `workdir` and `upperdir` must go into the
splitstore i.e `graphRoot`.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-04-14 17:34:27 +05:30
Nalin Dahyabhai f169774db9 Test helper: add "unshare"/"create-storage-layer"/"storage-layers"
Add "unshare", "create-storage-layer", and "storage-layers" commands to
the test helper, along with a "-U" flag to have it unshare when handling
a given command.

Add "-o" as an alias for the "--owner" flag to "copy".

Add "-r" as an alias for the "--ro" flag to "mount".

Add a "-q" flag to "layers" so that we can list just the IDs.

Drop mention of a couple of not-implemented options from
docs/containers-storage-create-layer.md.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-04-10 10:23:23 -04:00
Nalin Dahyabhai 4d61c789f3 test helper: maxArgs = 0 is actually a meaningful value
We do have commands that don't take any arguments, and quietly ignoring
arguments when they get them is not a good idea.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-01-27 09:21:43 -05:00
Alexander Larsson aa63ddb8dc Add test for transient mode
If STORAGE_TRANSIENT is set to 1 then transient mode will be enabled
in the tests.

Also adds overlay-transient to the cirrus CI.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-11-14 16:36:30 +01:00
Miloslav Trmač 67e2c873d4 Add more error handling to cmd/containers-storage
Introduce an outputJSON helper to decrease repetition.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:54 +02:00
Miloslav Trmač 7c002b2a2a Consolidate error reporting in cmd/containers-storage
Have the action handlers return an error value, and let
main() format that error, if any; this avoids duplicated
error formating code in the action handlers, dropping
89 lines.

This might change the error format in some cases (typically
%v vs. %+v).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:53 +02:00
Daniel J Walsh ec59ba74aa Move storageOpts structures into types subdir to shrink bindings.
Currently when we build podman bindings we are pulling in the entire
storage libraries, even though we only need a few structures and
functions.

Testing with the following program

```
package main

import (
	"fmt"
	"github.com/containers/storage/types"
)

func main() {
	fmt.Println(types.GetRootlessRuntimeDir(0))
}
```

Removing types above gives me compile size of the the program

du -s t.old t.new
9640	t.before
3232	t.after

Currently these functions are being vendored into
containers/common/pkg/config, which leads to large size in podman-remote
and podman bindings.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-26 05:34:09 -05:00
yangfeiyu20102011 8a93f6da7e new interface Free for deleting Store object
New interface for deleting already-created Store object

When the store is not needed, it is neccessary to remove
it and release the memory

Signed-off-by: yangfeiyu <yangfeiyu20102011@163.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-29 13:01:33 -04:00
Valentin Rothberg 5312ccefd8 Move opts to internal/opts and fork docker filters
The dependency on docker's filter package prevents us from using newer
versions of docker/moby where the package's API has changed.  The filter
package is small enough to justify maintaining a small fork of it. Also,
since the opts package is only used for the `containers-storage` binary
and is not part of the actual storage library, move it to the ./internal
directory to make it clearer that this is an internal API.

Fixes: containers/storage#450
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-29 13:12:13 +01:00
Giuseppe Scrivano 42fdddef40 storage: move the logic to detect rootless into utils.go
add a helper function that automatically detects the UID when running
in a user namespace..

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-05 15:11:57 +02:00
Daniel J Walsh 69f16a0a2d Move pkg/util default storage functions from libpod to containers/storage
In an effort to remove cross vendoring, trying to fix buildah from importing
from libpod.  I beleive these libraries make more sense in containers/storage
then in libpod.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-19 08:33:42 -04:00
Nalin Dahyabhai 6275d3a46a CLI helper: print backtraces with errors
Print backtrace information when displaying an error returned by our
API, to make troubleshooting tests a bit easier.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:15 -05:00
Daniel J Walsh 418bfa316b Modify storage to allow callers to determine if a mount point is mounted
Add force to umount to force the umount of a container image
Add an interface to indicate whether or not the layer is mounted
Add a boolean return from unmount to indicate when the layer is really unmounted

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-07-17 14:00:15 -04:00
Nalin Dahyabhai d634e3d510 Make the CLI use either all defaults, or none
Make the CLI use all of the default settings if none of them are
overridden on the command line, or none of them, if any are overridden.
Any other behavior is hard to use in integration tests, and confusing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-10-03 09:42:48 -04:00
Nalin Dahyabhai 3bb057c467 Wrap new data retrieval APIs in the CLI tool
Add CLI wrappers for the store's
  ImageBigDataDigest
  ImageBigDataSize
  ContainerBigDataDigest
  ContainerBigDataSize
methods.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-10-02 17:50:01 -04:00
Nalin Dahyabhai df812ed3a8 Clean up CLI display of settings
Change the labels we use when displaying our settings as part of a debug
log, and prepend that information to the "status" output.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-29 15:07:12 -04:00
Mrunal Patel b0996ef191 Update deps to github.com/sirupsen/logrus v1.0.0
Also updates github.com/Microsoft/hcsshim
and github.com/docker/go-connections so they work
with the newer version of logrus.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-08-01 07:25:56 -07:00
Nalin Dahyabhai 28ee01e53d Finish renaming oci-storage to containers-storage
Update the rest of the documentation, scripts, and output.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-07-10 16:11:09 -04:00
Nalin Dahyabhai d96905a24e Rename CLI from oci-storage to containers-storage
Rename the CLI tool to match the name that we gave the transport that
uses it in containers/image, which affects just about every consumer of
this library.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-05-25 15:50:33 -04:00