diff --git a/acceptance/testdata/pack_fixtures/report_output.txt b/acceptance/testdata/pack_fixtures/report_output.txt index 35218b27fd..3dc375b5b8 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.11.3 -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/doc_test.go b/doc_test.go index 75a5f519c9..49e9306287 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.mod b/go.mod index a3a2f46858..fb913f03f9 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,10 @@ require ( github.com/buildpacks/lifecycle v0.11.3 github.com/containerd/containerd v1.4.1 // indirect github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 // indirect - github.com/docker/docker v20.10.6+incompatible + github.com/docker/docker v20.10.7+incompatible github.com/docker/go-connections v0.4.0 github.com/ghodss/yaml v1.0.0 - github.com/golang/mock v1.5.0 + github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.5.6 github.com/google/go-containerregistry v0.5.1 github.com/google/go-github/v30 v30.1.0 @@ -25,7 +25,7 @@ require ( github.com/opencontainers/image-spec v1.0.1 github.com/opencontainers/runc v0.1.1 // indirect github.com/opencontainers/selinux v1.6.0 // indirect - github.com/pelletier/go-toml v1.9.1 + github.com/pelletier/go-toml v1.9.3 github.com/pkg/errors v0.9.1 github.com/sabhiram/go-gitignore v0.0.0-20201211074657-223ce5d391b0 github.com/sclevine/spec v1.4.0 diff --git a/go.sum b/go.sum index 7c9ff7c817..1b246e3b97 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/docker/cli v0.0.0-20200312141509-ef2f64abbd37/go.mod h1:JLrzqnKDaYBop github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v20.10.6+incompatible h1:oXI3Vas8TI8Eu/EjH4srKHJBVqraSzJybhxY7Om9faQ= -github.com/docker/docker v20.10.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v20.10.7+incompatible h1:Z6O9Nhsjv+ayUEeI1IojKbYcsGdgYSNqxe1s2MYzUhQ= +github.com/docker/docker v20.10.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3 h1:zI2p9+1NQYdnG6sMU26EX4aVGlqbInSQxQXLvzJ4RPQ= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -183,8 +183,9 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -378,8 +379,8 @@ github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqi github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.1 h1:a6qW1EVNZWH9WGI6CsYdD8WAylkoXBS5yv0XHlh17Tc= -github.com/pelletier/go-toml v1.9.1/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= +github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -474,6 +475,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -561,6 +563,7 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -578,8 +581,9 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -626,8 +630,10 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -686,6 +692,7 @@ golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 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= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/build/container_ops.go b/internal/build/container_ops.go index fdc842e71f..2e6948eae1 100644 --- a/internal/build/container_ops.go +++ b/internal/build/container_ops.go @@ -93,7 +93,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 @@ -185,10 +185,10 @@ func createReader(src, dst string, uid, gid int, includeRoot bool, fileFilter fu 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" { @@ -210,7 +210,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/build/lifecycle_execution.go b/internal/build/lifecycle_execution.go index 577a983a13..b89e4b8396 100644 --- a/internal/build/lifecycle_execution.go +++ b/internal/build/lifecycle_execution.go @@ -410,7 +410,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 89f4462de3..11d6271d32 100644 --- a/internal/build/lifecycle_execution_test.go +++ b/internal/build/lifecycle_execution_test.go @@ -65,11 +65,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") }) }) @@ -566,6 +567,26 @@ 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() { + 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) + + 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() { @@ -755,6 +776,26 @@ 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() { + 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) + + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) + + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) + }) + }) }) when("override GID", func() { @@ -1912,6 +1953,26 @@ 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() { + 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) + + 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() { @@ -2097,6 +2158,26 @@ 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() { + 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) + + lastCallIndex := len(fakePhaseFactory.NewCalledWithProvider) - 1 + h.AssertNotEq(t, lastCallIndex, -1) + + configProvider := fakePhaseFactory.NewCalledWithProvider[lastCallIndex] + h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-process-type") + }) + }) + }) }) when("override GID", func() { diff --git a/internal/build/lifecycle_executor.go b/internal/build/lifecycle_executor.go index f2229cf906..59edbcf289 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"), } ) diff --git a/internal/commands/buildpack_new_test.go b/internal/commands/buildpack_new_test.go index 8ff115ab44..f6bc668bc9 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", diff --git a/internal/commands/config_experimental_test.go b/internal/commands/config_experimental_test.go index fba05ad926..b845668ff0 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 e99069e32a..e60f5bc17d 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 6c7031893e..2d5fcd8fb2 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 4b95454ffa..de9fa8149d 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 ad54584c16..7955645265 100644 --- a/internal/image/fetcher.go +++ b/internal/image/fetcher.go @@ -152,7 +152,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 dfef3a2e18..f78695622a 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/internal/registry/registry_cache.go b/internal/registry/registry_cache.go index e317fd288b..c08b98dce0 100644 --- a/internal/registry/registry_cache.go +++ b/internal/registry/registry_cache.go @@ -187,7 +187,15 @@ func (r *Cache) CreateCache() error { return err } - return os.Rename(w.Filesystem.Root(), r.Root) + err = os.Rename(w.Filesystem.Root(), r.Root) + if err != nil { + if err == os.ErrExist { + // If pack is run concurrently, this action might have already occurred + return nil + } + return err + } + return nil } func (r *Cache) validateCache() error { diff --git a/testhelpers/tar_assertions.go b/testhelpers/tar_assertions.go index 2ebce6ab44..1de4442a44 100644 --- a/testhelpers/tar_assertions.go +++ b/testhelpers/tar_assertions.go @@ -82,7 +82,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 }