Skip to content

Commit

Permalink
converter: make backend package independent
Browse files Browse the repository at this point in the history
Move `pkg/converter/backend` to `pkg/backend`.

The advantage of this change is that if a component imports the
converter package, but it doesn't need backend support, the non-direct
dependencies in `pkg/backend` don't have to be imported either.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
  • Loading branch information
imeoer committed Aug 18, 2022
1 parent 62fbe34 commit 8dc8632
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 16 additions & 2 deletions pkg/converter/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
package converter

import (
"context"

"github.com/containerd/containerd/content"
"github.com/containerd/nydus-snapshotter/pkg/converter/backend"
"github.com/opencontainers/go-digest"
)

Expand All @@ -19,6 +20,19 @@ type Layer struct {
ReaderAt content.ReaderAt
}

// Backend uploads blobs generated by nydus-image builder to a backend storage such as:
// - oss: A object storage backend, which uses its SDK to upload blob file.
type Backend interface {
// Push pushes specified blob file to remote storage backend.
Push(ctx context.Context, ra content.ReaderAt, blobDigest digest.Digest) error
// Check checks whether a blob exists in remote storage backend,
// blob exists -> return (blobPath, nil)
// blob not exists -> return ("", err)
Check(blobDigest digest.Digest) (string, error)
// Type returns backend type name.
Type() string
}

type PackOption struct {
// WorkDir is used as the work directory during layer pack.
WorkDir string
Expand All @@ -34,7 +48,7 @@ type PackOption struct {
// Compressor specifies nydus blob compression algorithm.
Compressor string
// Backend uploads blobs generated by nydus-image builder to a backend storage.
Backend backend.Backend
Backend Backend
}

type MergeOption struct {
Expand Down

0 comments on commit 8dc8632

Please sign in to comment.