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

containerimage: fix removeinternalannotations #3394

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

tonistiigi
Copy link
Member

@tonistiigi tonistiigi commented Dec 13, 2022

It is unsafe to map direct modifications in the
Annotations make of the Remote descriptor. The same map inside the Descriptor could be used in other
components.

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

func RemoveInternalLayerAnnotations(desc ocispecs.Descriptor, oci bool) map[string]string {
m := make(map[string]string, len(desc.Annotations))
for k, v := range desc.Annotations {
if oci {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if oci can be checked before the for loop

for k := range desc.Annotations {
if strings.HasPrefix(k, "containerd.io/distribution.source.") {
delete(desc.Annotations, k)
func RemoveInternalLayerAnnotations(desc ocispecs.Descriptor, oci bool) map[string]string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: signature can be func (annotations map[string]string, oci bool) map[string]string, instead of needing the full descriptor.

It is unsafe to make direct modifications in the
Annotations map of the Remote descriptor. The same
map inside the Descriptor could be used in other
components.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi tonistiigi merged commit 2d9d783 into moby:master Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants