Skip to content

fix: improve uriFromLifecycleVersion to handle all supported OS/arch combinations correctly #2546

@jjbustamante

Description

@jjbustamante

Summary

uriFromLifecycleVersion in pkg/client/create_builder.go builds the download URL for the lifecycle binary based on the builder image's OS and architecture. The current implementation has several gaps and inaccuracies compared to what the lifecycle project actually publishes at https://github.com/buildpacks/lifecycle/releases.

This issue tracks making the method accurate and complete for all supported OS/arch combinations.


Current behavior

func (c *Client) uriFromLifecycleVersion(version semver.Version, os string, architecture string) string {
    arch := "x86-64"

    if os == "windows" {
        return fmt.Sprintf("...+windows.%s.tgz", version, version, arch)
    }

    if builder.SupportedLinuxArchitecture(architecture) { // only arm64, ppc64le, s390x
        arch = architecture
    } else {
        c.logger.Warnf("failed to find a lifecycle binary for requested architecture %s, defaulting to %s", ...)
    }

    return fmt.Sprintf("...+linux.%s.tgz", version, version, arch)
}

Problems:

  1. Linux — amd64 input emits a spurious warning even though amd64 and x86-64 name the same architecture and the correct binary is downloaded. (Being fixed by fix: treat amd64 as equivalent to x86-64 for lifecycle binary selection #2544, but the root of the problem is that the arch mapping is missing.)
  2. FreeBSD — entirely unhandled. The function always falls through to the linux URL template, producing a wrong URL for FreeBSD builder images.
  3. Windows — deprecated but silently broken. Windows container support was deprecated at lifecycle v0.20.5 (see announcement). No Windows lifecycle binary exists beyond that version, but the function still attempts to build a URL for any version, and the arch variable used in the Windows path is always the default x86-64 (the architecture parameter is ignored entirely for Windows).

Lifecycle release artifacts (as of latest)

OS Architecture Binary name suffix
linux arm64 +linux.arm64
linux ppc64le +linux.ppc64le
linux s390x +linux.s390x
linux x86-64 +linux.x86-64
freebsd amd64 +freebsd.amd64
freebsd arm64 +freebsd.arm64
windows x86-64 +windows.x86-64 (last: v0.20.5)

Example URLs:

https://github.com/buildpacks/lifecycle/releases/download/v0.21.5/lifecycle-v0.21.5+freebsd.amd64.tgz
https://github.com/buildpacks/lifecycle/releases/download/v0.21.5/lifecycle-v0.21.5+linux.x86-64.tgz
https://github.com/buildpacks/lifecycle/releases/download/v0.20.5/lifecycle-v0.20.5+windows.x86-64.tgz

Expected behavior per OS

Linux

Input arch Download arch Warning?
arm64 arm64 No
ppc64le ppc64le No
s390x s390x No
x86-64 x86-64 No
amd64 x86-64 No — amd64 is an alias for x86-64
anything else x86-64 Yes — unsupported arch, defaulting

FreeBSD

Input arch Download arch Warning?
amd64 amd64 No
arm64 arm64 No
x86-64 amd64 No — x86-64 is an alias for amd64 on FreeBSD
anything else amd64 Yes — unsupported arch, defaulting

Windows

Windows container support ended at lifecycle v0.20.5. The function should:

  • Cap the requested version at v0.20.5 if a higher version is requested.
  • Apply the same amd64x86-64 alias as Linux.
  • Always log a deprecation warning pointing to the announcement.

Suggested implementation approach

  • Introduce a lastWindowsLifecycleVersion constant ("0.20.5").
  • Replace SupportedLinuxArchitecture with explicit per-OS arch maps (or a helper per OS).
  • Handle the freebsd OS branch alongside linux and windows in uriFromLifecycleVersion.
  • Add/update unit tests in pkg/client/create_builder_test.go following the pattern of the existing arm64 test at line 616.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueA good first issue to get started with.type/bugIssue that reports an unexpected behaviour.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions