Skip to content

Commit

Permalink
fix extension builder for saveasfile
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Kumar <itsdarshankumar@gmail.com>
  • Loading branch information
itsdarshankumar committed Mar 6, 2023
1 parent ec105ea commit 0baa22d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions pkg/buildpack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,39 @@ func (b *PackageBuilder) resolvedStacks() []dist.Stack {
}

func (b *PackageBuilder) SaveAsFile(path, imageOS string) error {
if err := b.validate(); err != nil {
return err
if b.buildpack != nil {
if err := b.validate(); err != nil {
return err
}
}

layoutImage, err := newLayoutImage(imageOS)
if err != nil {
return errors.Wrap(err, "creating layout image")
}

tmpDir, err := os.MkdirTemp("", "package-buildpack")
tempDirName := ""
if b.buildpack != nil {
tempDirName = "package-buildpack"
} else {
tempDirName = "extension-buildpack"
}

tmpDir, err := os.MkdirTemp("", tempDirName)
if err != nil {
return err
}
defer os.RemoveAll(tmpDir)

if err := b.finalizeImage(layoutImage, tmpDir); err != nil {
return err
if b.buildpack != nil {
if err := b.finalizeImage(layoutImage, tmpDir); err != nil {
return err
}
} else {
if err := b.finalizeExtensionImage(layoutImage, tmpDir); err != nil {
return err
}
}

layoutDir, err := os.MkdirTemp(tmpDir, "oci-layout")
if err != nil {
return errors.Wrap(err, "creating oci-layout temp dir")
Expand Down

0 comments on commit 0baa22d

Please sign in to comment.