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

Ability to add image labels to buildpacks during pack buildpack package #1867

Closed
ForestEckhardt opened this issue Aug 9, 2023 · 10 comments · Fixed by #1877
Closed

Ability to add image labels to buildpacks during pack buildpack package #1867

ForestEckhardt opened this issue Aug 9, 2023 · 10 comments · Fixed by #1877
Labels
status/ready Issue ready to be worked on. type/enhancement Issue that requests a new feature or improvement.
Milestone

Comments

@ForestEckhardt
Copy link
Contributor

Description

We would like to be able to add metadata to our buildpacks via image labels at build time but there is no way for us to add custom image labels.

Proposed solution

Add a flag --label <label>=<value> to pack buildpack package command that will allow buildpack authors to add custom metadata to the buildpack image at build time.

Describe alternatives you've considered

This can be achieved with crane mutate but that requires you to upload the image without metadata to a registry and then mutate the file. This also means that image labels cannot be added to the .cnb files at all which feels bad as the OCI image in registry and in .cnb file format should be identical.

@ForestEckhardt ForestEckhardt added status/triage Issue or PR that requires contributor attention. type/enhancement Issue that requests a new feature or improvement. labels Aug 9, 2023
@hone
Copy link
Member

hone commented Aug 10, 2023

@ForestEckhardt This functionality makes sense to me. I'm just trying to figure out the best place it should be implemented. Is this something you'd like to do at build time dynamically, or should is it ok to encode this statically like in buildpack.toml? Also, do you mind providing some examples of labels you're thinking of if you can share them?

@ForestEckhardt
Copy link
Contributor Author

@hone

I think that this should be something that is done dynamically at build time because I think what I would like to do with it is encode build specific information.

As for the labels I personally would like to be able to embedded the source url and the commit SHA of the source that was used to build the buildpack. They way there is way for people to inspect the image itself and see where the source is and what SHA was used to create the buildpack with standard container tools.

That being said I could see an argument for most of the standard labels provided by the Paketo Image Labels buildpack also being useful for authors to just add standardized metadata to their buildpack images.

@hone
Copy link
Member

hone commented Aug 10, 2023

@ForestEckhardt I think those labels make sense. If I understand, you can use a buildpack today to solve what you're trying to do. I still think giving buildpack authors the flexibility makes sense and if we want to standardize things in lifecycle, we can do that after the fact.

@ForestEckhardt
Copy link
Contributor Author

If I understand, you can use a buildpack today to solve what you're trying to do.

@hone

To be clear. This would be for adding labels to a buildpackage and an image built by a buildpack. If there is already a way to do this as part of the buildpack packaging process then I would be more than happy to use that but as far as I could find there is no mechanism to add the labels to the buildpackage itself.

@jjbustamante
Copy link
Member

This could also be useful for pack builder create command. See this thread

cc @matejvasek

@jjbustamante
Copy link
Member

Here are my thoughts on this.

We have 3 commands that outputs OCI artifacts

  • pack buildpack package
  • pack builder create
  • pack build <app-image>

The idea will be to include a new flag --label <label>=<value> to allow users to add custom labels on those artifacts.
Under the hoods pack creates an imgutil.Image instance, this interface already exposes a method to add labels, in my opinion, adding those labels to buildpackage and builders is easy (we don't deal with the lifecycle here).

For pack build <app-image> I think could be similar, but in such as case, lifecycle is responsible for creating the imgutil.Image so we will need to passthrough the values to it. Maybe we should create a ticket in the lifecycle side first, and once that is defined we can create a ticket on pack to expose the proper user interface

@ForestEckhardt
Copy link
Contributor Author

@jjbustamante

I am not particular concerned with getting image labels built into the pack build <app-image> as that is something that I see supported by buildpacks. I would personally prefer that concern could be separated from this issue as I would like to see the pack buildpack package feature path not have to be tied to this being a universal option.

@jjbustamante jjbustamante added status/discussion-needed Issue or PR that requires in-depth discussion. and removed status/triage Issue or PR that requires contributor attention. labels Aug 16, 2023
@jjbustamante
Copy link
Member

This one seems like a very straight forward feature, and it seems valid to me, I will just put under needs-discussion to double check during working group if it doesn't require an RFC, I don't think so, but just want to validate it with the community. After that, we can label this one as status-ready to be work on

@jjbustamante
Copy link
Member

jjbustamante commented Aug 24, 2023

For working group discussion:

  • I want to confirm the idea is adding labels to the config file in the OCI image
  • I do not think this requires an RFC
  • What about labels with key org.opencontainers.* should we do any validation? (I don't think so)
  • Is it valid to expose equivalent feature for pack builder create command?

@jjbustamante
Copy link
Member

Hi Forest.

We just released a RC pack version, it will be great if you can give it a try and confirm the issue was solved

@jjbustamante jjbustamante added status/ready Issue ready to be worked on. and removed status/discussion-needed Issue or PR that requires in-depth discussion. labels Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/ready Issue ready to be worked on. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants