Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/nerdctl/container_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func containerPruneAction(cmd *cobra.Command, _ []string) error {
}
defer cancel()

return containerPrune(ctx, cmd, globalOptions, client)
return containerPrune(ctx, cmd, client, globalOptions)
}

func containerPrune(ctx context.Context, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, client *containerd.Client) error {
func containerPrune(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions types.GlobalCommandOptions) error {
containers, err := client.Containers(ctx)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func createAction(cmd *cobra.Command, args []string) error {
return err
}

container, gc, err := createContainer(ctx, cmd, globalOptions, client, args, platform, false, flagT, true)
container, gc, err := createContainer(ctx, cmd, client, globalOptions, args, platform, false, flagT, true)
if err != nil {
if gc != nil {
gc()
Expand Down
28 changes: 14 additions & 14 deletions cmd/nerdctl/flagutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,56 @@ import (
"github.com/spf13/cobra"
)

func processRootCmdFlags(cmd *cobra.Command) (*types.GlobalCommandOptions, error) {
func processRootCmdFlags(cmd *cobra.Command) (types.GlobalCommandOptions, error) {
debug, err := cmd.Flags().GetBool("debug")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
debugFull, err := cmd.Flags().GetBool("debug-full")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
address, err := cmd.Flags().GetString("address")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
namespace, err := cmd.Flags().GetString("namespace")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
snapshotter, err := cmd.Flags().GetString("snapshotter")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
cniPath, err := cmd.Flags().GetString("cni-path")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
cniConfigPath, err := cmd.Flags().GetString("cni-netconfpath")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
dataRoot, err := cmd.Flags().GetString("data-root")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
cgroupManager, err := cmd.Flags().GetString("cgroup-manager")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
insecureRegistry, err := cmd.Flags().GetBool("insecure-registry")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
hostsDir, err := cmd.Flags().GetStringSlice("hosts-dir")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
experimental, err := cmd.Flags().GetBool("experimental")
if err != nil {
return nil, err
return types.GlobalCommandOptions{}, err
}
return &types.GlobalCommandOptions{
return types.GlobalCommandOptions{
Debug: debug,
DebugFull: debugFull,
Address: address,
Expand Down
8 changes: 4 additions & 4 deletions cmd/nerdctl/image_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func imageConvertAction(cmd *cobra.Command, args []string) error {
return printConvertedImage(cmd, res)
}

func getESGZConverter(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) (convertFunc converter.ConvertFunc, finalize func(ctx context.Context, cs content.Store, ref string, desc *ocispec.Descriptor) (*images.Image, error), _ error) {
func getESGZConverter(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) (convertFunc converter.ConvertFunc, finalize func(ctx context.Context, cs content.Store, ref string, desc *ocispec.Descriptor) (*images.Image, error), _ error) {
externalTOC, err := cmd.Flags().GetBool("estargz-external-toc")
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -362,7 +362,7 @@ func getESGZConverter(cmd *cobra.Command, globalOptions *types.GlobalCommandOpti
return convertFunc, finalize, nil
}

func getESGZConvertOpts(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) ([]estargz.Option, error) {
func getESGZConvertOpts(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) ([]estargz.Option, error) {
estargzCompressionLevel, err := cmd.Flags().GetInt("estargz-compression-level")
if err != nil {
return nil, err
Expand Down Expand Up @@ -403,7 +403,7 @@ func getESGZConvertOpts(cmd *cobra.Command, globalOptions *types.GlobalCommandOp
return esgzOpts, nil
}

func getZstdchunkedConverter(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) (converter.ConvertFunc, error) {
func getZstdchunkedConverter(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) (converter.ConvertFunc, error) {
zstdchunkedCompressionLevel, err := cmd.Flags().GetInt("zstdchunked-compression-level")
if err != nil {
return nil, err
Expand Down Expand Up @@ -438,7 +438,7 @@ func getZstdchunkedConverter(cmd *cobra.Command, globalOptions *types.GlobalComm
return zstdchunkedconvert.LayerConvertFuncWithCompressionLevel(zstd.EncoderLevelFromZstd(zstdchunkedCompressionLevel), esgzOpts...), nil
}

func getNydusConvertOpts(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) (*nydusconvert.PackOption, error) {
func getNydusConvertOpts(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) (*nydusconvert.PackOption, error) {
builderPath, err := cmd.Flags().GetString("nydus-builder-path")
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/image_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func imageInspectAction(cmd *cobra.Command, args []string) error {
return imageInspectActionWithPlatform(cmd, args, platform, globalOptions)
}

func imageInspectActionWithPlatform(cmd *cobra.Command, args []string, platform string, globalOptions *types.GlobalCommandOptions) error {
func imageInspectActionWithPlatform(cmd *cobra.Command, args []string, platform string, globalOptions types.GlobalCommandOptions) error {

var clientOpts []containerd.ClientOpt
if platform != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func processImagesFlag(cmd *cobra.Command, args []string) (types.ImageListComman
return types.ImageListCommandOptions{}, err
}
return types.ImageListCommandOptions{
GOptions: *globalOptions,
GOptions: globalOptions,
Quiet: quiet,
NoTrunc: noTrunc,
Format: format,
Expand Down
4 changes: 2 additions & 2 deletions cmd/nerdctl/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func infoAction(cmd *cobra.Command, args []string) error {
return nil
}

func fulfillNativeInfo(cmd *cobra.Command, di *native.DaemonInfo, globalOptions *types.GlobalCommandOptions) (*native.Info, error) {
func fulfillNativeInfo(cmd *cobra.Command, di *native.DaemonInfo, globalOptions types.GlobalCommandOptions) (*native.Info, error) {
info := &native.Info{
Daemon: di,
}
Expand Down Expand Up @@ -178,7 +178,7 @@ func prettyPrintInfoNative(w io.Writer, info *native.Info) error {
return nil
}

func prettyPrintInfoDockerCompat(cmd *cobra.Command, info *dockercompat.Info, globalOptions *types.GlobalCommandOptions) error {
func prettyPrintInfoDockerCompat(cmd *cobra.Command, info *dockercompat.Info, globalOptions types.GlobalCommandOptions) error {
w := cmd.OutOrStdout()
debug := globalOptions.Debug
fmt.Fprintf(w, "Client:\n")
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func processLoadCommandFlags(cmd *cobra.Command) (types.LoadCommandOptions, erro
return types.LoadCommandOptions{}, err
}
return types.LoadCommandOptions{
GOptions: *globalOptions,
GOptions: globalOptions,
Input: input,
Platform: platform,
AllPlatforms: allPlatforms,
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func GetDefaultAuthConfig(checkCredStore bool, serverAddress string, isDefaultRe
return &res, nil
}

func loginClientSide(ctx context.Context, cmd *cobra.Command, globalOptions *ncTypes.GlobalCommandOptions, auth types.AuthConfig) (string, error) {
func loginClientSide(ctx context.Context, cmd *cobra.Command, globalOptions ncTypes.GlobalCommandOptions, auth types.AuthConfig) (string, error) {
host, err := convertToHostname(auth.ServerAddress)
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/network_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func networkPruneAction(cmd *cobra.Command, _ []string) error {
return networkPrune(ctx, cmd, client, globalOptions)
}

func networkPrune(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions *types.GlobalCommandOptions) error {
func networkPrune(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions types.GlobalCommandOptions) error {
e, err := netutil.NewCNIEnv(globalOptions.CNIPath, globalOptions.CNINetConfPath)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/nerdctl/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ func pullAction(cmd *cobra.Command, args []string) error {
return err
}

_, err = ensureImage(ctx, cmd, globalOptions, client, rawRef, ocispecPlatforms, "always", unpack, quiet)
_, err = ensureImage(ctx, cmd, client, globalOptions, rawRef, ocispecPlatforms, "always", unpack, quiet)
if err != nil {
return err
}

return nil
}

func ensureImage(ctx context.Context, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, client *containerd.Client, rawRef string, ocispecPlatforms []v1.Platform, pull string, unpack *bool, quiet bool) (*imgutil.EnsuredImage, error) {
func ensureImage(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions types.GlobalCommandOptions, rawRef string, ocispecPlatforms []v1.Platform, pull string, unpack *bool, quiet bool) (*imgutil.EnsuredImage, error) {

var ensured *imgutil.EnsuredImage

Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func rmAction(cmd *cobra.Command, args []string) error {
return nil
}

func removeContainer(ctx context.Context, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, container containerd.Container, force bool, removeAnonVolumes bool) (retErr error) {
func removeContainer(ctx context.Context, cmd *cobra.Command, globalOptions types.GlobalCommandOptions, container containerd.Container, force bool, removeAnonVolumes bool) (retErr error) {
ns, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return err
Expand Down
14 changes: 7 additions & 7 deletions cmd/nerdctl/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func runAction(cmd *cobra.Command, args []string) error {
return errors.New("flags -d and --rm cannot be specified together")
}

container, gc, err := createContainer(ctx, cmd, globalOptions, client, args, platform, flagI, flagT, flagD)
container, gc, err := createContainer(ctx, cmd, client, globalOptions, args, platform, flagI, flagT, flagD)
if err != nil {
if gc != nil {
defer gc()
Expand Down Expand Up @@ -397,7 +397,7 @@ func runAction(cmd *cobra.Command, args []string) error {
}

// FIXME: split to smaller functions
func createContainer(ctx context.Context, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, client *containerd.Client, args []string, platform string, flagI, flagT, flagD bool) (containerd.Container, func(), error) {
func createContainer(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions types.GlobalCommandOptions, args []string, platform string, flagI, flagT, flagD bool) (containerd.Container, func(), error) {
// simulate the behavior of double dash
newArg := []string{}
if len(args) >= 2 && args[1] == "--" {
Expand Down Expand Up @@ -443,7 +443,7 @@ func createContainer(ctx context.Context, cmd *cobra.Command, globalOptions *typ
oci.WithDefaultSpec(),
)

platformOpts, err := setPlatformOptions(ctx, cmd, globalOptions, client, id, &internalLabels)
platformOpts, err := setPlatformOptions(ctx, cmd, client, globalOptions, id, &internalLabels)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -488,7 +488,7 @@ func createContainer(ctx context.Context, cmd *cobra.Command, globalOptions *typ
opts = append(opts, oci.WithTTY)
}

mountOpts, anonVolumes, mountPoints, err := generateMountOpts(ctx, cmd, globalOptions, client, ensuredImage)
mountOpts, anonVolumes, mountPoints, err := generateMountOpts(ctx, cmd, client, globalOptions, ensuredImage)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -728,7 +728,7 @@ func createContainer(ctx context.Context, cmd *cobra.Command, globalOptions *typ
return container, nil, nil
}

func generateRootfsOpts(ctx context.Context, client *containerd.Client, platform string, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, args []string, id string) ([]oci.SpecOpts, []containerd.NewContainerOpts, *imgutil.EnsuredImage, error) {
func generateRootfsOpts(ctx context.Context, client *containerd.Client, platform string, cmd *cobra.Command, globalOptions types.GlobalCommandOptions, args []string, id string) ([]oci.SpecOpts, []containerd.NewContainerOpts, *imgutil.EnsuredImage, error) {
var (
ensured *imgutil.EnsuredImage
err error
Expand All @@ -751,7 +751,7 @@ func generateRootfsOpts(ctx context.Context, client *containerd.Client, platform
return nil, nil, nil, err
}
rawRef := args[0]
ensured, err = ensureImage(ctx, cmd, globalOptions, client, rawRef, ocispecPlatforms, pull, nil, false)
ensured, err = ensureImage(ctx, cmd, client, globalOptions, rawRef, ocispecPlatforms, pull, nil, false)
if err != nil {
return nil, nil, nil, err
}
Expand Down Expand Up @@ -948,7 +948,7 @@ func withNerdctlOCIHook(cmd *cobra.Command, id string) (oci.SpecOpts, error) {
}, nil
}

func getContainerStateDirPath(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, dataStore, id string) (string, error) {
func getContainerStateDirPath(cmd *cobra.Command, globalOptions types.GlobalCommandOptions, dataStore, id string) (string, error) {

if globalOptions.Namespace == "" {
return "", errors.New("namespace is required")
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/run_cgroup_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type customMemoryOptions struct {
disableOOMKiller *bool
}

func generateCgroupOpts(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, id string) ([]oci.SpecOpts, error) {
func generateCgroupOpts(cmd *cobra.Command, globalOptions types.GlobalCommandOptions, id string) ([]oci.SpecOpts, error) {
cpus, err := cmd.Flags().GetFloat64("cpus")
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/run_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func runShellComplete(cmd *cobra.Command, args []string, toComplete string) ([]s
func setPlatformOptions(
ctx context.Context,
cmd *cobra.Command,
_ *types.GlobalCommandOptions,
client *containerd.Client,
_ types.GlobalCommandOptions,
id string,
internalLabels *internalLabels,
) ([]oci.SpecOpts, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func runShellComplete(cmd *cobra.Command, args []string, toComplete string) ([]s
return nil, cobra.ShellCompDirectiveNoFileComp
}

func setPlatformOptions(ctx context.Context, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, client *containerd.Client, id string, internalLabels *internalLabels) ([]oci.SpecOpts, error) {
func setPlatformOptions(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions types.GlobalCommandOptions, id string, internalLabels *internalLabels) ([]oci.SpecOpts, error) {
var opts []oci.SpecOpts
opts = append(opts,
oci.WithDefaultUnixDevices,
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/run_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func parseMountFlags(cmd *cobra.Command, volStore volumestore.VolumeStore) ([]*m

// generateMountOpts generates volume-related mount opts.
// Other mounts such as procfs mount are not handled here.
func generateMountOpts(ctx context.Context, cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, client *containerd.Client, ensuredImage *imgutil.EnsuredImage) ([]oci.SpecOpts, []string, []*mountutil.Processed, error) {
func generateMountOpts(ctx context.Context, cmd *cobra.Command, client *containerd.Client, globalOptions types.GlobalCommandOptions, ensuredImage *imgutil.EnsuredImage) ([]oci.SpecOpts, []string, []*mountutil.Processed, error) {
volStore, err := getVolumeStore(globalOptions)
if err != nil {
return nil, nil, nil, err
Expand Down
4 changes: 2 additions & 2 deletions cmd/nerdctl/run_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func withCustomHosts(src string) func(context.Context, oci.Client, *containers.C
}
}

func generateNetOpts(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, dataStore, stateDir, ns, id string) ([]oci.SpecOpts, []string, string, []gocni.PortMapping, string, error) {
func generateNetOpts(cmd *cobra.Command, globalOptions types.GlobalCommandOptions, dataStore, stateDir, ns, id string) ([]oci.SpecOpts, []string, string, []gocni.PortMapping, string, error) {
opts := []oci.SpecOpts{}
portSlice, err := cmd.Flags().GetStringSlice("publish")
if err != nil {
Expand Down Expand Up @@ -266,7 +266,7 @@ func getContainerNetNSPath(ctx context.Context, c containerd.Container) (string,
return fmt.Sprintf("/proc/%d/ns/net", task.Pid()), nil
}

func verifyCNINetwork(cmd *cobra.Command, netSlice []string, macAddress string, globalOptions *types.GlobalCommandOptions) error {
func verifyCNINetwork(cmd *cobra.Command, netSlice []string, macAddress string, globalOptions types.GlobalCommandOptions) error {
e, err := netutil.NewCNIEnv(globalOptions.CNIPath, globalOptions.CNINetConfPath, netutil.WithDefaultNetwork())
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/run_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/spf13/cobra"
)

func generateRuntimeCOpts(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) ([]containerd.NewContainerOpts, error) {
func generateRuntimeCOpts(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) ([]containerd.NewContainerOpts, error) {
runtime := plugin.RuntimeRuncV2
var (
runcOpts runcoptions.Options
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/run_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func runShellComplete(cmd *cobra.Command, args []string, toComplete string) ([]s
func setPlatformOptions(
ctx context.Context,
cmd *cobra.Command,
_ *types.GlobalCommandOptions,
client *containerd.Client,
_ types.GlobalCommandOptions,
id string,
internalLabels *internalLabels,
) ([]oci.SpecOpts, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func statsAction(cmd *cobra.Command, args []string) error {
return err
}

func collect(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions, s *statsutil.Stats, waitFirst *sync.WaitGroup, id string, noStream bool) {
func collect(cmd *cobra.Command, globalOptions types.GlobalCommandOptions, s *statsutil.Stats, waitFirst *sync.WaitGroup, id string, noStream bool) {
logrus.Debugf("collecting stats for %s", s.Container)
var (
getFirst = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/system_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func systemPruneAction(cmd *cobra.Command, args []string) error {
}
defer cancel()

if err := containerPrune(ctx, cmd, globalOptions, client); err != nil {
if err := containerPrune(ctx, cmd, client, globalOptions); err != nil {
return err
}
if err := networkPrune(ctx, cmd, client, globalOptions); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func updateAction(cmd *cobra.Command, args []string) error {
return nil
}

func getUpdateOption(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) (updateResourceOptions, error) {
func getUpdateOption(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) (updateResourceOptions, error) {
var options updateResourceOptions
cpus, err := cmd.Flags().GetFloat64("cpus")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func versionAction(cmd *cobra.Command, args []string) error {
}

// versionInfo may return partial VersionInfo on error
func versionInfo(cmd *cobra.Command, globalOptions *types.GlobalCommandOptions) (dockercompat.VersionInfo, error) {
func versionInfo(cmd *cobra.Command, globalOptions types.GlobalCommandOptions) (dockercompat.VersionInfo, error) {

v := dockercompat.VersionInfo{
Client: infoutil.ClientVersion(),
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ func newVolumeCommand() *cobra.Command {

// getVolumeStore returns a volume store
// that corresponds to a directory like `/var/lib/nerdctl/1935db59/volumes/default`
func getVolumeStore(globalOptions *types.GlobalCommandOptions) (volumestore.VolumeStore, error) {
func getVolumeStore(globalOptions types.GlobalCommandOptions) (volumestore.VolumeStore, error) {
return volume.Store(globalOptions.Namespace, globalOptions.DataRoot, globalOptions.Address)
}
Comment on lines +47 to 49
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we remove this function and use volume.Store (the 2nd one below) directly (we can change volume.Store to accept a globalOptions) (Don't necessarily be part of this PR though)

This adds one unnecessary wrap on volume create:

func getVolumeStore(globalOptions *types.GlobalCommandOptions) (volumestore.VolumeStore, error) {
return volume.Store(globalOptions.Namespace, globalOptions.DataRoot, globalOptions.Address)
}

func Store(ns string, dataRoot string, address string) (volumestore.VolumeStore, error) {
dataStore, err := clientutil.DataStore(dataRoot, address)
if err != nil {
return nil, err
}
return volumestore.New(dataStore, ns)
}

func New(dataStore, ns string) (VolumeStore, error) {

Copy link
Copy Markdown
Member Author

@Zheaoli Zheaoli Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be another PR, I will update ASAP

Loading