From aed085dae750317baf5ad360aac74735687ebb2e Mon Sep 17 00:00:00 2001 From: dwillist Date: Tue, 2 Feb 2021 15:51:49 -0500 Subject: [PATCH 1/3] add platform api 0.6 support to enable new lifecycle features Signed-off-by: dwillist --- .../testdata/pack_fixtures/report_output.txt | 2 +- internal/build/lifecycle_execution.go | 3 +- internal/build/lifecycle_execution_test.go | 75 ++++++++++++++++++- internal/build/lifecycle_executor.go | 2 + 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/acceptance/testdata/pack_fixtures/report_output.txt b/acceptance/testdata/pack_fixtures/report_output.txt index 23877a937..a1821820c 100644 --- a/acceptance/testdata/pack_fixtures/report_output.txt +++ b/acceptance/testdata/pack_fixtures/report_output.txt @@ -4,7 +4,7 @@ Pack: Default Lifecycle Version: 0.10.2 -Supported Platform APIs: 0.3, 0.4 +Supported Platform APIs: 0.3, 0.4, 0.5, 0.6 Config: default-builder-image = "{{ .DefaultBuilder }}" diff --git a/internal/build/lifecycle_execution.go b/internal/build/lifecycle_execution.go index e307dd204..ad665bbd1 100644 --- a/internal/build/lifecycle_execution.go +++ b/internal/build/lifecycle_execution.go @@ -399,7 +399,8 @@ func (l *LifecycleExecution) Build(ctx context.Context, networkMode string, volu } func determineDefaultProcessType(platformAPI *api.Version, providedValue string) string { - shouldSetForceDefault := platformAPI.Compare(api.MustParse("0.4")) >= 0 + shouldSetForceDefault := platformAPI.Compare(api.MustParse("0.4")) >= 0 && + platformAPI.Compare(api.MustParse("0.6")) < 0 if providedValue == "" && shouldSetForceDefault { return defaultProcessType } diff --git a/internal/build/lifecycle_execution_test.go b/internal/build/lifecycle_execution_test.go index 2ec26cb3b..bd05a778a 100644 --- a/internal/build/lifecycle_execution_test.go +++ b/internal/build/lifecycle_execution_test.go @@ -64,11 +64,12 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { api.MustParse("0.3"), api.MustParse("0.4"), api.MustParse("0.5"), + api.MustParse("0.6"), })) h.AssertNil(t, err) lifecycleExec := newTestLifecycleExec(t, false, fakes.WithBuilder(fakeBuilder)) - h.AssertEq(t, lifecycleExec.PlatformAPI().String(), "0.4") + h.AssertEq(t, lifecycleExec.PlatformAPI().String(), "0.6") }) }) @@ -630,6 +631,24 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { h.AssertIncludeAllExpectedPatterns(t, configProvider.ContainerConfig().Cmd, []string{"-process-type", "web"}) }) }) + + when("platform >= 0.6", func() { + it("doesn't hint at default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() + + err = lifecycle.Export(context.Background(), "test", "test", true, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) + + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) + + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) + }) }) when("publish is false", func() { @@ -767,6 +786,24 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { h.AssertIncludeAllExpectedPatterns(t, configProvider.ContainerConfig().Cmd, []string{"-process-type", "web"}) }) }) + + when("platform >= 0.6", func() { + it("doesn't hint at default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() + + err = lifecycle.Export(context.Background(), "test", "test", false, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) + + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) + + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) + }) }) }) @@ -1693,6 +1730,24 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { h.AssertIncludeAllExpectedPatterns(t, configProvider.ContainerConfig().Cmd, []string{"-process-type", "web"}) }) }) + + when("platform >= 0.6", func() { + it("doesn't hint at default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() + + err = lifecycle.Export(context.Background(), "test", "test", true, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) + + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) + + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) + }) }) when("publish is false", func() { @@ -1863,6 +1918,24 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { h.AssertIncludeAllExpectedPatterns(t, configProvider.ContainerConfig().Cmd, []string{"-process-type", "web"}) }) }) + + when("platform >= 0.6", func() { + it("doesn't hint at default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() + + err = lifecycle.Export(context.Background(), "test", "test", false, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) + + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) + + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) + }) }) }) } diff --git a/internal/build/lifecycle_executor.go b/internal/build/lifecycle_executor.go index f73a48445..d3bc43d6d 100644 --- a/internal/build/lifecycle_executor.go +++ b/internal/build/lifecycle_executor.go @@ -21,6 +21,8 @@ var ( SupportedPlatformAPIVersions = builder.APISet{ api.MustParse("0.3"), api.MustParse("0.4"), + api.MustParse("0.5"), + api.MustParse("0.6"), } ) From ce353f9c00a0e18e0c9f93f8ed39a962d2a130e2 Mon Sep 17 00:00:00 2001 From: dwillist Date: Tue, 2 Feb 2021 15:52:04 -0500 Subject: [PATCH 2/3] formatting updates Signed-off-by: dwillist --- doc_test.go | 4 ++-- go.sum | 1 + internal/build/container_ops.go | 12 ++++++------ internal/commands/config_experimental_test.go | 4 ++-- internal/commands/config_registries_default.go | 2 +- .../commands/config_run_image_mirrors_test.go | 2 +- internal/dist/buildpack_descriptor.go | 2 +- internal/image/fetcher.go | 2 +- internal/paths/paths.go | 18 +++++++++--------- testhelpers/tar_assertions.go | 2 +- 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/doc_test.go b/doc_test.go index 66b5d6147..7cccb74ec 100644 --- a/doc_test.go +++ b/doc_test.go @@ -11,10 +11,10 @@ import ( // This example shows the basic usage of the package: Create a client, // call a configuration object, call the client's Build function. func Example_build() { - //create a context object + // create a context object context := context.Background() - //initialize a pack client + // initialize a pack client client, err := pack.NewClient() if err != nil { panic(err) diff --git a/go.sum b/go.sum index f38d1c287..0b4420ecb 100644 --- a/go.sum +++ b/go.sum @@ -777,6 +777,7 @@ golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3 h1:DywqrEscRX7O2phNjkT0L6lhHKGBoMLCNX+XcAe7t6s= golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/build/container_ops.go b/internal/build/container_ops.go index d0ae10f44..8cda1fc81 100644 --- a/internal/build/container_ops.go +++ b/internal/build/container_ops.go @@ -92,7 +92,7 @@ func copyDirWindows(ctx context.Context, ctrClient client.CommonAPIClient, conta "cmd", "/c", - //xcopy args + // xcopy args // e - recursively create subdirectories // h - copy hidden and system files // b - copy symlinks, do not dereference @@ -184,10 +184,10 @@ func createReader(src, dst string, uid, gid int, fileFilter func(string) bool) ( return archive.ReadZipAsTar(src, dst, uid, gid, -1, false, fileFilter), nil } -//EnsureVolumeAccess grants full access permissions to volumes for UID/GID-based user -//When UID/GID are 0 it grants explicit full access to BUILTIN\Administrators and any other UID/GID grants full access to BUILTIN\Users -//Changing permissions on volumes through stopped containers does not work on Docker for Windows so we start the container and make change using icacls -//See: https://github.com/moby/moby/issues/40771 +// EnsureVolumeAccess grants full access permissions to volumes for UID/GID-based user +// When UID/GID are 0 it grants explicit full access to BUILTIN\Administrators and any other UID/GID grants full access to BUILTIN\Users +// Changing permissions on volumes through stopped containers does not work on Docker for Windows so we start the container and make change using icacls +// See: https://github.com/moby/moby/issues/40771 func EnsureVolumeAccess(uid, gid int, os string, volumeNames ...string) ContainerOperation { return func(ctrClient client.CommonAPIClient, ctx context.Context, containerID string, stdout, stderr io.Writer) error { if os != "windows" { @@ -209,7 +209,7 @@ func EnsureVolumeAccess(uid, gid int, os string, volumeNames ...string) Containe cmd += "&&" } - //icacls args + // icacls args // /grant - add new permissions instead of replacing // (OI) - object inherit // (CI) - container inherit diff --git a/internal/commands/config_experimental_test.go b/internal/commands/config_experimental_test.go index fba05ad92..b845668ff 100644 --- a/internal/commands/config_experimental_test.go +++ b/internal/commands/config_experimental_test.go @@ -94,8 +94,8 @@ func testConfigExperimental(t *testing.T, when spec.G, it spec.S) { it("returns error if invalid value provided", func() { cmd.SetArgs([]string{"disable-me"}) h.AssertError(t, cmd.Execute(), fmt.Sprintf("invalid value %s provided", style.Symbol("disable-me"))) - //output := outBuf.String() - //h.AssertContains(t, output, "Experimental features disabled.") + // output := outBuf.String() + // h.AssertContains(t, output, "Experimental features disabled.") cfg, err := config.Read(configPath) h.AssertNil(t, err) h.AssertEq(t, cfg.Experimental, false) diff --git a/internal/commands/config_registries_default.go b/internal/commands/config_registries_default.go index e99069e32..e60f5bc17 100644 --- a/internal/commands/config_registries_default.go +++ b/internal/commands/config_registries_default.go @@ -39,7 +39,7 @@ func ConfigRegistriesDefault(logger logging.Logger, cfg config.Config, cfgPath s } logger.Infof("Successfully unset default registry %s", style.Symbol(oldRegistry)) logger.Infof("Default registry has been set to %s", style.Symbol(config.OfficialRegistryName)) - case len(args) == 0: //list + case len(args) == 0: // list if cfg.DefaultRegistryName == "" { cfg.DefaultRegistryName = config.OfficialRegistryName } diff --git a/internal/commands/config_run_image_mirrors_test.go b/internal/commands/config_run_image_mirrors_test.go index 6c7031893..2d5fcd8fb 100644 --- a/internal/commands/config_run_image_mirrors_test.go +++ b/internal/commands/config_run_image_mirrors_test.go @@ -121,7 +121,7 @@ func testConfigRunImageMirrorsCommand(t *testing.T, when spec.G, it spec.S) { cfg, err := config.Read(configPath) h.AssertNil(t, err) h.AssertEq(t, cfg, testCfg) - //This ensures that there are no dups + // This ensures that there are no dups h.AssertEq(t, len(cfg.RunImages[0].Mirrors), 2) }) }) diff --git a/internal/dist/buildpack_descriptor.go b/internal/dist/buildpack_descriptor.go index 4b95454ff..de9fa8149 100644 --- a/internal/dist/buildpack_descriptor.go +++ b/internal/dist/buildpack_descriptor.go @@ -19,7 +19,7 @@ type BuildpackDescriptor struct { } func (b *BuildpackDescriptor) EscapedID() string { - return strings.Replace(b.Info.ID, "/", "_", -1) + return strings.ReplaceAll(b.Info.ID, "/", "_") } func (b *BuildpackDescriptor) EnsureStackSupport(stackID string, providedMixins []string, validateRunStageMixins bool) error { diff --git a/internal/image/fetcher.go b/internal/image/fetcher.go index e9465ea01..fdbffc2f0 100644 --- a/internal/image/fetcher.go +++ b/internal/image/fetcher.go @@ -161,7 +161,7 @@ func (w *colorizedWriter) Write(p []byte) (n int, err error) { ">": style.ProgressBar, } for pattern, colorize := range colorizers { - msg = strings.Replace(msg, pattern, colorize(pattern), -1) + msg = strings.ReplaceAll(msg, pattern, colorize(pattern)) } return w.writer.Write([]byte(msg)) } diff --git a/internal/paths/paths.go b/internal/paths/paths.go index dfef3a2e1..f78695622 100644 --- a/internal/paths/paths.go +++ b/internal/paths/paths.go @@ -90,14 +90,14 @@ func FilterReservedNames(p string) string { "prn": "p_r_n", } for k, v := range reservedNameConversions { - p = strings.Replace(p, k, v, -1) + p = strings.ReplaceAll(p, k, v) } return p } -//WindowsDir is equivalent to path.Dir or filepath.Dir but always for Windows paths -//reproduced because Windows implementation is not exported +// WindowsDir is equivalent to path.Dir or filepath.Dir but always for Windows paths +// reproduced because Windows implementation is not exported func WindowsDir(p string) string { pathElements := strings.Split(p, `\`) @@ -106,16 +106,16 @@ func WindowsDir(p string) string { return dirName } -//WindowsBasename is equivalent to path.Basename or filepath.Basename but always for Windows paths -//reproduced because Windows implementation is not exported +// WindowsBasename is equivalent to path.Basename or filepath.Basename but always for Windows paths +// reproduced because Windows implementation is not exported func WindowsBasename(p string) string { pathElements := strings.Split(p, `\`) return pathElements[len(pathElements)-1] } -//WindowsToSlash is equivalent to path.ToSlash or filepath.ToSlash but always for Windows paths -//reproduced because Windows implementation is not exported +// WindowsToSlash is equivalent to path.ToSlash or filepath.ToSlash but always for Windows paths +// reproduced because Windows implementation is not exported func WindowsToSlash(p string) string { slashPath := strings.ReplaceAll(p, `\`, "/") // convert slashes if len(slashPath) < 2 { @@ -125,8 +125,8 @@ func WindowsToSlash(p string) string { return slashPath[2:] // strip volume } -//WindowsPathSID returns the appropriate SID for a given UID and GID -//This the basic logic for path permissions in Pack and Lifecycle +// WindowsPathSID returns the appropriate SID for a given UID and GID +// This the basic logic for path permissions in Pack and Lifecycle func WindowsPathSID(uid, gid int) string { if uid == 0 && gid == 0 { return "S-1-5-32-544" // BUILTIN\Administrators diff --git a/testhelpers/tar_assertions.go b/testhelpers/tar_assertions.go index ae01d4031..b01845ec4 100644 --- a/testhelpers/tar_assertions.go +++ b/testhelpers/tar_assertions.go @@ -81,7 +81,7 @@ func isGzipped(reader io.Reader) (headerBytes []byte, isGzipped bool, err error) return magicHeader, false, err } // This assertion is based on https://stackoverflow.com/a/28332019. It checks whether the two header bytes of - //the file match the expected headers for a gzip file; the first one is 0x1f and the second is 0x8b + // the file match the expected headers for a gzip file; the first one is 0x1f and the second is 0x8b return magicHeader, bytes.Equal(magicHeader, gzipMagicHeader), nil } From e01b67310f6b4dee5217555d86338e031aa21401 Mon Sep 17 00:00:00 2001 From: dwillist Date: Fri, 14 May 2021 00:52:34 -0400 Subject: [PATCH 3/3] update testing and resolve branch updates Signed-off-by: dwillist --- internal/build/lifecycle_execution_test.go | 96 ++++++++++++---------- internal/commands/buildpack_new_test.go | 2 +- 2 files changed, 53 insertions(+), 45 deletions(-) diff --git a/internal/build/lifecycle_execution_test.go b/internal/build/lifecycle_execution_test.go index 81231cf7a..0af28eecb 100644 --- a/internal/build/lifecycle_execution_test.go +++ b/internal/build/lifecycle_execution_test.go @@ -527,20 +527,22 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { }) when("platform >= 0.6", func() { - it("doesn't hint at default process type", func() { - fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) - h.AssertNil(t, err) - lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) - fakePhaseFactory := fakes.NewFakePhaseFactory() + when("no user provided process type is present", func() { + it("doesn't provide 'web' as default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() - err = lifecycle.Export(context.Background(), "test", "test", true, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) - h.AssertNil(t, err) + err = lifecycle.Export(context.Background(), "test", "test", true, "", "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) - lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 - h.AssertNotEq(t, lastCallIndex, -1) + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) - configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] - h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) }) }) }) @@ -734,20 +736,22 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { }) when("platform >= 0.6", func() { - it("doesn't hint at default process type", func() { - fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) - h.AssertNil(t, err) - lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) - fakePhaseFactory := fakes.NewFakePhaseFactory() + when("no user provided process type is present", func() { + it("doesn't provide 'web' as default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() - err = lifecycle.Export(context.Background(), "test", "test", false, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) - h.AssertNil(t, err) + err = lifecycle.Export(context.Background(), "test", "test", false, "", "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) - lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 - h.AssertNotEq(t, lastCallIndex, -1) + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) - configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] - h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) }) }) }) @@ -1681,20 +1685,22 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { }) when("platform >= 0.6", func() { - it("doesn't hint at default process type", func() { - fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) - h.AssertNil(t, err) - lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) - fakePhaseFactory := fakes.NewFakePhaseFactory() + when("no user provided process type is present", func() { + it("doesn't provide 'web' as default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() - err = lifecycle.Export(context.Background(), "test", "test", true, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) - h.AssertNil(t, err) + err = lifecycle.Export(context.Background(), "test", "test", true, "", "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) - lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 - h.AssertNotEq(t, lastCallIndex, -1) + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) - configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] - h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) }) }) }) @@ -1884,20 +1890,22 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { }) when("platform >= 0.6", func() { - it("doesn't hint at default process type", func() { - fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) - h.AssertNil(t, err) - lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) - fakePhaseFactory := fakes.NewFakePhaseFactory() + when("no user provided process type is present", func() { + it("doesn't provide 'web' as default process type", func() { + fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithSupportedPlatformAPIs([]*api.Version{api.MustParse("0.6")})) + h.AssertNil(t, err) + lifecycle := newTestLifecycleExec(t, true, fakes.WithBuilder(fakeBuilder)) + fakePhaseFactory := fakes.NewFakePhaseFactory() - err = lifecycle.Export(context.Background(), "test", "test", false, "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) - h.AssertNil(t, err) + err = lifecycle.Export(context.Background(), "test", "test", false, "", "test", fakeBuildCache, fakeLaunchCache, []string{}, fakePhaseFactory) + h.AssertNil(t, err) - lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 - h.AssertNotEq(t, lastCallIndex, -1) + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) - configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] - h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) }) }) }) diff --git a/internal/commands/buildpack_new_test.go b/internal/commands/buildpack_new_test.go index 8ff115ab4..f6bc668bc 100644 --- a/internal/commands/buildpack_new_test.go +++ b/internal/commands/buildpack_new_test.go @@ -57,7 +57,7 @@ func testBuildpackNewCommand(t *testing.T, when spec.G, it spec.S) { when("BuildpackNew#Execute", func() { it("uses the args to generate artifacts", func() { mockClient.EXPECT().NewBuildpack(gomock.Any(), pack.NewBuildpackOptions{ - API: "0.4", + API: "0.6", ID: "example/some-cnb", Path: filepath.Join(tmpDir, "some-cnb"), Version: "1.0.0",