diff --git a/go.sum b/go.sum index f55571dd7..686709419 100644 --- a/go.sum +++ b/go.sum @@ -462,9 +462,8 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZABEali68eoMFhTZpCjYVA= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= -golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/internal/build/phases.go b/internal/build/phases.go index dbb5e05a4..3bc7d885e 100644 --- a/internal/build/phases.go +++ b/internal/build/phases.go @@ -7,8 +7,6 @@ import ( "github.com/Masterminds/semver" "github.com/buildpacks/lifecycle/auth" "github.com/google/go-containerregistry/pkg/authn" - - "github.com/buildpacks/pack/internal/api" ) const ( @@ -165,6 +163,12 @@ func (l *Lifecycle) newExport(repoName, runImage string, publish bool, launchCac binds := []string{fmt.Sprintf("%s:%s", cacheName, cacheDir)} + if l.DefaultProcessType != "" && l.supportsDefaultProcess() { + args = append([]string{"-process-type", l.DefaultProcessType}, args...) + } else { + l.logger.Warn("You specified a default process type but that is not supported by this version of the lifecycle") + } + if publish { authConfig, err := auth.BuildEnvVar(authn.DefaultKeychain, repoName, runImage) if err != nil { @@ -188,15 +192,6 @@ func (l *Lifecycle) newExport(repoName, runImage string, publish bool, launchCac args = append([]string{"-daemon", "-launch-cache", launchCacheDir}, args...) binds = append(binds, fmt.Sprintf("%s:%s", launchCacheName, launchCacheDir)) - if l.DefaultProcessType != "" { - supportsDefaultProcess := api.MustParse(l.platformAPIVersion).SupportsVersion(api.MustParse(defaultProcessPlatformAPI)) - if supportsDefaultProcess { - args = append([]string{"-process-type", l.DefaultProcessType}, args...) - } else { - l.logger.Warn("You specified a default process type but that is not supported by this version of the lifecycle") - } - } - configProvider := NewPhaseConfigProvider( "exporter", l, @@ -227,3 +222,9 @@ func (l *Lifecycle) exportImageArgs(runImage string) []string { } return []string{"-image", runImage} } + +func (l *Lifecycle) supportsDefaultProcess() bool { + apiVersion := semver.MustParse(l.platformAPIVersion) + defaultProcVersion := semver.MustParse(defaultProcessPlatformAPI) + return apiVersion.GreaterThan(defaultProcVersion) || apiVersion.Equal(defaultProcVersion) +} diff --git a/internal/build/phases_test.go b/internal/build/phases_test.go index ad57bc6f5..0961640d2 100644 --- a/internal/build/phases_test.go +++ b/internal/build/phases_test.go @@ -500,11 +500,19 @@ func testPhases(t *testing.T, when spec.G, it spec.S) { }) when("platform api 0.3+", func() { - it("uses -run-image instead of deprecated -image", func() { + var ( + fakeBuilder *fakes.FakeBuilder + err error + ) + + it.Before(func() { platformAPIVersion, err := api.NewVersion("0.3") h.AssertNil(t, err) - fakeBuilder, err := fakes.NewFakeBuilder(fakes.WithPlatformVersion(platformAPIVersion)) + fakeBuilder, err = fakes.NewFakeBuilder(fakes.WithPlatformVersion(platformAPIVersion)) h.AssertNil(t, err) + }) + + it("uses -run-image instead of deprecated -image", func() { lifecycle := fakeLifecycle(t, false, fakes.WithBuilder(fakeBuilder)) fakePhaseFactory := fakes.NewFakePhaseFactory() expectedRunImage := "some-run-image" @@ -519,6 +527,19 @@ func testPhases(t *testing.T, when spec.G, it spec.S) { []string{"-run-image", expectedRunImage}, ) }) + + it("configures the phase with default arguments", func() { + lifecycle := fakeLifecycle(t, true, fakes.WithBuilder(fakeBuilder), func(options *build.LifecycleOptions) { + options.DefaultProcessType = "test-process" + }) + fakePhaseFactory := fakes.NewFakePhaseFactory() + expectedDefaultProc := []string{"-process-type", "test-process"} + + err := lifecycle.Export(context.Background(), "test", "test", false, "test", "test", fakePhaseFactory) + h.AssertNil(t, err) + configProvider := fakePhaseFactory.NewCalledWithProvider + h.AssertIncludeAllExpectedPatterns(t, configProvider.ContainerConfig().Cmd, expectedDefaultProc) + }) }) }) } diff --git a/vendor/modules.txt b/vendor/modules.txt index fb1fbe59b..91096f129 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -12,14 +12,13 @@ github.com/Microsoft/go-winio/pkg/guid github.com/Microsoft/hcsshim/osversion # github.com/apex/log v1.1.2 github.com/apex/log -# github.com/buildpacks/imgutil v0.0.0-20200313170640-a02052f47d62 +# github.com/buildpacks/imgutil v0.0.0-20200424215026-dfdc82949704 github.com/buildpacks/imgutil -github.com/buildpacks/imgutil/archive github.com/buildpacks/imgutil/fakes github.com/buildpacks/imgutil/layer github.com/buildpacks/imgutil/local github.com/buildpacks/imgutil/remote -# github.com/buildpacks/lifecycle v0.7.1 +# github.com/buildpacks/lifecycle v0.7.2 github.com/buildpacks/lifecycle github.com/buildpacks/lifecycle/api github.com/buildpacks/lifecycle/archive @@ -194,6 +193,7 @@ github.com/src-d/gcfg/types # github.com/xanzy/ssh-agent v0.2.1 github.com/xanzy/ssh-agent # golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 +golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish golang.org/x/crypto/cast5 golang.org/x/crypto/chacha20