remove ByteCounter from rootfs
This commit is contained in:
@@ -13,7 +13,11 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
rootfsFactory func(io.ReadSeeker) io.WriterTo
|
||||
flattener interface {
|
||||
Flatten(io.Writer) error
|
||||
}
|
||||
|
||||
rootfsFactory func(io.ReadSeeker) flattener
|
||||
|
||||
// Command is "rootfs" command
|
||||
Command struct {
|
||||
@@ -55,10 +59,7 @@ func (c *Command) Execute(args []string) (err error) {
|
||||
out = outf
|
||||
}
|
||||
|
||||
if _, err := c.rootfsNew(rd).WriteTo(out); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return c.rootfsNew(rd).Flatten(out)
|
||||
}
|
||||
|
||||
// init() initializes Command with the default options.
|
||||
@@ -67,7 +68,7 @@ func (c *Command) Execute(args []string) (err error) {
|
||||
// command will initialize itself.
|
||||
func (c *Command) init() {
|
||||
c.BaseCommand.Init()
|
||||
c.rootfsNew = func(r io.ReadSeeker) io.WriterTo {
|
||||
c.rootfsNew = func(r io.ReadSeeker) flattener {
|
||||
return rootfs.New(r)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func TestExecute(t *testing.T) {
|
||||
inf := filepath.Join(dir, tt.infile)
|
||||
c.PositionalArgs.Infile = goflags.Filename(inf)
|
||||
c.PositionalArgs.Outfile = tt.outfile
|
||||
c.rootfsNew = func(r io.ReadSeeker) io.WriterTo {
|
||||
c.rootfsNew = func(r io.ReadSeeker) flattener {
|
||||
return &passthrough{r}
|
||||
}
|
||||
|
||||
@@ -92,4 +92,7 @@ func TestExecute(t *testing.T) {
|
||||
|
||||
type passthrough struct{ r io.Reader }
|
||||
|
||||
func (p *passthrough) WriteTo(w io.Writer) (int64, error) { return io.Copy(w, p.r) }
|
||||
func (p *passthrough) Flatten(w io.Writer) error {
|
||||
_, err := io.Copy(w, p.r)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user