Merge pull request #3843 from dgageot/remove-more-dead-code

Remove dead or redundant code (src/cmd/linuxkit)
This commit is contained in:
Avi Deitcher 2022-10-10 20:52:47 +03:00 committed by GitHub
commit 93896eb201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 12 additions and 75 deletions

View File

@ -106,12 +106,7 @@ func Export(container string) (io.ReadCloser, error) {
if err != nil {
return nil, errors.New("could not initialize Docker API client")
}
responseBody, err := cli.ContainerExport(context.Background(), container)
if err != nil {
return nil, err
}
return responseBody, err
return cli.ContainerExport(context.Background(), container)
}
// Save save the provided image ref.

View File

@ -2,7 +2,6 @@ package initrd
import (
"archive/tar"
"bytes"
"errors"
"io"
"path/filepath"
@ -83,8 +82,9 @@ func copyTarEntry(w *Writer, thdr *tar.Header, r io.Reader) (written int64, err
var n int64
switch tp {
case cpio.TYPE_SYMLINK:
buffer := bytes.NewBufferString(thdr.Linkname)
n, err = io.Copy(w, buffer)
var count int
count, err = w.Write([]byte(thdr.Linkname))
n = int64(count)
case cpio.TYPE_REG:
n, err = io.Copy(w, r)
}

View File

@ -29,18 +29,6 @@ var (
Config = GlobalConfig{}
)
// infoFormatter overrides the default format for Info() log events to
// provide an easier to read output
type infoFormatter struct {
}
func (f *infoFormatter) Format(entry *log.Entry) ([]byte, error) {
if entry.Level == log.InfoLevel {
return append([]byte(entry.Message), '\n'), nil
}
return defaultLogFormatter.Format(entry)
}
func printVersion() {
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), version.Version)
if version.GitCommit != "" {

View File

@ -358,8 +358,7 @@ func (k *kernelFilter) WriteHeader(hdr *tar.Header) error {
if err := tw.WriteHeader(whdr); err != nil {
return err
}
buf := bytes.NewBufferString(k.cmdline)
_, err = io.Copy(tw, buf)
_, err = tw.Write([]byte(k.cmdline))
if err != nil {
return err
}

View File

@ -2,7 +2,6 @@ package moby
import (
"archive/tar"
"bytes"
"encoding/json"
"fmt"
"io"
@ -231,8 +230,7 @@ func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, resolv string, o
if err := tw.WriteHeader(hdr); err != nil {
return err
}
buf := bytes.NewBufferString(contents)
_, err = io.Copy(tw, buf)
_, err = tw.Write([]byte(contents))
if err != nil {
return err
}
@ -307,8 +305,7 @@ func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, resolv string, o
return err
}
if hdr.Size > 0 {
buf := bytes.NewBufferString(contents)
if _, err = io.Copy(tw, buf); err != nil {
if _, err = tw.Write([]byte(contents)); err != nil {
return err
}
}
@ -349,8 +346,7 @@ func ImageBundle(prefix string, ref *reference.Spec, config []byte, runtime Runt
if err := tw.WriteHeader(hdr); err != nil {
return err
}
buf := bytes.NewBuffer(config)
if _, err := io.Copy(tw, buf); err != nil {
if _, err := tw.Write(config); err != nil {
return err
}
@ -426,8 +422,7 @@ func ImageBundle(prefix string, ref *reference.Spec, config []byte, runtime Runt
if err := tw.WriteHeader(hdr); err != nil {
return err
}
buf = bytes.NewBuffer(runtimeConfig)
if _, err := io.Copy(tw, buf); err != nil {
if _, err := tw.Write(runtimeConfig); err != nil {
return err
}

View File

@ -1,6 +1,6 @@
package moby
var schema = string(`
var schema = `
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Moby Config",
@ -328,4 +328,4 @@ var schema = string(`
"files": { "$ref": "#/definitions/files" }
}
}
`)
`

View File

@ -24,10 +24,6 @@ import (
"golang.org/x/sync/errgroup"
)
const (
minimumDockerVersion = "19.03"
)
type buildOpts struct {
skipBuild bool
force bool

View File

@ -42,7 +42,6 @@ import (
)
const (
registryServer = "https://index.docker.io/v1/"
buildkitBuilderName = "linuxkit-builder"
buildkitSocketPath = "/run/buildkit/buildkitd.sock"
buildkitWaitServer = 30 // seconds
@ -63,11 +62,6 @@ type dockerRunnerImpl struct {
cache bool
}
type buildContext interface {
// Copy copies the build context to the supplied WriterCloser
Copy(io.WriteCloser) error
}
func newDockerRunner(cache bool) dockerRunner {
return &dockerRunnerImpl{cache: cache}
}

View File

@ -1,18 +0,0 @@
package pkglib
import (
"io"
)
type readerCtx struct {
reader io.Reader
}
// Copy just copies from reader to writer
func (c *readerCtx) Copy(w io.WriteCloser) error {
_, err := io.Copy(w, c.reader)
if err != nil {
return err
}
return w.Close()
}

View File

@ -113,7 +113,7 @@ func generateMAC() net.HardwareAddr {
}
mac[0] &^= 0x01 // Clear multicast bit
mac[0] |= 0x2 // Set locally administered bit
return net.HardwareAddr(mac)
return mac
}
func runQemu(args []string) {
@ -621,15 +621,3 @@ func buildQemuForwardings(publishFlags multipleFlag) (string, error) {
return forwardings, nil
}
func buildDockerForwardings(publishedPorts []string) ([]string, error) {
var pmap []string
for _, port := range publishedPorts {
s, err := NewPublishedPort(port)
if err != nil {
return nil, err
}
pmap = append(pmap, "-p", fmt.Sprintf("%d:%d/%s", s.Host, s.Guest, s.Protocol))
}
return pmap, nil
}