From e3047bbd1075e937892785c6d273c7893f3efdc1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:39:13 +0000 Subject: [PATCH] chore: bump github.com/buildpacks/pack from 0.36.3 to 0.36.4 Bumps [github.com/buildpacks/pack](https://github.com/buildpacks/pack) from 0.36.3 to 0.36.4. - [Release notes](https://github.com/buildpacks/pack/releases) - [Changelog](https://github.com/buildpacks/pack/blob/main/RELEASE.md) - [Commits](https://github.com/buildpacks/pack/compare/v0.36.3...v0.36.4) --- updated-dependencies: - dependency-name: github.com/buildpacks/pack dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- .../buildpacks/pack/internal/name/name.go | 24 +++++++++++++++++++ .../pack/pkg/client/create_builder.go | 20 +++++++++++++--- .../pack/pkg/client/package_buildpack.go | 15 +++++++++++- .../buildpacks/pack/pkg/image/fetcher.go | 7 +++--- vendor/modules.txt | 2 +- 7 files changed, 62 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 4be2c241d31..16d2b48604f 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/bmatcuk/doublestar v1.3.4 github.com/buildpacks/imgutil v0.0.0-20240605145725-186f89b2d168 github.com/buildpacks/lifecycle v0.20.5 - github.com/buildpacks/pack v0.36.3 + github.com/buildpacks/pack v0.36.4 github.com/cenkalti/backoff/v4 v4.3.0 github.com/containerd/containerd v1.7.25 github.com/distribution/reference v0.6.0 diff --git a/go.sum b/go.sum index ca5c806669b..c002b01258a 100644 --- a/go.sum +++ b/go.sum @@ -162,8 +162,8 @@ github.com/buildpacks/imgutil v0.0.0-20240605145725-186f89b2d168 h1:yVYVi1V7x1bX github.com/buildpacks/imgutil v0.0.0-20240605145725-186f89b2d168/go.mod h1:n2R6VRuWsAX3cyHCp/u0Z4WJcixny0gYg075J39owrk= github.com/buildpacks/lifecycle v0.20.5 h1:xgKKbex/H79B23PVyT6F5Ilj/3H9QeIZnd6aPNvA898= github.com/buildpacks/lifecycle v0.20.5/go.mod h1:ZsExeEhN+6Qws7iDHJl6PV6zsHycgK/RmDKnRgKQTH0= -github.com/buildpacks/pack v0.36.3 h1:4xiaPzDzJV/g3bkOvx+A/1fZcbX3xD3KG7Bzb0jG7Tc= -github.com/buildpacks/pack v0.36.3/go.mod h1:DUFJ5IFnHOtFf+K/wStELnn84kPwSTeMxteXyUJwlRg= +github.com/buildpacks/pack v0.36.4 h1:otHfS3Ju9TBRTz6LAScXSZw+BEw7BLTB0QPUtWPuiHg= +github.com/buildpacks/pack v0.36.4/go.mod h1:DUFJ5IFnHOtFf+K/wStELnn84kPwSTeMxteXyUJwlRg= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= diff --git a/vendor/github.com/buildpacks/pack/internal/name/name.go b/vendor/github.com/buildpacks/pack/internal/name/name.go index bac87b0386b..0ea67c585e2 100644 --- a/vendor/github.com/buildpacks/pack/internal/name/name.go +++ b/vendor/github.com/buildpacks/pack/internal/name/name.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/buildpacks/pack/pkg/dist" + gname "github.com/google/go-containerregistry/pkg/name" "github.com/buildpacks/pack/internal/style" @@ -49,6 +51,24 @@ func TranslateRegistry(name string, registryMirrors map[string]string, logger Lo return refName, nil } +func AppendSuffix(name string, target dist.Target) (string, error) { + reference, err := gname.ParseReference(name, gname.WeakValidation) + if err != nil { + return "", err + } + + suffixPlatformTag := targetToTag(target) + if suffixPlatformTag != "" { + if reference.Identifier() == "latest" { + return fmt.Sprintf("%s:%s", reference.Context(), suffixPlatformTag), nil + } + if !strings.Contains(reference.Identifier(), ":") { + return fmt.Sprintf("%s:%s-%s", reference.Context(), reference.Identifier(), suffixPlatformTag), nil + } + } + return name, nil +} + func getMirror(repo gname.Repository, registryMirrors map[string]string) (string, bool) { mirror, ok := registryMirrors["*"] if ok { @@ -58,3 +78,7 @@ func getMirror(repo gname.Repository, registryMirrors map[string]string) (string mirror, ok = registryMirrors[repo.RegistryStr()] return mirror, ok } + +func targetToTag(target dist.Target) string { + return strings.Join(target.ValuesAsSlice(), "-") +} diff --git a/vendor/github.com/buildpacks/pack/pkg/client/create_builder.go b/vendor/github.com/buildpacks/pack/pkg/client/create_builder.go index ca777864156..6a3e1dbac9b 100644 --- a/vendor/github.com/buildpacks/pack/pkg/client/create_builder.go +++ b/vendor/github.com/buildpacks/pack/pkg/client/create_builder.go @@ -6,6 +6,8 @@ import ( "sort" "strings" + "github.com/buildpacks/pack/internal/name" + "github.com/Masterminds/semver" "github.com/buildpacks/imgutil" "github.com/pkg/errors" @@ -43,6 +45,10 @@ type CreateBuilderOptions struct { // Requires BuilderName to be a valid registry location. Publish bool + // Append [os]-[arch] suffix to the image tag when publishing a multi-arch to a registry + // Requires Publish to be true + AppendImageNameSuffix bool + // Buildpack registry name. Defines where all registry buildpacks will be pulled from. Registry string @@ -98,7 +104,7 @@ func (c *Client) createBuilderTarget(ctx context.Context, opts CreateBuilderOpti return "", err } - bldr, err := c.createBaseBuilder(ctx, opts, target) + bldr, err := c.createBaseBuilder(ctx, opts, target, multiArch) if err != nil { return "", errors.Wrap(err, "failed to create builder") } @@ -197,7 +203,7 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO return nil } -func (c *Client) createBaseBuilder(ctx context.Context, opts CreateBuilderOptions, target *dist.Target) (*builder.Builder, error) { +func (c *Client) createBaseBuilder(ctx context.Context, opts CreateBuilderOptions, target *dist.Target, multiArch bool) (*builder.Builder, error) { baseImage, err := c.imageFetcher.Fetch(ctx, opts.Config.Build.Image, image.FetchOptions{Daemon: !opts.Publish, PullPolicy: opts.PullPolicy, Target: target}) if err != nil { return nil, errors.Wrap(err, "fetch build image") @@ -213,7 +219,15 @@ func (c *Client) createBaseBuilder(ctx context.Context, opts CreateBuilderOption builderOpts = append(builderOpts, builder.WithLabels(opts.Labels)) } - bldr, err := builder.New(baseImage, opts.BuilderName, builderOpts...) + builderName := opts.BuilderName + if multiArch && opts.AppendImageNameSuffix { + builderName, err = name.AppendSuffix(builderName, *target) + if err != nil { + return nil, errors.Wrap(err, "invalid image name") + } + } + + bldr, err := builder.New(baseImage, builderName, builderOpts...) if err != nil { return nil, errors.Wrap(err, "invalid build-image") } diff --git a/vendor/github.com/buildpacks/pack/pkg/client/package_buildpack.go b/vendor/github.com/buildpacks/pack/pkg/client/package_buildpack.go index ed31a3203c3..fbb8e38062a 100644 --- a/vendor/github.com/buildpacks/pack/pkg/client/package_buildpack.go +++ b/vendor/github.com/buildpacks/pack/pkg/client/package_buildpack.go @@ -5,6 +5,8 @@ import ( "fmt" "path/filepath" + "github.com/buildpacks/pack/internal/name" + "github.com/pkg/errors" pubbldpkg "github.com/buildpacks/pack/buildpackage" @@ -47,6 +49,10 @@ type PackageBuildpackOptions struct { // specified in the Name variable. Publish bool + // Append [os]-[arch] suffix to the image tag when publishing a multi-arch to a registry + // Requires Publish to be true + AppendImageNameSuffix bool + // Strategy for updating images before packaging. PullPolicy image.PullPolicy @@ -192,7 +198,14 @@ func (c *Client) packageBuildpackTarget(ctx context.Context, opts PackageBuildpa return digest, err } case FormatImage: - img, err := packageBuilder.SaveAsImage(opts.Name, opts.Publish, target, opts.Labels) + packageName := opts.Name + if multiArch && opts.AppendImageNameSuffix { + packageName, err = name.AppendSuffix(packageName, target) + if err != nil { + return "", errors.Wrap(err, "invalid image name") + } + } + img, err := packageBuilder.SaveAsImage(packageName, opts.Publish, target, opts.Labels) if err != nil { return digest, errors.Wrapf(err, "saving image") } diff --git a/vendor/github.com/buildpacks/pack/pkg/image/fetcher.go b/vendor/github.com/buildpacks/pack/pkg/image/fetcher.go index ec12b10226f..7505b74f377 100644 --- a/vendor/github.com/buildpacks/pack/pkg/image/fetcher.go +++ b/vendor/github.com/buildpacks/pack/pkg/image/fetcher.go @@ -121,10 +121,9 @@ func (f *Fetcher) Fetch(ctx context.Context, name string, options FetchOptions) // FIXME: this matching is brittle and the fallback should be removed when https://github.com/buildpacks/pack/issues/2079 // has been fixed for a sufficient amount of time. // 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") && - (strings.HasSuffix(strings.TrimSpace(err.Error()), "actual: linux") || - strings.HasSuffix(strings.TrimSpace(err.Error()), "actual: windows")) { + // `image with reference was found but does not match the specified platform: wanted linux/amd64, actual: linux` or + // `image with reference was found but its platform (linux) does not match the specified platform (linux/amd64)` + if strings.Contains(err.Error(), "does not match the specified platform") { f.logger.Debugf(fmt.Sprintf("Pulling image %s", style.Symbol(name))) err = f.pullImage(ctx, name, "") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9d8a80984f8..f08d9770b34 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -358,7 +358,7 @@ github.com/buildpacks/lifecycle/log github.com/buildpacks/lifecycle/phase github.com/buildpacks/lifecycle/platform github.com/buildpacks/lifecycle/platform/files -# github.com/buildpacks/pack v0.36.3 +# github.com/buildpacks/pack v0.36.4 ## explicit; go 1.23 github.com/buildpacks/pack github.com/buildpacks/pack/builder