Skip to content

Commit

Permalink
Exit with access error if rebase container cannot access previous app…
Browse files Browse the repository at this point in the history
… image or run image

- This prevents opaque errors where the rebase would fail trying to read labels on a inaccessible image:
```
ERROR: rebase working image: rebase: could not find base layer in image
```
  • Loading branch information
matthewmcnew committed Jun 29, 2020
1 parent e075180 commit 2998cdf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/rebase/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/buildpacks/imgutil/remote"
"github.com/buildpacks/lifecycle"
"github.com/buildpacks/lifecycle/cmd"
"github.com/pkg/errors"

"github.com/pivotal/kpack/pkg/dockercreds"
"github.com/pivotal/kpack/pkg/flaghelpers"
Expand Down Expand Up @@ -74,11 +75,19 @@ func rebase(tags []string, logger *log.Logger) error {
return err
}

if !appImage.Found() {
return errors.Errorf("could not access previous image: %s", *lastBuiltImage)
}

newBaseImage, err := remote.NewImage(*runImage, keychain, remote.FromBaseImage(*runImage))
if err != nil {
return err
}

if !newBaseImage.Found() {
return errors.Errorf("could not access run image: %s", *runImage)
}

rebaser := lifecycle.Rebaser{
Logger: cmd.Logger,
}
Expand Down

0 comments on commit 2998cdf

Please sign in to comment.