diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index da19ad6fd..7e51324d2 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -1551,6 +1551,44 @@ func testAcceptance( assertBuildpackOutput := assertions.NewTestBuildpackOutputAssertionManager(t, output) assertBuildpackOutput.ReportsBuildStep("Simple Layers Buildpack") }) + + when("buildpackage is in a registry", func() { + it("adds the buildpacks to the builder and runs them", func() { + packageImageName = registryConfig.RepoName("buildpack-" + h.RandString(8)) + + packageTomlPath := generatePackageTomlWithOS(t, assert, pack, tmpDir, "package_for_build_cmd.toml", imageManager.HostOS()) + packageImage := buildpacks.NewPackageImage( + t, + pack, + packageImageName, + packageTomlPath, + buildpacks.WithRequiredBuildpacks( + buildpacks.BpFolderSimpleLayersParent, + buildpacks.BpFolderSimpleLayers, + ), + buildpacks.WithPublish(), + ) + + buildpackManager.PrepareBuildModules(tmpDir, packageImage) + + output := pack.RunSuccessfully( + "build", repoName, + "-p", filepath.Join("testdata", "mock_app"), + "--buildpack", packageImageName, + ) + + assertOutput := assertions.NewOutputAssertionManager(t, output) + assertOutput.ReportsAddingBuildpack( + "simple/layers/parent", + "simple-layers-parent-version", + ) + assertOutput.ReportsAddingBuildpack("simple/layers", "simple-layers-version") + assertOutput.ReportsSuccessfulImageBuild(repoName) + + assertBuildpackOutput := assertions.NewTestBuildpackOutputAssertionManager(t, output) + assertBuildpackOutput.ReportsBuildStep("Simple Layers Buildpack") + }) + }) }) when("the argument is a buildpackage file", func() { diff --git a/pkg/image/fetcher.go b/pkg/image/fetcher.go index 3835b0bd3..60548fcc1 100644 --- a/pkg/image/fetcher.go +++ b/pkg/image/fetcher.go @@ -82,7 +82,6 @@ func NewFetcher(logger logging.Logger, docker DockerClient, opts ...FetcherOptio } var ErrNotFound = errors.New("not found") -var ErrPlatformNotMatch = errors.New("platform does not match") func (f *Fetcher) Fetch(ctx context.Context, name string, options FetchOptions) (imgutil.Image, error) { name, err := pname.TranslateRegistry(name, f.registryMirrors, f.logger) @@ -110,10 +109,12 @@ func (f *Fetcher) Fetch(ctx context.Context, name string, options FetchOptions) } f.logger.Debugf("Pulling image %s", style.Symbol(name)) - err = f.pullImage(ctx, name, options.Platform) - if errors.Is(err, ErrPlatformNotMatch) { - f.logger.Info(err.Error()) - err = f.pullImage(ctx, name, "") + if err = f.pullImage(ctx, name, options.Platform); err != nil { + // sample error from docker engine: + // image with reference was found but does not match the specified platform: wanted linux/amd64, actual: linux + if strings.Contains(err.Error(), "does not match the specified platform") { + err = f.pullImage(ctx, name, "") + } } if err != nil && !errors.Is(err, ErrNotFound) { return nil, err @@ -197,11 +198,6 @@ func (f *Fetcher) pullImage(ctx context.Context, imageID string, platform string err = jsonmessage.DisplayJSONMessagesStream(rc, &colorizedWriter{writer}, termFd, isTerm, nil) if err != nil { - // sample error from docker engine: - // image with reference was found but does not match the specified platform: wanted linux/amd64, actual: linux - if strings.Contains(err.Error(), "does not match the specified platform") { - return errors.Wrap(ErrPlatformNotMatch, err.Error()) - } return err }