Skip to content

Commit 4dcfd5b

Browse files
authored
Merge pull request containerd#8355 from Jenkins-J/move-DefaultSnapshotter
Move DefaultSnapshotter constants
2 parents 0a7c192 + 8aa2551 commit 4dcfd5b

File tree

16 files changed

+35
-31
lines changed

16 files changed

+35
-31
lines changed

client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ func (c *Client) ContentStore() content.Store {
626626
func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter {
627627
snapshotterName, err := c.resolveSnapshotterName(context.Background(), snapshotterName)
628628
if err != nil {
629-
snapshotterName = DefaultSnapshotter
629+
snapshotterName = defaults.DefaultSnapshotter
630630
}
631631
if c.snapshotters != nil {
632632
return c.snapshotters[snapshotterName]
@@ -801,7 +801,7 @@ func (c *Client) resolveSnapshotterName(ctx context.Context, name string) (strin
801801
if label != "" {
802802
name = label
803803
} else {
804-
name = DefaultSnapshotter
804+
name = defaults.DefaultSnapshotter
805805
}
806806
}
807807

cmd/ctr/commands/images/mount.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
containerd "github.com/containerd/containerd/v2/client"
2424
"github.com/containerd/containerd/v2/cmd/ctr/commands"
25+
"github.com/containerd/containerd/v2/defaults"
2526
"github.com/containerd/containerd/v2/errdefs"
2627
"github.com/containerd/containerd/v2/leases"
2728
"github.com/containerd/containerd/v2/mount"
@@ -69,7 +70,7 @@ When you are done, use the unmount command.
6970

7071
snapshotter := context.String("snapshotter")
7172
if snapshotter == "" {
72-
snapshotter = containerd.DefaultSnapshotter
73+
snapshotter = defaults.DefaultSnapshotter
7374
}
7475

7576
ctx, done, err := client.WithLease(ctx,

cmd/ctr/commands/images/usage.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
containerd "github.com/containerd/containerd/v2/client"
2525
"github.com/containerd/containerd/v2/cmd/ctr/commands"
26+
"github.com/containerd/containerd/v2/defaults"
2627
"github.com/containerd/containerd/v2/pkg/progress"
2728

2829
"github.com/opencontainers/image-spec/identity"
@@ -48,7 +49,7 @@ var usageCommand = cli.Command{
4849

4950
snapshotter := context.String("snapshotter")
5051
if snapshotter == "" {
51-
snapshotter = containerd.DefaultSnapshotter
52+
snapshotter = defaults.DefaultSnapshotter
5253
}
5354

5455
img, err := client.ImageService().Get(ctx, ref)

client/snapshotter_default_linux.go renamed to defaults/defaults_snapshotter_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package client
17+
package defaults
1818

1919
const (
2020
// DefaultSnapshotter will set the default snapshotter for the platform.

client/snapshotter_default_unix.go renamed to defaults/defaults_snapshotter_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
limitations under the License.
1717
*/
1818

19-
package client
19+
package defaults
2020

2121
const (
2222
// DefaultSnapshotter will set the default snapshotter for the platform.

client/snapshotter_default_windows.go renamed to defaults/defaults_snapshotter_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package client
17+
package defaults
1818

1919
const (
2020
// DefaultSnapshotter will set the default snapshotter for the platform.

integration/client/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"os"
2424
"testing"
2525

26-
containerd "github.com/containerd/containerd/v2/client"
2726
"github.com/containerd/containerd/v2/defaults"
2827
"github.com/containerd/containerd/v2/namespaces"
2928
"github.com/containerd/log/logtest"
@@ -37,7 +36,7 @@ const (
3736
var (
3837
address string
3938
ctrdStdioFilePath string
40-
testSnapshotter = containerd.DefaultSnapshotter
39+
testSnapshotter = defaults.DefaultSnapshotter
4140
ctrd = &daemon{}
4241
)
4342

integration/client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestMain(m *testing.M) {
129129
"snapshotter": os.Getenv("TEST_SNAPSHOTTER"),
130130
}).Info("running tests against containerd")
131131

132-
snapshotter := DefaultSnapshotter
132+
snapshotter := defaults.DefaultSnapshotter
133133
if ss := os.Getenv("TEST_SNAPSHOTTER"); ss != "" {
134134
snapshotter = ss
135135
}

integration/client/image_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"testing"
2525

2626
. "github.com/containerd/containerd/v2/client"
27+
"github.com/containerd/containerd/v2/defaults"
2728
"github.com/containerd/containerd/v2/errdefs"
2829
"github.com/containerd/containerd/v2/images"
2930
imagelist "github.com/containerd/containerd/v2/integration/images"
@@ -57,7 +58,7 @@ func TestImageIsUnpacked(t *testing.T) {
5758
}
5859

5960
// Check that image is not unpacked
60-
unpacked, err := image.IsUnpacked(ctx, DefaultSnapshotter)
61+
unpacked, err := image.IsUnpacked(ctx, defaults.DefaultSnapshotter)
6162
if err != nil {
6263
t.Fatal(err)
6364
}
@@ -66,11 +67,11 @@ func TestImageIsUnpacked(t *testing.T) {
6667
}
6768

6869
// Check that image is unpacked
69-
err = image.Unpack(ctx, DefaultSnapshotter)
70+
err = image.Unpack(ctx, defaults.DefaultSnapshotter)
7071
if err != nil {
7172
t.Fatal(err)
7273
}
73-
unpacked, err = image.IsUnpacked(ctx, DefaultSnapshotter)
74+
unpacked, err = image.IsUnpacked(ctx, defaults.DefaultSnapshotter)
7475
if err != nil {
7576
t.Fatal(err)
7677
}
@@ -218,7 +219,7 @@ func TestImageUsage(t *testing.T) {
218219
t.Fatalf("Expected actual usage to equal manifest reported usage of %d: got %d", s3, s)
219220
}
220221

221-
err = image.Unpack(ctx, DefaultSnapshotter)
222+
err = image.Unpack(ctx, defaults.DefaultSnapshotter)
222223
if err != nil {
223224
t.Fatal(err)
224225
}
@@ -256,12 +257,12 @@ func TestImageSupportedBySnapshotter_Error(t *testing.T) {
256257
_, err = client.Pull(ctx, unsupportedImage,
257258
WithSchema1Conversion,
258259
WithPlatform(platforms.DefaultString()),
259-
WithPullSnapshotter(DefaultSnapshotter),
260+
WithPullSnapshotter(defaults.DefaultSnapshotter),
260261
WithPullUnpack,
261262
WithUnpackOpts([]UnpackOpt{WithSnapshotterPlatformCheck()}),
262263
)
263264

264265
if err == nil {
265-
t.Fatalf("expected unpacking %s for snapshotter %s to fail", unsupportedImage, DefaultSnapshotter)
266+
t.Fatalf("expected unpacking %s for snapshotter %s to fail", unsupportedImage, defaults.DefaultSnapshotter)
266267
}
267268
}

integration/client/snapshot_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"testing"
2222

2323
. "github.com/containerd/containerd/v2/client"
24+
"github.com/containerd/containerd/v2/defaults"
2425
"github.com/containerd/containerd/v2/snapshots"
2526
"github.com/containerd/containerd/v2/snapshots/testsuite"
2627
)
@@ -31,7 +32,7 @@ func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, fu
3132
return nil, nil, err
3233
}
3334

34-
sn := client.SnapshotService(DefaultSnapshotter)
35+
sn := client.SnapshotService(defaults.DefaultSnapshotter)
3536

3637
return sn, func() error {
3738
// no need to close remote snapshotter
@@ -44,5 +45,5 @@ func TestSnapshotterClient(t *testing.T) {
4445
t.Skip()
4546
}
4647

47-
testsuite.SnapshotterSuite(t, DefaultSnapshotter, newSnapshotter)
48+
testsuite.SnapshotterSuite(t, defaults.DefaultSnapshotter, newSnapshotter)
4849
}

0 commit comments

Comments
 (0)