Merge pull request #8355 from Jenkins-J/move-DefaultSnapshotter
Move DefaultSnapshotter constants
This commit is contained in:
commit
4dcfd5bf6e
@ -626,7 +626,7 @@ func (c *Client) ContentStore() content.Store {
|
|||||||
func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter {
|
func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter {
|
||||||
snapshotterName, err := c.resolveSnapshotterName(context.Background(), snapshotterName)
|
snapshotterName, err := c.resolveSnapshotterName(context.Background(), snapshotterName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
snapshotterName = DefaultSnapshotter
|
snapshotterName = defaults.DefaultSnapshotter
|
||||||
}
|
}
|
||||||
if c.snapshotters != nil {
|
if c.snapshotters != nil {
|
||||||
return c.snapshotters[snapshotterName]
|
return c.snapshotters[snapshotterName]
|
||||||
@ -801,7 +801,7 @@ func (c *Client) resolveSnapshotterName(ctx context.Context, name string) (strin
|
|||||||
if label != "" {
|
if label != "" {
|
||||||
name = label
|
name = label
|
||||||
} else {
|
} else {
|
||||||
name = DefaultSnapshotter
|
name = defaults.DefaultSnapshotter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
containerd "github.com/containerd/containerd/v2/client"
|
||||||
"github.com/containerd/containerd/v2/cmd/ctr/commands"
|
"github.com/containerd/containerd/v2/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/errdefs"
|
"github.com/containerd/containerd/v2/errdefs"
|
||||||
"github.com/containerd/containerd/v2/leases"
|
"github.com/containerd/containerd/v2/leases"
|
||||||
"github.com/containerd/containerd/v2/mount"
|
"github.com/containerd/containerd/v2/mount"
|
||||||
@ -69,7 +70,7 @@ When you are done, use the unmount command.
|
|||||||
|
|
||||||
snapshotter := context.String("snapshotter")
|
snapshotter := context.String("snapshotter")
|
||||||
if snapshotter == "" {
|
if snapshotter == "" {
|
||||||
snapshotter = containerd.DefaultSnapshotter
|
snapshotter = defaults.DefaultSnapshotter
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, done, err := client.WithLease(ctx,
|
ctx, done, err := client.WithLease(ctx,
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
containerd "github.com/containerd/containerd/v2/client"
|
||||||
"github.com/containerd/containerd/v2/cmd/ctr/commands"
|
"github.com/containerd/containerd/v2/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/pkg/progress"
|
"github.com/containerd/containerd/v2/pkg/progress"
|
||||||
|
|
||||||
"github.com/opencontainers/image-spec/identity"
|
"github.com/opencontainers/image-spec/identity"
|
||||||
@ -48,7 +49,7 @@ var usageCommand = cli.Command{
|
|||||||
|
|
||||||
snapshotter := context.String("snapshotter")
|
snapshotter := context.String("snapshotter")
|
||||||
if snapshotter == "" {
|
if snapshotter == "" {
|
||||||
snapshotter = containerd.DefaultSnapshotter
|
snapshotter = defaults.DefaultSnapshotter
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := client.ImageService().Get(ctx, ref)
|
img, err := client.ImageService().Get(ctx, ref)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package client
|
package defaults
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultSnapshotter will set the default snapshotter for the platform.
|
// DefaultSnapshotter will set the default snapshotter for the platform.
|
@ -16,7 +16,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package client
|
package defaults
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultSnapshotter will set the default snapshotter for the platform.
|
// DefaultSnapshotter will set the default snapshotter for the platform.
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package client
|
package defaults
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultSnapshotter will set the default snapshotter for the platform.
|
// DefaultSnapshotter will set the default snapshotter for the platform.
|
@ -23,7 +23,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
|
||||||
"github.com/containerd/containerd/v2/defaults"
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/namespaces"
|
"github.com/containerd/containerd/v2/namespaces"
|
||||||
"github.com/containerd/log/logtest"
|
"github.com/containerd/log/logtest"
|
||||||
@ -37,7 +36,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
address string
|
address string
|
||||||
ctrdStdioFilePath string
|
ctrdStdioFilePath string
|
||||||
testSnapshotter = containerd.DefaultSnapshotter
|
testSnapshotter = defaults.DefaultSnapshotter
|
||||||
ctrd = &daemon{}
|
ctrd = &daemon{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ func TestMain(m *testing.M) {
|
|||||||
"snapshotter": os.Getenv("TEST_SNAPSHOTTER"),
|
"snapshotter": os.Getenv("TEST_SNAPSHOTTER"),
|
||||||
}).Info("running tests against containerd")
|
}).Info("running tests against containerd")
|
||||||
|
|
||||||
snapshotter := DefaultSnapshotter
|
snapshotter := defaults.DefaultSnapshotter
|
||||||
if ss := os.Getenv("TEST_SNAPSHOTTER"); ss != "" {
|
if ss := os.Getenv("TEST_SNAPSHOTTER"); ss != "" {
|
||||||
snapshotter = ss
|
snapshotter = ss
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/containerd/containerd/v2/client"
|
. "github.com/containerd/containerd/v2/client"
|
||||||
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/errdefs"
|
"github.com/containerd/containerd/v2/errdefs"
|
||||||
"github.com/containerd/containerd/v2/images"
|
"github.com/containerd/containerd/v2/images"
|
||||||
imagelist "github.com/containerd/containerd/v2/integration/images"
|
imagelist "github.com/containerd/containerd/v2/integration/images"
|
||||||
@ -57,7 +58,7 @@ func TestImageIsUnpacked(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that image is not unpacked
|
// Check that image is not unpacked
|
||||||
unpacked, err := image.IsUnpacked(ctx, DefaultSnapshotter)
|
unpacked, err := image.IsUnpacked(ctx, defaults.DefaultSnapshotter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -66,11 +67,11 @@ func TestImageIsUnpacked(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that image is unpacked
|
// Check that image is unpacked
|
||||||
err = image.Unpack(ctx, DefaultSnapshotter)
|
err = image.Unpack(ctx, defaults.DefaultSnapshotter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
unpacked, err = image.IsUnpacked(ctx, DefaultSnapshotter)
|
unpacked, err = image.IsUnpacked(ctx, defaults.DefaultSnapshotter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -218,7 +219,7 @@ func TestImageUsage(t *testing.T) {
|
|||||||
t.Fatalf("Expected actual usage to equal manifest reported usage of %d: got %d", s3, s)
|
t.Fatalf("Expected actual usage to equal manifest reported usage of %d: got %d", s3, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = image.Unpack(ctx, DefaultSnapshotter)
|
err = image.Unpack(ctx, defaults.DefaultSnapshotter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -256,12 +257,12 @@ func TestImageSupportedBySnapshotter_Error(t *testing.T) {
|
|||||||
_, err = client.Pull(ctx, unsupportedImage,
|
_, err = client.Pull(ctx, unsupportedImage,
|
||||||
WithSchema1Conversion,
|
WithSchema1Conversion,
|
||||||
WithPlatform(platforms.DefaultString()),
|
WithPlatform(platforms.DefaultString()),
|
||||||
WithPullSnapshotter(DefaultSnapshotter),
|
WithPullSnapshotter(defaults.DefaultSnapshotter),
|
||||||
WithPullUnpack,
|
WithPullUnpack,
|
||||||
WithUnpackOpts([]UnpackOpt{WithSnapshotterPlatformCheck()}),
|
WithUnpackOpts([]UnpackOpt{WithSnapshotterPlatformCheck()}),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected unpacking %s for snapshotter %s to fail", unsupportedImage, DefaultSnapshotter)
|
t.Fatalf("expected unpacking %s for snapshotter %s to fail", unsupportedImage, defaults.DefaultSnapshotter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/containerd/containerd/v2/client"
|
. "github.com/containerd/containerd/v2/client"
|
||||||
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/snapshots"
|
"github.com/containerd/containerd/v2/snapshots"
|
||||||
"github.com/containerd/containerd/v2/snapshots/testsuite"
|
"github.com/containerd/containerd/v2/snapshots/testsuite"
|
||||||
)
|
)
|
||||||
@ -31,7 +32,7 @@ func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, fu
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sn := client.SnapshotService(DefaultSnapshotter)
|
sn := client.SnapshotService(defaults.DefaultSnapshotter)
|
||||||
|
|
||||||
return sn, func() error {
|
return sn, func() error {
|
||||||
// no need to close remote snapshotter
|
// no need to close remote snapshotter
|
||||||
@ -44,5 +45,5 @@ func TestSnapshotterClient(t *testing.T) {
|
|||||||
t.Skip()
|
t.Skip()
|
||||||
}
|
}
|
||||||
|
|
||||||
testsuite.SnapshotterSuite(t, DefaultSnapshotter, newSnapshotter)
|
testsuite.SnapshotterSuite(t, defaults.DefaultSnapshotter, newSnapshotter)
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import (
|
|||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
containerd "github.com/containerd/containerd/v2/client"
|
||||||
"github.com/containerd/containerd/v2/content"
|
"github.com/containerd/containerd/v2/content"
|
||||||
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/leases"
|
"github.com/containerd/containerd/v2/leases"
|
||||||
"github.com/containerd/containerd/v2/namespaces"
|
"github.com/containerd/containerd/v2/namespaces"
|
||||||
criconfig "github.com/containerd/containerd/v2/pkg/cri/config"
|
criconfig "github.com/containerd/containerd/v2/pkg/cri/config"
|
||||||
@ -476,7 +477,7 @@ func initLocalCRIImageService(client *containerd.Client, tmpDir string, registry
|
|||||||
containerdRootDir := filepath.Join(tmpDir, "root")
|
containerdRootDir := filepath.Join(tmpDir, "root")
|
||||||
|
|
||||||
cfg := criconfig.ImageConfig{
|
cfg := criconfig.ImageConfig{
|
||||||
Snapshotter: containerd.DefaultSnapshotter,
|
Snapshotter: defaults.DefaultSnapshotter,
|
||||||
Registry: registryCfg,
|
Registry: registryCfg,
|
||||||
ImagePullProgressTimeout: defaultImagePullProgressTimeout.String(),
|
ImagePullProgressTimeout: defaultImagePullProgressTimeout.String(),
|
||||||
StatsCollectPeriod: 10,
|
StatsCollectPeriod: 10,
|
||||||
@ -484,7 +485,7 @@ func initLocalCRIImageService(client *containerd.Client, tmpDir string, registry
|
|||||||
|
|
||||||
return images.NewService(cfg, &images.CRIImageServiceOptions{
|
return images.NewService(cfg, &images.CRIImageServiceOptions{
|
||||||
ImageFSPaths: map[string]string{
|
ImageFSPaths: map[string]string{
|
||||||
containerd.DefaultSnapshotter: containerdRootDir,
|
defaults.DefaultSnapshotter: containerdRootDir,
|
||||||
},
|
},
|
||||||
RuntimePlatforms: map[string]images.ImagePlatform{},
|
RuntimePlatforms: map[string]images.ImagePlatform{},
|
||||||
Content: client.ContentStore(),
|
Content: client.ContentStore(),
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/pelletier/go-toml/v2"
|
"github.com/pelletier/go-toml/v2"
|
||||||
"k8s.io/kubelet/pkg/cri/streaming"
|
"k8s.io/kubelet/pkg/cri/streaming"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DefaultImageConfig() ImageConfig {
|
func DefaultImageConfig() ImageConfig {
|
||||||
return ImageConfig{
|
return ImageConfig{
|
||||||
Snapshotter: containerd.DefaultSnapshotter,
|
Snapshotter: defaults.DefaultSnapshotter,
|
||||||
DisableSnapshotAnnotations: true,
|
DisableSnapshotAnnotations: true,
|
||||||
MaxConcurrentDownloads: 3,
|
MaxConcurrentDownloads: 3,
|
||||||
ImageDecryption: ImageDecryption{
|
ImageDecryption: ImageDecryption{
|
||||||
|
@ -20,13 +20,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"k8s.io/kubelet/pkg/cri/streaming"
|
"k8s.io/kubelet/pkg/cri/streaming"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DefaultImageConfig() ImageConfig {
|
func DefaultImageConfig() ImageConfig {
|
||||||
return ImageConfig{
|
return ImageConfig{
|
||||||
Snapshotter: containerd.DefaultSnapshotter,
|
Snapshotter: defaults.DefaultSnapshotter,
|
||||||
StatsCollectPeriod: 10,
|
StatsCollectPeriod: 10,
|
||||||
MaxConcurrentDownloads: 3,
|
MaxConcurrentDownloads: 3,
|
||||||
ImageDecryption: ImageDecryption{
|
ImageDecryption: ImageDecryption{
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
|
||||||
"github.com/containerd/containerd/v2/content"
|
"github.com/containerd/containerd/v2/content"
|
||||||
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/errdefs"
|
"github.com/containerd/containerd/v2/errdefs"
|
||||||
"github.com/containerd/containerd/v2/images"
|
"github.com/containerd/containerd/v2/images"
|
||||||
"github.com/containerd/containerd/v2/pkg/transfer"
|
"github.com/containerd/containerd/v2/pkg/transfer"
|
||||||
@ -286,7 +286,7 @@ func getSupportedPlatform(uc transfer.UnpackConfiguration, supportedPlatforms []
|
|||||||
// Assume sp.SnapshotterKey is not empty
|
// Assume sp.SnapshotterKey is not empty
|
||||||
if uc.Snapshotter == sp.SnapshotterKey {
|
if uc.Snapshotter == sp.SnapshotterKey {
|
||||||
return true, sp
|
return true, sp
|
||||||
} else if uc.Snapshotter == "" && sp.SnapshotterKey == containerd.DefaultSnapshotter {
|
} else if uc.Snapshotter == "" && sp.SnapshotterKey == defaults.DefaultSnapshotter {
|
||||||
return true, sp
|
return true, sp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package local
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/pkg/transfer"
|
"github.com/containerd/containerd/v2/pkg/transfer"
|
||||||
"github.com/containerd/containerd/v2/pkg/unpack"
|
"github.com/containerd/containerd/v2/pkg/unpack"
|
||||||
"github.com/containerd/containerd/v2/platforms"
|
"github.com/containerd/containerd/v2/platforms"
|
||||||
@ -45,7 +45,7 @@ func TestGetSupportedPlatform(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Platform: platforms.DefaultStrict(),
|
Platform: platforms.DefaultStrict(),
|
||||||
SnapshotterKey: containerd.DefaultSnapshotter,
|
SnapshotterKey: defaults.DefaultSnapshotter,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ func TestGetSupportedPlatform(t *testing.T) {
|
|||||||
Match: true,
|
Match: true,
|
||||||
ExpectedPlatform: transfer.UnpackConfiguration{
|
ExpectedPlatform: transfer.UnpackConfiguration{
|
||||||
Platform: platforms.DefaultSpec(),
|
Platform: platforms.DefaultSpec(),
|
||||||
Snapshotter: containerd.DefaultSnapshotter,
|
Snapshotter: defaults.DefaultSnapshotter,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
@ -19,7 +19,7 @@ package transfer
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
containerd "github.com/containerd/containerd/v2/client"
|
"github.com/containerd/containerd/v2/defaults"
|
||||||
"github.com/containerd/containerd/v2/diff"
|
"github.com/containerd/containerd/v2/diff"
|
||||||
"github.com/containerd/containerd/v2/errdefs"
|
"github.com/containerd/containerd/v2/errdefs"
|
||||||
"github.com/containerd/containerd/v2/leases"
|
"github.com/containerd/containerd/v2/leases"
|
||||||
@ -172,7 +172,7 @@ func defaultConfig() *transferConfig {
|
|||||||
UnpackConfiguration: []unpackConfiguration{
|
UnpackConfiguration: []unpackConfiguration{
|
||||||
{
|
{
|
||||||
Platform: platforms.Format(platforms.DefaultSpec()),
|
Platform: platforms.Format(platforms.DefaultSpec()),
|
||||||
Snapshotter: containerd.DefaultSnapshotter,
|
Snapshotter: defaults.DefaultSnapshotter,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user