diff --git a/build_test.go b/build_test.go index 5056c77..8e4dfe4 100644 --- a/build_test.go +++ b/build_test.go @@ -105,7 +105,10 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("handles error from Builder", func() { - Expect(ioutil.WriteFile(filepath.Join(buildpackPath, "buildpack.toml"), []byte(`[buildpack] + Expect(ioutil.WriteFile(filepath.Join(buildpackPath, "buildpack.toml"), []byte(` +api = "0.5" + +[buildpack] name = "test-name" version = "test-version"`), 0644)).To(Succeed()) diff --git a/buildpack.go b/buildpack.go index d35b247..c0c0055 100644 --- a/buildpack.go +++ b/buildpack.go @@ -83,9 +83,9 @@ type BuildpackDependency struct { Licenses []BuildpackDependencyLicense `toml:"licenses"` } -// AsBuildpackPlanEntry renders the dependency as a BuildpackPlanEntry. -func (b BuildpackDependency) AsBuildpackPlanEntry() libcnb.BuildpackPlanEntry { - return libcnb.BuildpackPlanEntry{ +// AsBOMEntry renders a bill of materials entry describing the dependency. +func (b BuildpackDependency) AsBOMEntry() libcnb.BOMEntry { + return libcnb.BOMEntry{ Name: b.ID, Metadata: map[string]interface{}{ "name": b.Name, diff --git a/buildpack_test.go b/buildpack_test.go index 4b68105..5bc9844 100644 --- a/buildpack_test.go +++ b/buildpack_test.go @@ -33,7 +33,7 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) { Expect = NewWithT(t).Expect ) - it("renders dependency as an BuildpackPlanEntry", func() { + it("renders dependency as a BOMEntry", func() { dependency := libpak.BuildpackDependency{ ID: "test-id", Name: "test-name", @@ -49,7 +49,7 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) { }, } - Expect(dependency.AsBuildpackPlanEntry()).To(Equal(libcnb.BuildpackPlanEntry{ + Expect(dependency.AsBOMEntry()).To(Equal(libcnb.BOMEntry{ Name: dependency.ID, Metadata: map[string]interface{}{ "name": dependency.Name, diff --git a/detect_test.go b/detect_test.go index a14ab0e..02e64af 100644 --- a/detect_test.go +++ b/detect_test.go @@ -99,7 +99,10 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }) it("handles error from Detector", func() { - Expect(ioutil.WriteFile(filepath.Join(buildpackPath, "buildpack.toml"), []byte(`[buildpack] + Expect(ioutil.WriteFile(filepath.Join(buildpackPath, "buildpack.toml"), []byte(` +api = "0.5" + +[buildpack] name = "test-name" version = "test-version"`), 0644)).To(Succeed()) diff --git a/go.mod b/go.mod index 7950fec..214e95e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/Masterminds/semver/v3 v3.1.1 - github.com/buildpacks/libcnb v1.18.1 + github.com/buildpacks/libcnb v1.19.0 github.com/creack/pty v1.1.11 github.com/heroku/color v0.0.6 github.com/imdario/mergo v0.3.11 diff --git a/go.sum b/go.sum index 1ee1b02..f98727f 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030I github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/buildpacks/libcnb v1.18.1 h1:NcAqtyLmSkpcgIOl83GOHY5Mk2ltBFiAI8mmAvavvEs= github.com/buildpacks/libcnb v1.18.1/go.mod h1:ozKZYold67tlck+1cobg11YhGmJqkQr8bMAH5gSvEvw= +github.com/buildpacks/libcnb v1.19.0 h1:7Frn3qErlVmQydk95YXmHtpmf5bZ1l7h4rK/C+SKAmY= +github.com/buildpacks/libcnb v1.19.0/go.mod h1:slnOsywO4mNdkShkwX1GYR+kQF1tH2F9Urfr66lWGQs= github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/toml_writer.go b/internal/toml_writer.go index 78cca79..a76b6a5 100644 --- a/internal/toml_writer.go +++ b/internal/toml_writer.go @@ -67,7 +67,7 @@ func (t TOMLWriter) Write(path string, value interface{}) error { } switch v := value.(type) { - case libcnb.Launch: + case libcnb.LaunchTOML: if len(v.Slices) > 0 { t.logger.Headerf("%d application slices", len(v.Slices)) } diff --git a/internal/toml_writer_test.go b/internal/toml_writer_test.go index 10d5605..9785008 100644 --- a/internal/toml_writer_test.go +++ b/internal/toml_writer_test.go @@ -87,7 +87,7 @@ other-field = "other-value"`)) }) it("logs []libcnb.Slice", func() { - err := tomlWriter.Write(path, libcnb.Launch{ + err := tomlWriter.Write(path, libcnb.LaunchTOML{ Slices: []libcnb.Slice{ {}, {}, @@ -100,7 +100,7 @@ other-field = "other-value"`)) }) it("logs []libcnb.Label", func() { - err := tomlWriter.Write(path, libcnb.Launch{ + err := tomlWriter.Write(path, libcnb.LaunchTOML{ Labels: []libcnb.Label{ {Key: "test-key-1"}, {Key: "test-key-2"}, @@ -117,7 +117,7 @@ other-field = "other-value"`)) context("[]libcnb.Process", func() { it("aligns process types", func() { - err := tomlWriter.Write(path, libcnb.Launch{ + err := tomlWriter.Write(path, libcnb.LaunchTOML{ Processes: []libcnb.Process{ {Type: "short", Command: "test-command-1"}, {Type: "a-very-long-type", Command: "test-command-2"}, @@ -133,7 +133,7 @@ other-field = "other-value"`)) }) it("appends arguments", func() { - err := tomlWriter.Write(path, libcnb.Launch{ + err := tomlWriter.Write(path, libcnb.LaunchTOML{ Processes: []libcnb.Process{ {Type: "test-type", Command: "test-command", Arguments: []string{"test-arg-1", "test-arg-2"}}, }, @@ -147,7 +147,7 @@ other-field = "other-value"`)) }) it("indicates direct", func() { - err := tomlWriter.Write(path, libcnb.Launch{ + err := tomlWriter.Write(path, libcnb.LaunchTOML{ Processes: []libcnb.Process{ {Type: "test-type", Command: "test-command", Direct: true}, }, diff --git a/layer.go b/layer.go index 6f0918d..48670fb 100644 --- a/layer.go +++ b/layer.go @@ -21,7 +21,6 @@ import ( "os" "path/filepath" "reflect" - "strings" "github.com/heroku/color" "github.com/pelletier/go-toml" @@ -45,29 +44,26 @@ type LayerContributor struct { // Name is the user readable name of the contribution. Name string + + // ExpectedTypes indicates the types that should be set on the layer. + ExpectedTypes libcnb.LayerTypes } // NewLayerContributor creates a new instance. -func NewLayerContributor(name string, expectedMetadata interface{}) LayerContributor { +func NewLayerContributor(name string, expectedMetadata interface{}, expectedTypes libcnb.LayerTypes) LayerContributor { return LayerContributor{ ExpectedMetadata: expectedMetadata, Name: name, + ExpectedTypes: expectedTypes, } } // LayerFunc is a callback function that is invoked when a layer needs to be contributed. type LayerFunc func() (libcnb.Layer, error) -type LayerFlag uint8 - -const ( - BuildLayer LayerFlag = iota - CacheLayer - LaunchLayer -) // Contribute is the function to call when implementing your libcnb.LayerContributor. -func (l *LayerContributor) Contribute(layer libcnb.Layer, f LayerFunc, flags ...LayerFlag) (libcnb.Layer, error) { +func (l *LayerContributor) Contribute(layer libcnb.Layer, f LayerFunc) (libcnb.Layer, error) { raw, err := toml.Marshal(l.ExpectedMetadata) if err != nil { return libcnb.Layer{}, fmt.Errorf("unable to encode metadata\n%w", err) @@ -81,6 +77,7 @@ func (l *LayerContributor) Contribute(layer libcnb.Layer, f LayerFunc, flags ... l.Logger.Debugf("Expected metadata: %+v", expected) l.Logger.Debugf("Actual metadata: %+v", layer.Metadata) + // TODO: compare entire layer not just metadata (in case build, launch, or cache have changed) if reflect.DeepEqual(expected, layer.Metadata) { l.Logger.Headerf("%s: %s cached layer", color.BlueString(l.Name), color.GreenString("Reusing")) return layer, nil @@ -101,17 +98,7 @@ func (l *LayerContributor) Contribute(layer libcnb.Layer, f LayerFunc, flags ... return libcnb.Layer{}, err } - for _, f := range flags { - switch f { - case BuildLayer: - layer.Build = true - case CacheLayer: - layer.Cache = true - case LaunchLayer: - layer.Launch = true - } - } - + layer.LayerTypes = l.ExpectedTypes layer.Metadata = expected return layer, nil @@ -127,8 +114,11 @@ type DependencyLayerContributor struct { // DependencyCache is the cache to use to get the dependency. DependencyCache DependencyCache - // LayerContributor is the contained LayerContributor used for the actual contribution. - LayerContributor LayerContributor + // ExpectedTypes indicates the types that should be set on the layer. + ExpectedTypes libcnb.LayerTypes + + // ExpectedMetadata contains metadata describing the expected layer + ExpectedMetadata interface{} // Logger is the logger to use. Logger bard.Logger @@ -137,29 +127,38 @@ type DependencyLayerContributor struct { RequestModifierFuncs []RequestModifierFunc } -// NewDependencyLayerContributor creates a new instance and adds the dependency to the Buildpack Plan. -func NewDependencyLayerContributor(dependency BuildpackDependency, cache DependencyCache, plan *libcnb.BuildpackPlan) DependencyLayerContributor { +// NewDependencyLayer returns a new DependencyLayerContributor for the given BuildpackDependency and a BOMEntry describing the layer contents. +func NewDependencyLayer(dependency BuildpackDependency, cache DependencyCache, types libcnb.LayerTypes) (DependencyLayerContributor, libcnb.BOMEntry) { c := DependencyLayerContributor{ Dependency: dependency, + ExpectedMetadata: dependency, DependencyCache: cache, - LayerContributor: NewLayerContributor(fmt.Sprintf("%s %s", dependency.Name, dependency.Version), dependency), + ExpectedTypes: types, } - entry := dependency.AsBuildpackPlanEntry() + entry := dependency.AsBOMEntry() entry.Metadata["layer"] = c.LayerName() - plan.Entries = append(plan.Entries, entry) - return c + if types.Launch { + entry.Launch = true + } + if !(types.Launch && !types.Cache && !types.Build) { + // launch-only layers are the only layers NOT guaranteed to be present in the build environment + entry.Build = true + } + + return c, entry } // DependencyLayerFunc is a callback function that is invoked when a dependency needs to be contributed. type DependencyLayerFunc func(artifact *os.File) (libcnb.Layer, error) // Contribute is the function to call whe implementing your libcnb.LayerContributor. -func (d *DependencyLayerContributor) Contribute(layer libcnb.Layer, f DependencyLayerFunc, flags ...LayerFlag) (libcnb.Layer, error) { - d.LayerContributor.Logger = d.Logger +func (d *DependencyLayerContributor) Contribute(layer libcnb.Layer, f DependencyLayerFunc) (libcnb.Layer, error) { + lc := NewLayerContributor(d.Name(), d.ExpectedMetadata, d.ExpectedTypes) + lc.Logger = d.Logger - return d.LayerContributor.Contribute(layer, func() (libcnb.Layer, error) { + return lc.Contribute(layer, func() (libcnb.Layer, error) { artifact, err := d.DependencyCache.Artifact(d.Dependency, d.RequestModifierFuncs...) if err != nil { return libcnb.Layer{}, fmt.Errorf("unable to get dependency %s\n%w", d.Dependency.ID, err) @@ -167,7 +166,7 @@ func (d *DependencyLayerContributor) Contribute(layer libcnb.Layer, f Dependency defer artifact.Close() return f(artifact) - }, flags...) + }) } // LayerName returns the conventional name of the layer for this contributor @@ -175,6 +174,11 @@ func (d *DependencyLayerContributor) LayerName() string { return d.Dependency.ID } +// Name returns the human readable name of the layer +func (d *DependencyLayerContributor) Name() string { + return fmt.Sprintf("%s %s", d.Dependency.Name, d.Dependency.Version) +} + // HelperLayerContributor is a helper for implementing a libcnb.LayerContributor for a buildpack helper application in // order to get consistent logging and avoidance. type HelperLayerContributor struct { @@ -182,8 +186,8 @@ type HelperLayerContributor struct { // Path is the path to the helper application. Path string - // LayerContributor is the contained LayerContributor used for the actual contribution. - LayerContributor LayerContributor + // BuildpackInfo describes the buildpack that provides the helper + BuildpackInfo libcnb.BuildpackInfo // Logger is the logger to use. Logger bard.Logger @@ -192,31 +196,40 @@ type HelperLayerContributor struct { Names []string } -// NewHelperLayerContributor creates a new instance and adds the helper to the Buildpack Plan. -func NewHelperLayerContributor(buildpack libcnb.Buildpack, plan *libcnb.BuildpackPlan, names ...string) HelperLayerContributor { +// NewHelperLayer returns a new HelperLayerContributor and a BOMEntry describing the layer contents. +func NewHelperLayer(buildpack libcnb.Buildpack, names ...string) (HelperLayerContributor, libcnb.BOMEntry) { c := HelperLayerContributor{ - Path: filepath.Join(buildpack.Path, "bin", "helper"), - LayerContributor: NewLayerContributor("Launch Helper", buildpack.Info), - Names: names, + Path: filepath.Join(buildpack.Path, "bin", "helper"), + Names: names, + BuildpackInfo: buildpack.Info, } - plan.Entries = append(plan.Entries, libcnb.BuildpackPlanEntry{ + entry := libcnb.BOMEntry{ Name: "helper", Metadata: map[string]interface{}{ "layer": c.Name(), "names": names, "version": buildpack.Info.Version, }, - }) + Launch: true, + } + + return c, entry +} - return c +// Name returns the conventional name of the layer for this contributor +func (h HelperLayerContributor) Name() string { + return filepath.Base(h.Path) } // Contribute is the function to call whe implementing your libcnb.LayerContributor. func (h HelperLayerContributor) Contribute(layer libcnb.Layer) (libcnb.Layer, error) { - h.LayerContributor.Logger = h.Logger + lc := NewLayerContributor("Launch Helper", h.BuildpackInfo, libcnb.LayerTypes{ + Launch: true, + }) + lc.Logger = h.Logger - return h.LayerContributor.Contribute(layer, func() (libcnb.Layer, error) { + return lc.Contribute(layer, func() (libcnb.Layer, error) { in, err := os.Open(h.Path) if err != nil { return libcnb.Layer{}, fmt.Errorf("unable to open %s\n%w", h.Path, err) @@ -228,7 +241,6 @@ func (h HelperLayerContributor) Contribute(layer libcnb.Layer) (libcnb.Layer, er return libcnb.Layer{}, fmt.Errorf("unable to copy %s to %s", h.Path, out) } - var p []string for _, n := range h.Names { link := layer.Exec.FilePath(n) h.Logger.Bodyf("Creating %s", link) @@ -241,24 +253,8 @@ func (h HelperLayerContributor) Contribute(layer libcnb.Layer) (libcnb.Layer, er if err := os.Symlink(out, link); err != nil { return libcnb.Layer{}, fmt.Errorf("unable to link %s to %s\n%w", out, link, err) } - - p = append(p, - "exec 4<&1", - fmt.Sprintf(`for_export=$(%s 3>&1 >&4) || exit $?`, link), - "exec 4<&-", - "set -a", - `eval "$for_export"`, - "set +a", - ) } - layer.Profile.Add("helper", strings.Join(p, "\n")) - return layer, nil - }, LaunchLayer) -} - -// Name returns the conventional name of the layer for this contributor -func (h HelperLayerContributor) Name() string { - return filepath.Base(h.Path) + }) } diff --git a/layer_test.go b/layer_test.go index f1c92eb..c62b4e5 100644 --- a/layer_test.go +++ b/layer_test.go @@ -30,6 +30,7 @@ import ( "github.com/sclevine/spec" "github.com/paketo-buildpacks/libpak" + "github.com/paketo-buildpacks/libpak/bard" ) func testLayer(t *testing.T, context spec.G, it spec.S) { @@ -138,30 +139,127 @@ func testLayer(t *testing.T, context spec.G, it spec.S) { }) it("sets build layer flag", func() { + lc.ExpectedTypes.Build = true layer, err := lc.Contribute(layer, func() (libcnb.Layer, error) { return layer, nil - }, libpak.BuildLayer) + }) Expect(err).NotTo(HaveOccurred()) - Expect(layer.Build).To(BeTrue()) + Expect(layer.LayerTypes.Build).To(BeTrue()) }) it("sets cache layer flag", func() { + lc.ExpectedTypes.Cache = true layer, err := lc.Contribute(layer, func() (libcnb.Layer, error) { return layer, nil - }, libpak.CacheLayer) + }) Expect(err).NotTo(HaveOccurred()) - Expect(layer.Cache).To(BeTrue()) + Expect(layer.LayerTypes.Cache).To(BeTrue()) }) it("sets launch layer flag", func() { + lc.ExpectedTypes.Launch = true layer, err := lc.Contribute(layer, func() (libcnb.Layer, error) { return layer, nil - }, libpak.LaunchLayer) + }) Expect(err).NotTo(HaveOccurred()) - Expect(layer.Launch).To(BeTrue()) + Expect(layer.LayerTypes.Launch).To(BeTrue()) + }) + }) + + context("NewDependencyLayer", func() { + var dep libpak.BuildpackDependency + + it.Before(func() { + dep = libpak.BuildpackDependency{ + ID: "test-id", + Name: "test-name", + Version: "1.1.1", + URI: "test-uri", + SHA256: "576dd8416de5619ea001d9662291d62444d1292a38e96956bc4651c01f14bca1", + Stacks: []string{"test-stack"}, + Licenses: []libpak.BuildpackDependencyLicense{ + { + Type: "test-type", + URI: "test-uri", + }, + }, + } + }) + it("returns a BOM entry for the layer", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{}) + Expect(entry.Name).To(Equal("test-id")) + Expect(entry.Metadata["name"]).To(Equal("test-name")) + Expect(entry.Metadata["version"]).To(Equal("1.1.1")) + Expect(entry.Metadata["uri"]).To(Equal("test-uri")) + Expect(entry.Metadata["sha256"]).To(Equal("576dd8416de5619ea001d9662291d62444d1292a38e96956bc4651c01f14bca1")) + Expect(entry.Metadata["licenses"]).To(Equal([]libpak.BuildpackDependencyLicense{ + { + Type: "test-type", + URI: "test-uri", + }, + })) + }) + context("launch layer type", func() { + it("only sets launch on the entry", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{ + Launch: true, + }) + Expect(entry.Launch).To(BeTrue()) + Expect(entry.Build).To(BeFalse()) + }) + }) + + context("launch and build layer type", func() { + it("sets launch and build on the entry", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{ + Launch: true, + Build: true, + }) + Expect(entry.Launch).To(BeTrue()) + Expect(entry.Build).To(BeTrue()) + }) + }) + + context("launch and cache layer type", func() { + it("sets launch and build on the entry", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{ + Launch: true, + Cache: true, + }) + Expect(entry.Launch).To(BeTrue()) + Expect(entry.Build).To(BeTrue()) + }) + }) + + context("build layer type", func() { + it("sets build on the entry", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{ + Build: true, + }) + Expect(entry.Launch).To(BeFalse()) + Expect(entry.Build).To(BeTrue()) + }) + }) + + context("cache layer type", func() { + it("sets build on the entry", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{ + Cache: true, + }) + Expect(entry.Launch).To(BeFalse()) + Expect(entry.Build).To(BeTrue()) + }) + }) + + context("no layer types", func() { + it("sets build on the entry", func() { + _, entry := libpak.NewDependencyLayer(dep, libpak.DependencyCache{}, libcnb.LayerTypes{}) + Expect(entry.Launch).To(BeFalse()) + Expect(entry.Build).To(BeTrue()) + }) }) }) @@ -193,8 +291,7 @@ func testLayer(t *testing.T, context spec.G, it spec.S) { layer.Metadata = map[string]interface{}{} - dlc.LayerContributor.ExpectedMetadata = dependency - + dlc.ExpectedMetadata = dependency dlc.Dependency = dependency dlc.DependencyCache.CachePath = layer.Path dlc.DependencyCache.DownloadPath = layer.Path @@ -320,24 +417,27 @@ func testLayer(t *testing.T, context spec.G, it spec.S) { }, })) }) + }) - it("contributes to buildpack plan", func() { - plan := libcnb.BuildpackPlan{} - - _ = libpak.NewDependencyLayerContributor(dependency, libpak.DependencyCache{}, &plan) - - Expect(plan.Entries).To(ContainElement(libcnb.BuildpackPlanEntry{ - Name: dependency.ID, - Metadata: map[string]interface{}{ - "name": dependency.Name, - "version": dependency.Version, - "layer": dependency.ID, - "uri": dependency.URI, - "sha256": dependency.SHA256, - "stacks": dependency.Stacks, - "licenses": dependency.Licenses, + context("NewHelperLayer", func() { + it("returns a BOM entry with version equal to buildpack version", func() { + _, entry := libpak.NewHelperLayer(libcnb.Buildpack{ + Info: libcnb.BuildpackInfo{ + Version: "test-version", }, - })) + }, "test-name-1", "test-name-2") + Expect(entry).To(Equal( + libcnb.BOMEntry{ + Name: filepath.Base("helper"), + Metadata: map[string]interface{}{ + "layer": "helper", + "names": []string{"test-name-1", "test-name-2"}, + "version": "test-version", + }, + Launch: true, + Build: false, + }, + )) }) }) @@ -366,9 +466,12 @@ func testLayer(t *testing.T, context spec.G, it spec.S) { file = filepath.Join(file, "helper") Expect(ioutil.WriteFile(file, []byte{}, 0755)).To(Succeed()) - hlc.Path = file - hlc.LayerContributor.ExpectedMetadata = buildpack.Info - hlc.Names = []string{"test-name-1", "test-name-2"} + hlc = libpak.HelperLayerContributor{ + Path: file, + BuildpackInfo: buildpack.Info, + Logger: bard.Logger{}, + Names: []string{"test-name-1", "test-name-2"}, + } }) it.After(func() { @@ -395,19 +498,6 @@ func testLayer(t *testing.T, context spec.G, it spec.S) { file = filepath.Join(layer.Exec.FilePath("test-name-2")) Expect(file).To(BeAnExistingFile()) Expect(os.Readlink(file)).To(Equal(filepath.Join(layer.Path, "helper"))) - - Expect(layer.Profile["helper"]).To(Equal(fmt.Sprintf(`exec 4<&1 -for_export=$(%s 3>&1 >&4) || exit $? -exec 4<&- -set -a -eval "$for_export" -set +a -exec 4<&1 -for_export=$(%s 3>&1 >&4) || exit $? -exec 4<&- -set -a -eval "$for_export" -set +a`, layer.Exec.FilePath("test-name-1"), layer.Exec.FilePath("test-name-2")))) }) it("does not call function with matching metadata", func() { @@ -438,20 +528,5 @@ set +a`, layer.Exec.FilePath("test-name-1"), layer.Exec.FilePath("test-name-2")) "clear-env": buildpack.Info.ClearEnvironment, })) }) - - it("contributes to buildpack plan", func() { - plan := libcnb.BuildpackPlan{} - - _ = libpak.NewHelperLayerContributor(buildpack, &plan, "test-name-1", "test-name-2") - - Expect(plan.Entries).To(ContainElement(libcnb.BuildpackPlanEntry{ - Name: filepath.Base("helper"), - Metadata: map[string]interface{}{ - "layer": "helper", - "names": []string{"test-name-1", "test-name-2"}, - "version": buildpack.Info.Version, - }, - })) - }) }) } diff --git a/main_test.go b/main_test.go index 9e5ba78..a4ffd63 100644 --- a/main_test.go +++ b/main_test.go @@ -66,7 +66,7 @@ func testMain(t *testing.T, context spec.G, it spec.S) { Expect(ioutil.WriteFile(filepath.Join(buildpackPath, "buildpack.toml"), []byte(` -api = "0.0.0" +api = "0.5" [buildpack] id = "test-id"