mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-19 18:07:45 +08:00

Tested with `kind` and GKE. Note: "nodes" shown in `docker buildx ls` are unrelated to Kubernetes "nodes". Probably buildx should come up with an alternative term. Usage: $ kind create cluster $ export KUBECONFIG="$(kind get kubeconfig-path --name="kind")" $ docker buildx create --driver kubernetes --driver-opt replicas=3 --use $ docker buildx build -t foo --load . `--load` loads the image into the local Docker. Driver opts: - `image=IMAGE` - Sets the container image to be used for running buildkit. - `namespace=NS` - Sets the Kubernetes namespace. Defaults to the current namespace. - `replicas=N` - Sets the number of `Pod` replicas. Defaults to 1. - `rootless=(true|false)` - Run the container as a non-root user without `securityContext.privileged`. Defaults to false. - `loadbalance=(sticky|random)` - Load-balancing strategy. If set to "sticky", the pod is chosen using the hash of the context path. Defaults to "sticky" Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
65 lines
2.1 KiB
Go
65 lines
2.1 KiB
Go
package diskv
|
|
|
|
import (
|
|
"compress/flate"
|
|
"compress/gzip"
|
|
"compress/zlib"
|
|
"io"
|
|
)
|
|
|
|
// Compression is an interface that Diskv uses to implement compression of
|
|
// data. Writer takes a destination io.Writer and returns a WriteCloser that
|
|
// compresses all data written through it. Reader takes a source io.Reader and
|
|
// returns a ReadCloser that decompresses all data read through it. You may
|
|
// define these methods on your own type, or use one of the NewCompression
|
|
// helpers.
|
|
type Compression interface {
|
|
Writer(dst io.Writer) (io.WriteCloser, error)
|
|
Reader(src io.Reader) (io.ReadCloser, error)
|
|
}
|
|
|
|
// NewGzipCompression returns a Gzip-based Compression.
|
|
func NewGzipCompression() Compression {
|
|
return NewGzipCompressionLevel(flate.DefaultCompression)
|
|
}
|
|
|
|
// NewGzipCompressionLevel returns a Gzip-based Compression with the given level.
|
|
func NewGzipCompressionLevel(level int) Compression {
|
|
return &genericCompression{
|
|
wf: func(w io.Writer) (io.WriteCloser, error) { return gzip.NewWriterLevel(w, level) },
|
|
rf: func(r io.Reader) (io.ReadCloser, error) { return gzip.NewReader(r) },
|
|
}
|
|
}
|
|
|
|
// NewZlibCompression returns a Zlib-based Compression.
|
|
func NewZlibCompression() Compression {
|
|
return NewZlibCompressionLevel(flate.DefaultCompression)
|
|
}
|
|
|
|
// NewZlibCompressionLevel returns a Zlib-based Compression with the given level.
|
|
func NewZlibCompressionLevel(level int) Compression {
|
|
return NewZlibCompressionLevelDict(level, nil)
|
|
}
|
|
|
|
// NewZlibCompressionLevelDict returns a Zlib-based Compression with the given
|
|
// level, based on the given dictionary.
|
|
func NewZlibCompressionLevelDict(level int, dict []byte) Compression {
|
|
return &genericCompression{
|
|
func(w io.Writer) (io.WriteCloser, error) { return zlib.NewWriterLevelDict(w, level, dict) },
|
|
func(r io.Reader) (io.ReadCloser, error) { return zlib.NewReaderDict(r, dict) },
|
|
}
|
|
}
|
|
|
|
type genericCompression struct {
|
|
wf func(w io.Writer) (io.WriteCloser, error)
|
|
rf func(r io.Reader) (io.ReadCloser, error)
|
|
}
|
|
|
|
func (g *genericCompression) Writer(dst io.Writer) (io.WriteCloser, error) {
|
|
return g.wf(dst)
|
|
}
|
|
|
|
func (g *genericCompression) Reader(src io.Reader) (io.ReadCloser, error) {
|
|
return g.rf(src)
|
|
}
|