Skip to content

Commit

Permalink
Pass the OS from the source image to the target
Browse files Browse the repository at this point in the history
Presently, images generated with 'update-buildpack-image-id' will have the OS='' (empty string). This is not being copied over from the source image, which has the OS set. This PR changes it so that the value from the source image is set on the target image.

Signed-off-by: Daniel Mikusa <[email protected]>
  • Loading branch information
Daniel Mikusa committed Aug 27, 2022
1 parent 0bbf448 commit d3a47ca
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions buildpack/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ func Rename(buildpack, tag, newID, newVersion string) (string, error) {
return "", fmt.Errorf("unable to unable to parse reference for new buildpack tag\n%w", err)
}

srcCfgFile, err := image.ConfigFile()
if err != nil {
return "", fmt.Errorf("unable to fetch config file\n%w", err)
}

targetCfgFile, err := newBuildpackage.ConfigFile()
if err != nil {
return "", fmt.Errorf("unable to fetch config file\n%w", err)
}
targetCfgFile.OS = srcCfgFile.OS

newBuildpackage, err = mutate.ConfigFile(newBuildpackage, targetCfgFile)
if err != nil {
return "", fmt.Errorf("unable to transfer config file\n%w", err)
}

err = remote.Write(reference, newBuildpackage, remote.WithAuthFromKeychain(authn.DefaultKeychain))
if err != nil {
return "", fmt.Errorf("unable to write new buildapck\n%w", err)
Expand Down

0 comments on commit d3a47ca

Please sign in to comment.