Skip to content

Commit c66e51f

Browse files
authored
[spin] broken symlinks (#244)
1 parent ac277c8 commit c66e51f

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

pkg/spin/registry/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ func tarIt(ctx context.Context, rootfsDir, outputTarball string) error {
577577
default:
578578

579579
linkname, _ := os.Readlink(file)
580-
header, err := tar.FileInfoHeader(fi, filepath.Clean("/"+linkname))
580+
header, err := tar.FileInfoHeader(fi, filepath.Clean(linkname))
581581
if err != nil {
582582
return fmt.Errorf("failed to create tar header: %w", err)
583583
}

tools/spin/pull.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var pullCommand = &cli.Command{
3232
pbar := mpb.New(mpb.WithWidth(60), mpb.WithRefreshRate(100*time.Millisecond), mpb.WithOutput(os.Stderr))
3333
pullChan := make(chan error, 1)
3434

35-
pull(ctx.Context, reg, image, pbar, pullChan)
35+
pull(ctx.Context, reg, image, pbar, pullChan, false)
3636

3737
err = <-pullChan
3838
if err != nil {
@@ -45,16 +45,22 @@ var pullCommand = &cli.Command{
4545
},
4646
}
4747

48-
func pull(ctx context.Context, reg spin.Registry, image string, pbar *mpb.Progress, pullChan chan<- error) {
48+
func pull(ctx context.Context, reg spin.Registry, image string, pbar *mpb.Progress, pullChan chan<- error, remove bool) {
4949
progress := make(chan spin.PullProgress, 1024)
5050
var pullErr error
5151
go func() {
52-
pullBar, _ := pbar.Add(100,
53-
mpb.BarStyle().Build(),
52+
opts := []mpb.BarOption{
5453
mpb.AppendDecorators(decor.Percentage()),
5554
mpb.PrependDecorators(
5655
decor.Name("Pulling "),
5756
),
57+
}
58+
if remove {
59+
opts = append(opts, mpb.BarRemoveOnComplete())
60+
}
61+
pullBar, _ := pbar.Add(100,
62+
mpb.BarStyle().Build(),
63+
opts...,
5864
)
5965
for pr := range progress {
6066
if pr.Error() != io.EOF {

tools/spin/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ var runCommand = &cli.Command{
149149
}
150150
containerOpts = append(containerOpts, Image(image), Command(ctx.Args().Slice()[1:]...))
151151
// start pulling
152-
pull(cCtx, reg, image, pbar, pullChan)
152+
pull(cCtx, reg, image, pbar, pullChan, true)
153153
} else {
154154
containerOpts = append(containerOpts, Command(ctx.Args().Slice()...))
155155
pullChan <- nil

0 commit comments

Comments
 (0)