Skip to content

Commit

Permalink
packit, occam fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun024 authored and paketo-bot committed Jan 4, 2021
1 parent e0c8714 commit faa9149
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
16 changes: 12 additions & 4 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Build(entryResolver EntryResolver, dependencyService DependencyService, pro
return packit.BuildResult{}, fmt.Errorf("failed to create logs dir : %w", err)
}

nginxLayer, err := context.Layers.Get(NGINX, packit.LaunchLayer)
nginxLayer, err := context.Layers.Get(NGINX)
if err != nil {
return packit.BuildResult{}, err
}
Expand All @@ -80,18 +80,24 @@ func Build(entryResolver EntryResolver, dependencyService DependencyService, pro
Layers: []packit.Layer{
nginxLayer,
},
Processes: defaultStartProcesses,
Launch: packit.LaunchMetadata{
Processes: defaultStartProcesses,
},
}, nil
}

logger.Break()
logger.Process("Executing build process")

err = nginxLayer.Reset()
nginxLayer, err = nginxLayer.Reset()
if err != nil {
return packit.BuildResult{}, err
}

// later todo: ask for launch in metadata (detect) and
// read metadata here
nginxLayer.Launch = true

err = os.MkdirAll(filepath.Join(nginxLayer.Path, "bin"), os.ModePerm)
if err != nil {
return packit.BuildResult{}, err
Expand Down Expand Up @@ -141,7 +147,9 @@ func Build(entryResolver EntryResolver, dependencyService DependencyService, pro
Layers: []packit.Layer{
nginxLayer,
},
Processes: defaultStartProcesses,
Launch: packit.LaunchMetadata{
Processes: defaultStartProcesses,
},
}, nil
}
}
Expand Down
23 changes: 14 additions & 9 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
},
},
},
Processes: []packit.Process{
{
Type: "web",
Command: fmt.Sprintf(`nginx -p $PWD -c "%s"`, filepath.Join(workspaceDir, "nginx.conf")),
Launch: packit.LaunchMetadata{
Processes: []packit.Process{
{
Type: "web",
Command: fmt.Sprintf(`nginx -p $PWD -c "%s"`, filepath.Join(workspaceDir, "nginx.conf")),
},
},
},
}))
Expand Down Expand Up @@ -188,7 +190,8 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {

context("when rebuilding a layer", func() {
it.Before(func() {
err := ioutil.WriteFile(filepath.Join(layersDir, "nginx.toml"), []byte(fmt.Sprintf(`[metadata]
err := ioutil.WriteFile(filepath.Join(layersDir, "nginx.toml"), []byte(fmt.Sprintf(`launch = true
[metadata]
dependency-sha = "some-sha"
configure-bin-sha = "some-bin-sha"
built_at = "%s"
Expand Down Expand Up @@ -242,10 +245,12 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
},
},
},
Processes: []packit.Process{
{
Type: "web",
Command: fmt.Sprintf(`nginx -p $PWD -c "%s"`, filepath.Join(workspaceDir, "nginx.conf")),
Launch: packit.LaunchMetadata{
Processes: []packit.Process{
{
Type: "web",
Command: fmt.Sprintf(`nginx -p $PWD -c "%s"`, filepath.Join(workspaceDir, "nginx.conf")),
},
},
},
}))
Expand Down

0 comments on commit faa9149

Please sign in to comment.