Skip to content

Commit

Permalink
Pass previous-image to analyzer
Browse files Browse the repository at this point in the history
See buildpacks#897, buildpacks#1275

Signed-off-by: Ujjwal Goyal <importujjwal@gmail.com>
  • Loading branch information
importhuman committed Sep 18, 2021
1 parent 9dd9f8f commit ab40f48
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/build/lifecycle_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,31 @@ func (l *LifecycleExecution) newAnalyze(repoName, networkMode string, publish bo
flagsOpt = WithFlags("-gid", strconv.Itoa(l.opts.GID))
}

if l.opts.PreviousImage != "" {
if l.opts.Image == nil {
return nil, errors.New("image can't be nil")
}

image, err := name.ParseReference(l.opts.Image.Name(), name.WeakValidation)
if err != nil {
return nil, fmt.Errorf("invalid image name: %s", err)
}

prevImage, err := name.ParseReference(l.opts.PreviousImage, name.WeakValidation)
if err != nil {
return nil, fmt.Errorf("invalid previous image name: %s", err)
}
if publish {
if image.Context().RegistryStr() != prevImage.Context().RegistryStr() {
return nil, fmt.Errorf(`when --publish is used, <previous-image> must be in the same image registry as <image>
image registry = %s
previous-image registry = %s`, image.Context().RegistryStr(), prevImage.Context().RegistryStr())
}
}

args = append(args, l.opts.PreviousImage)
}

if publish {
authConfig, err := auth.BuildEnvVar(authn.DefaultKeychain, repoName)
if err != nil {
Expand Down

0 comments on commit ab40f48

Please sign in to comment.