forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run analyze and export directly rather than through docker
Signed-off-by: Dave Goddard <dave@goddard.id.au>
- Loading branch information
1 parent
82a7e97
commit 45e1ae0
Showing
8 changed files
with
222 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package pack | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/buildpack/lifecycle" | ||
"github.com/buildpack/packs" | ||
) | ||
|
||
func analyzer(group lifecycle.BuildpackGroup, launchDir, repoName string, useDaemon bool) error { | ||
origImage, err := readImage(repoName, useDaemon) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if origImage == nil { | ||
// no previous image to analyze | ||
return nil | ||
} | ||
|
||
analyzer := &lifecycle.Analyzer{ | ||
Buildpacks: group.Buildpacks, | ||
Out: os.Stdout, | ||
Err: os.Stderr, | ||
} | ||
err = analyzer.Analyze( | ||
launchDir, | ||
origImage, | ||
) | ||
if err != nil { | ||
return packs.FailErrCode(err, packs.CodeFailedBuild) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package pack | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/buildpack/lifecycle" | ||
"github.com/buildpack/packs" | ||
"github.com/buildpack/packs/img" | ||
) | ||
|
||
func export(group lifecycle.BuildpackGroup, launchDir, repoName, stackName string, useDaemon, useDaemonStack bool) error { | ||
origImage, err := readImage(repoName, useDaemon) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
stackImage, err := readImage(stackName, useDaemonStack) | ||
if err != nil || stackImage == nil { | ||
return packs.FailErr(err, "get image for", stackName) | ||
} | ||
|
||
var repoStore img.Store | ||
if useDaemon { | ||
repoStore, err = img.NewDaemon(repoName) | ||
} else { | ||
repoStore, err = img.NewRegistry(repoName) | ||
} | ||
if err != nil { | ||
return packs.FailErr(err, "access", repoName) | ||
} | ||
|
||
tmpDir, err := ioutil.TempDir("", "lifecycle.exporter.layer") | ||
if err != nil { | ||
return packs.FailErr(err, "create temp directory") | ||
} | ||
defer os.RemoveAll(tmpDir) | ||
|
||
exporter := &lifecycle.Exporter{ | ||
Buildpacks: group.Buildpacks, | ||
TmpDir: tmpDir, | ||
Out: os.Stdout, | ||
Err: os.Stderr, | ||
} | ||
newImage, err := exporter.Export( | ||
launchDir, | ||
stackImage, | ||
origImage, | ||
) | ||
if err != nil { | ||
return packs.FailErrCode(err, packs.CodeFailedBuild) | ||
} | ||
|
||
if err := repoStore.Write(newImage); err != nil { | ||
return packs.FailErrCode(err, packs.CodeFailedUpdate, "write") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.