diff --git a/internal/app/siftool/mount.go b/internal/app/siftool/mount.go deleted file mode 100644 index 5da071b9..00000000 --- a/internal/app/siftool/mount.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -package siftool - -import ( - "context" - - "github.com/sylabs/sif/v2/pkg/user" -) - -// Mount mounts the primary system partition of the SIF file at path into mountPath. -func (a *App) Mount(ctx context.Context, path, mountPath string) error { - return user.Mount(ctx, path, mountPath, - user.OptMountStdout(a.opts.out), - user.OptMountStderr(a.opts.err), - ) -} diff --git a/internal/app/siftool/unmount.go b/internal/app/siftool/unmount.go deleted file mode 100644 index 52d8492e..00000000 --- a/internal/app/siftool/unmount.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -package siftool - -import ( - "context" - - "github.com/sylabs/sif/v2/pkg/user" -) - -// Unmounts the filesystem at mountPath. -func (a *App) Unmount(ctx context.Context, mountPath string) error { - return user.Unmount(ctx, mountPath, - user.OptUnmountStdout(a.opts.out), - user.OptUnmountStderr(a.opts.err), - ) -} diff --git a/pkg/siftool/mount.go b/pkg/siftool/mount.go deleted file mode 100644 index 6b595572..00000000 --- a/pkg/siftool/mount.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -package siftool - -import ( - "github.com/spf13/cobra" -) - -// getMount returns a command that mounts the primary system partition of a SIF image. -func (c *command) getMount() *cobra.Command { - return &cobra.Command{ - Use: "mount ", - Short: "Mount primary system partition", - Long: "Mount the primary system partition of a SIF image", - Example: c.opts.rootPath + " mount image.sif path/", - Args: cobra.ExactArgs(2), - PreRunE: c.initApp, - RunE: func(cmd *cobra.Command, args []string) error { - return c.app.Mount(cmd.Context(), args[0], args[1]) - }, - DisableFlagsInUseLine: true, - Hidden: true, // hide while command is experimental - } -} diff --git a/pkg/siftool/mount_test.go b/pkg/siftool/mount_test.go deleted file mode 100644 index 3b2848ec..00000000 --- a/pkg/siftool/mount_test.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -package siftool - -import ( - "os" - "os/exec" - "path/filepath" - "testing" - - "github.com/sylabs/sif/v2/pkg/sif" -) - -func Test_command_getMount(t *testing.T) { - if _, err := exec.LookPath("squashfuse"); err != nil { - t.Skip("squashfuse not found, skipping mount tests") - } - - tests := []struct { - name string - opts commandOpts - path string - wantErr error - }{ - { - name: "Empty", - path: filepath.Join(corpus, "empty.sif"), - wantErr: sif.ErrNoObjects, - }, - { - name: "OneGroup", - path: filepath.Join(corpus, "one-group.sif"), - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - path, err := os.MkdirTemp("", "siftool-mount-*") - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { - cmd := exec.Command("fusermount", "-u", path) - - if err := cmd.Run(); err != nil { - t.Log(err) - } - - os.RemoveAll(path) - }) - - c := &command{opts: tt.opts} - - cmd := c.getMount() - - runCommand(t, cmd, []string{tt.path, path}, tt.wantErr) - }) - } -} diff --git a/pkg/siftool/siftool.go b/pkg/siftool/siftool.go index 37c2cc7f..4400fdad 100644 --- a/pkg/siftool/siftool.go +++ b/pkg/siftool/siftool.go @@ -76,10 +76,5 @@ func AddCommands(cmd *cobra.Command, opts ...CommandOpt) error { c.getSetPrim(), ) - if c.opts.experimental { - cmd.AddCommand(c.getMount()) - cmd.AddCommand(c.getUnmount()) - } - return nil } diff --git a/pkg/siftool/siftool_test.go b/pkg/siftool/siftool_test.go index f4cb5712..f0e4bcfe 100644 --- a/pkg/siftool/siftool_test.go +++ b/pkg/siftool/siftool_test.go @@ -49,6 +49,7 @@ func makeTestSIF(t *testing.T, withDataObject bool) string { return tf.Name() } +//nolint:unparam func runCommand(t *testing.T, cmd *cobra.Command, args []string, wantErr error) { t.Helper() @@ -117,11 +118,6 @@ func TestAddCommands(t *testing.T) { name: "SetPrim", args: []string{"help", "setprim"}, }, - { - name: "Mount", - opts: []CommandOpt{OptWithExperimental(true)}, - args: []string{"help", "mount"}, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/siftool/testdata/TestAddCommands/Mount/err.golden b/pkg/siftool/testdata/TestAddCommands/Mount/err.golden deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/siftool/testdata/TestAddCommands/Mount/out.golden b/pkg/siftool/testdata/TestAddCommands/Mount/out.golden deleted file mode 100644 index 3df015d5..00000000 --- a/pkg/siftool/testdata/TestAddCommands/Mount/out.golden +++ /dev/null @@ -1,10 +0,0 @@ -Mount the primary system partition of a SIF image - -Usage: - siftool mount - -Examples: -siftool mount image.sif path/ - -Flags: - -h, --help help for mount diff --git a/pkg/siftool/testdata/Test_command_getMount/Empty/err.golden b/pkg/siftool/testdata/Test_command_getMount/Empty/err.golden deleted file mode 100644 index cd860b84..00000000 --- a/pkg/siftool/testdata/Test_command_getMount/Empty/err.golden +++ /dev/null @@ -1 +0,0 @@ -Error: failed to get partition descriptor: no objects in image diff --git a/pkg/siftool/testdata/Test_command_getMount/Empty/out.golden b/pkg/siftool/testdata/Test_command_getMount/Empty/out.golden deleted file mode 100644 index f22522a8..00000000 --- a/pkg/siftool/testdata/Test_command_getMount/Empty/out.golden +++ /dev/null @@ -1,9 +0,0 @@ -Usage: - mount - -Examples: - mount image.sif path/ - -Flags: - -h, --help help for mount - diff --git a/pkg/siftool/testdata/Test_command_getMount/OneGroup/err.golden b/pkg/siftool/testdata/Test_command_getMount/OneGroup/err.golden deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/siftool/testdata/Test_command_getMount/OneGroup/out.golden b/pkg/siftool/testdata/Test_command_getMount/OneGroup/out.golden deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/siftool/testdata/Test_command_getUnmount/err.golden b/pkg/siftool/testdata/Test_command_getUnmount/err.golden deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/siftool/testdata/Test_command_getUnmount/out.golden b/pkg/siftool/testdata/Test_command_getUnmount/out.golden deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/siftool/unmount.go b/pkg/siftool/unmount.go deleted file mode 100644 index 88141827..00000000 --- a/pkg/siftool/unmount.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -package siftool - -import ( - "github.com/spf13/cobra" -) - -// getUnmount returns a command that unmounts the primary system partition of a SIF image. -func (c *command) getUnmount() *cobra.Command { - return &cobra.Command{ - Use: "unmount ", - Short: "Unmount primary system partition", - Long: "Unmount a primary system partition of a SIF image", - Example: c.opts.rootPath + " unmount path/", - Args: cobra.ExactArgs(1), - PreRunE: c.initApp, - RunE: func(cmd *cobra.Command, args []string) error { - return c.app.Unmount(cmd.Context(), args[0]) - }, - DisableFlagsInUseLine: true, - Hidden: true, // hide while command is experimental - } -} diff --git a/pkg/siftool/unmount_test.go b/pkg/siftool/unmount_test.go deleted file mode 100644 index 2cf81605..00000000 --- a/pkg/siftool/unmount_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. -// This software is licensed under a 3-clause BSD license. Please consult the -// LICENSE file distributed with the sources of this project regarding your -// rights to use or distribute this software. - -package siftool - -import ( - "context" - "os" - "os/exec" - "path/filepath" - "testing" - - "github.com/sylabs/sif/v2/pkg/user" -) - -func Test_command_getUnmount(t *testing.T) { - if _, err := exec.LookPath("squashfuse"); err != nil { - t.Skip(" not found, skipping unmount tests") - } - if _, err := exec.LookPath("fusermount"); err != nil { - t.Skip(" not found, skipping unmount tests") - } - - path, err := os.MkdirTemp("", "siftool-unmount-*") - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { - os.RemoveAll(path) - }) - - testSIF := filepath.Join(corpus, "one-group.sif") - if err := user.Mount(context.Background(), testSIF, path); err != nil { - t.Fatal(err) - } - - c := &command{} - cmd := c.getUnmount() - runCommand(t, cmd, []string{path}, nil) -} diff --git a/pkg/user/mount.go b/pkg/user/mount.go index c96e4145..15240d26 100644 --- a/pkg/user/mount.go +++ b/pkg/user/mount.go @@ -1,8 +1,9 @@ -// Copyright (c) 2022, Sylabs Inc. All rights reserved. +// Copyright (c) 2022-2023, Sylabs Inc. All rights reserved. // This software is licensed under a 3-clause BSD license. Please consult the // LICENSE file distributed with the sources of this project regarding your // rights to use or distribute this software. +// Deprecated: this package will be removed in a future version. package user import (