Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new flag --append-image-name-suffix to append suffix to the image name when pushing a multi-arch buildpack or builder #2314

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

jjbustamante
Copy link
Member

@jjbustamante jjbustamante commented Jan 12, 2025

Summary

This PR adds a new flag --append-image-name-suffix to pack commands

  • pack builder create
  • pack buildpack package

When publishing an multi-arch builder or buildpack to a registry, this flag will append a suffix to the given with the format [os]-[arch]-[arch-variant] to each combination given as Targets.

Output

Before

The flag doesn't exists, and pack will push a manifest for each target image and at the end it will combine them with an Image Index, the problem appears when the Registry doesn't allow to override image tags

After

Running pack against a sample multi-arch buildpack

  1. We publish our image using the new flag
> pack buildpack package $repo/cnb-hello-world --verbose --publish --append-image-name-suffix
Downloading buildpack from URI: file:///home/juan/go/src/github.com/buildpacks/samples/buildpacks/hello-world/linux/amd64
Downloading buildpack from URI: file:///home/juan/go/src/github.com/buildpacks/samples/buildpacks/hello-world/linux/arm64
Successfully pushed manifest list localhost:5000/cnb-hello-world to registry
Successfully published package localhost:5000/cnb-hello-world and saved to registry
  1. We can check the expected image index was created with the given <image-name>
> crane manifest localhost:5000/cnb-hello-world | jq .
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "size": 402,
      "digest": "sha256:9db3a1732d1c31d73a8fe4e303c49b6bd80c7678c906ad8205912a435894de32",
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "size": 402,
      "digest": "sha256:fdbe2d4fe915659e7b0ab4fa753f3f4c0bdfe80611e6a7e26b81fcfdb13da0a0",
      "platform": {
        "architecture": "arm64",
        "os": "linux"
      }
    }
  ]
}
  1. Verify each intermediate image was tagged with [os]-[target]
> crane manifest localhost:5000/cnb-hello-world:linux-amd64 | jq .
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "config": {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "size": 924,
    "digest": "sha256:9a691ead5994213d509d34ce78521ce1e89cb5a49d3e272605b48aed34a1d4c0"
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "size": 1282,
      "digest": "sha256:ea97b20ab2c0b71edbef5c6ab4957bea932168cf152065ccc62efc272fd1891d"
    }
  ]
}

> crane manifest localhost:5000/cnb-hello-world:linux-arm64 | jq .
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "config": {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "size": 924,
    "digest": "sha256:5bb3593af185263aeb9226185e63f4cf6af03bcafbfb185e4fbc2d24969a7f78"
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "size": 1282,
      "digest": "sha256:f001097ece4c3581cf9a2e0eb56f82203e1d0c72d72ccad612db95bcc9258754"
    }
  ]
}

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #2299

@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Jan 12, 2025
@github-actions github-actions bot added this to the 0.37.0 milestone Jan 12, 2025
…ch]-[variant] to the image name when pushing a multi-arch buildpack or builder

Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/fix-pack-2299 branch from 10f1924 to c49ea0a Compare January 15, 2025 01:38
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 69.84127% with 19 lines in your changes missing coverage. Please review.

Project coverage is 69.96%. Comparing base (0adeb45) to head (0c432c9).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2314      +/-   ##
==========================================
- Coverage   70.00%   69.96%   -0.04%     
==========================================
  Files         254      254              
  Lines       18720    18758      +38     
==========================================
+ Hits        13103    13122      +19     
- Misses       4741     4755      +14     
- Partials      876      881       +5     
Flag Coverage Δ
os_linux 69.10% <69.85%> (-0.03%) ⬇️
os_macos-arm64 65.31% <69.85%> (-0.03%) ⬇️
os_windows 69.47% <69.85%> (-0.03%) ⬇️
unit 69.96% <69.85%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
@jjbustamante jjbustamante changed the title WIP - adding a new flag --append-image-name-suffix to append [os]-[ar… Add new flag --append-image-name-suffix to append suffix to the image name when pushing a multi-arch buildpack or builder Jan 16, 2025
@jjbustamante jjbustamante modified the milestones: 0.37.0, 0.36.4 Jan 16, 2025
@jjbustamante jjbustamante marked this pull request as ready for review January 16, 2025 02:17
@jjbustamante jjbustamante requested review from a team as code owners January 16, 2025 02:17
@jjbustamante jjbustamante added type/bug Issue that reports an unexpected behaviour. and removed type/enhancement Issue that requests a new feature or improvement. labels Jan 17, 2025
@jjbustamante jjbustamante merged commit c7f5b1c into main Jan 17, 2025
18 checks passed
@jjbustamante jjbustamante deleted the jjbustamante/fix-pack-2299 branch January 17, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Issue that reports an unexpected behaviour.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-arch images cannot be published to a repository with immutable tags
1 participant