diff --git a/README.md b/README.md index 6213c7a..e74044b 100644 --- a/README.md +++ b/README.md @@ -130,15 +130,15 @@ the `BP_NODE_PROJECT_PATH` environment variable at build time either directly file](https://github.com/buildpacks/spec/blob/main/extensions/project-descriptor.md). This could be useful if your app is a part of a monorepo. -### Setting explicitly a run image `BP_NODE_RUN_EXTENSION` +### Setting explicitly a run image `BP_UBI_RUN_IMAGE_OVERRIDE` -With `BP_NODE_RUN_EXTENSION` environment variable, you are able to specify the run image of the built application, without changing the source code of the extension (specifically the extension.toml file) as shown on below example. +With `BP_UBI_RUN_IMAGE_OVERRIDE` environment variable, you are able to specify the run image of the built application, without changing the source code of the extension (specifically the extension.toml file) as shown on below example. ```bash pack build test-app-name \ --path ./app-dir \ --builder paketocommunity/builder-ubi-base \ - --env BP_NODE_RUN_EXTENSION="localhost:5000/my-run-image" + --env BP_UBI_RUN_IMAGE_OVERRIDE="localhost:5000/my-run-image" ``` ## Run Tests diff --git a/generate.go b/generate.go index c2aa062..f9d66b6 100644 --- a/generate.go +++ b/generate.go @@ -81,11 +81,11 @@ func Generate(dependencyManager DependencyManager, logger scribe.Emitter, during var selectedNodeRunImage string - bpNodeRunExtension, bpNodeRunExtensionEnvExists := os.LookupEnv("BP_NODE_RUN_EXTENSION") + bpNodeRunExtension, bpNodeRunExtensionEnvExists := os.LookupEnv("BP_UBI_RUN_IMAGE_OVERRIDE") if !bpNodeRunExtensionEnvExists || bpNodeRunExtension == "" { selectedNodeRunImage = dependency.Source } else { - logger.Process("Using run image specified by BP_NODE_RUN_EXTENSION %s", bpNodeRunExtension) + logger.Process("Using run image specified by BP_UBI_RUN_IMAGE_OVERRIDE %s", bpNodeRunExtension) selectedNodeRunImage = bpNodeRunExtension } diff --git a/generate_test.go b/generate_test.go index 4c46420..c3ae76d 100644 --- a/generate_test.go +++ b/generate_test.go @@ -846,7 +846,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { }) }, spec.Sequential()) - context("When BP_NODE_RUN_EXTENSION env has been set", func() { + context("When BP_UBI_RUN_IMAGE_OVERRIDE env has been set", func() { it.Before(func() { @@ -871,7 +871,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { Expect(os.RemoveAll(workingDir)).To(Succeed()) }) - it("Should have the same value as the BP_NODE_RUN_EXTENSION if is not empty string", func() { + it("Should have the same value as the BP_UBI_RUN_IMAGE_OVERRIDE if is not empty string", func() { extensionToml, _ := readExtensionTomlTemplateFile() @@ -880,8 +880,8 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { Expect(os.WriteFile(cnbDir+"/extension.toml", []byte(extensionToml), 0600)).To(Succeed()) entriesTests := []struct { - Entries []packit.BuildpackPlanEntry - BP_NODE_RUN_EXTENSION string + Entries []packit.BuildpackPlanEntry + BP_UBI_RUN_IMAGE_OVERRIDE string }{ { Entries: []packit.BuildpackPlanEntry{ @@ -890,12 +890,12 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { Metadata: map[string]interface{}{"version": ">0", "version-source": ".node-version"}, }, }, - BP_NODE_RUN_EXTENSION: "testregistry/image-name", + BP_UBI_RUN_IMAGE_OVERRIDE: "testregistry/image-name", }, } for _, tt := range entriesTests { - t.Setenv("BP_NODE_RUN_EXTENSION", tt.BP_NODE_RUN_EXTENSION) + t.Setenv("BP_UBI_RUN_IMAGE_OVERRIDE", tt.BP_UBI_RUN_IMAGE_OVERRIDE) generateResult, err = generate(packit.GenerateContext{ WorkingDir: workingDir, @@ -910,7 +910,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { Expect(generateResult).NotTo(Equal(nil)) RunDockerfileProps := ubinodejsextension.RunDockerfileProps{ - Source: tt.BP_NODE_RUN_EXTENSION, + Source: tt.BP_UBI_RUN_IMAGE_OVERRIDE, } runDockerfileContent, _ := ubinodejsextension.FillPropsToTemplate(RunDockerfileProps, runDockerfileTemplate) @@ -930,9 +930,9 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { Expect(os.WriteFile(cnbDir+"/extension.toml", []byte(extensionToml), 0600)).To(Succeed()) entriesTests := []struct { - Entries []packit.BuildpackPlanEntry - selectedNodeVersion int - BP_NODE_RUN_EXTENSION string + Entries []packit.BuildpackPlanEntry + selectedNodeVersion int + BP_UBI_RUN_IMAGE_OVERRIDE string }{ { Entries: []packit.BuildpackPlanEntry{ @@ -941,13 +941,13 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { Metadata: map[string]interface{}{"version": "16.*", "version-source": ".node-version"}, }, }, - selectedNodeVersion: 16, - BP_NODE_RUN_EXTENSION: "", + selectedNodeVersion: 16, + BP_UBI_RUN_IMAGE_OVERRIDE: "", }, } for _, tt := range entriesTests { - t.Setenv("BP_NODE_RUN_EXTENSION", tt.BP_NODE_RUN_EXTENSION) + t.Setenv("BP_UBI_RUN_IMAGE_OVERRIDE", tt.BP_UBI_RUN_IMAGE_OVERRIDE) generateResult, err = generate(packit.GenerateContext{ WorkingDir: workingDir, diff --git a/integration/fetch_run_image_from_env.go b/integration/fetch_run_image_from_env.go index a703803..fea1258 100644 --- a/integration/fetch_run_image_from_env.go +++ b/integration/fetch_run_image_from_env.go @@ -46,8 +46,8 @@ func testFetchRunImageFromEnv(t *testing.T, context spec.G, it spec.S) { Expect(os.RemoveAll(source)).To(Succeed()) }) - context("when BP_NODE_RUN_EXTENSION is set", func() { - it("uses the run image specified from the BP_NODE_RUN_EXTENSION", func() { + context("when BP_UBI_RUN_IMAGE_OVERRIDE is set", func() { + it("uses the run image specified from the BP_UBI_RUN_IMAGE_OVERRIDE", func() { var err error source, err = occam.Source(filepath.Join("testdata", "simple_app")) Expect(err).NotTo(HaveOccurred()) @@ -71,7 +71,7 @@ func testFetchRunImageFromEnv(t *testing.T, context spec.G, it spec.S) { settings.Buildpacks.NodeEngine.Online, settings.Buildpacks.Processes.Online, ). - WithEnv(map[string]string{"BP_NODE_RUN_EXTENSION": nodeRunImage, "BP_NODE_VERSION": fmt.Sprint(buildNodeMajorVersion)}). + WithEnv(map[string]string{"BP_UBI_RUN_IMAGE_OVERRIDE": nodeRunImage, "BP_NODE_VERSION": fmt.Sprint(buildNodeMajorVersion)}). WithPullPolicy("always"). Execute(name, source) @@ -82,7 +82,7 @@ func testFetchRunImageFromEnv(t *testing.T, context spec.G, it spec.S) { Expect(logs).To(ContainLines(" Candidate version sources (in priority order):")) Expect(logs).To(ContainLines(fmt.Sprintf(" BP_NODE_VERSION -> \"%d\"", buildNodeMajorVersion))) Expect(logs).To(ContainLines(" -> \"\"")) - Expect(logs).To(ContainLines(fmt.Sprintf(" Using run image specified by BP_NODE_RUN_EXTENSION %s", nodeRunImage))) + Expect(logs).To(ContainLines(fmt.Sprintf(" Using run image specified by BP_UBI_RUN_IMAGE_OVERRIDE %s", nodeRunImage))) Expect(logs).To(ContainLines( "[extender (build)] Enabling module streams:",