Skip to content

Commit

Permalink
util/compression: move type definition together with implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Sep 24, 2024
1 parent 8a26ca7 commit ceda214
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
7 changes: 0 additions & 7 deletions util/compression/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ type Type interface {
String() string
}

type (
uncompressedType struct{}
gzipType struct{}
estargzType struct{}
zstdType struct{}
)

var (
// Uncompressed indicates no compression.
Uncompressed = uncompressedType{}
Expand Down
2 changes: 2 additions & 0 deletions util/compression/estargz.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var EStargzAnnotations = []string{estargz.TOCJSONDigestAnnotation, estargz.Store

const estargzLabel = "buildkit.io/compression/estargz"

type estargzType struct{}

func (c estargzType) Compress(ctx context.Context, comp Config) (compressorFunc Compressor, finalize Finalizer) {
var cInfo *compressionInfo
var writeErr error
Expand Down
2 changes: 2 additions & 0 deletions util/compression/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)

type gzipType struct{}

func (c gzipType) Compress(ctx context.Context, comp Config) (compressorFunc Compressor, finalize Finalizer) {
return func(dest io.Writer, _ string) (io.WriteCloser, error) {
return gzipWriter(comp)(dest)
Expand Down
4 changes: 2 additions & 2 deletions util/compression/nydus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
nydusify "github.com/containerd/nydus-snapshotter/pkg/converter"
)

type nydusType struct{}

var Nydus = nydusType{}

func init() {
Expand All @@ -28,6 +26,8 @@ func init() {
toCompressionType[Nydus.String()] = Nydus
}

type nydusType struct{}

func (c nydusType) Compress(ctx context.Context, comp Config) (compressorFunc Compressor, finalize Finalizer) {
digester := digest.Canonical.Digester()
return func(dest io.Writer, requiredMediaType string) (io.WriteCloser, error) {
Expand Down
2 changes: 2 additions & 0 deletions util/compression/uncompressed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)

type uncompressedType struct{}

func (c uncompressedType) Compress(ctx context.Context, comp Config) (compressorFunc Compressor, finalize Finalizer) {
return func(dest io.Writer, mediaType string) (io.WriteCloser, error) {
return &iohelper.NopWriteCloser{Writer: dest}, nil
Expand Down
2 changes: 2 additions & 0 deletions util/compression/zstd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)

type zstdType struct{}

func (c zstdType) Compress(ctx context.Context, comp Config) (compressorFunc Compressor, finalize Finalizer) {
return func(dest io.Writer, _ string) (io.WriteCloser, error) {
return zstdWriter(comp)(dest)
Expand Down

0 comments on commit ceda214

Please sign in to comment.