Skip to content

Commit d9ec94f

Browse files
committed
explicitly reject updates to non-spec imagestreamtags
1 parent 4957392 commit d9ec94f

File tree

1 file changed

+9
-0
lines changed
  • pkg/image/registry/imagestreamtag

1 file changed

+9
-0
lines changed

pkg/image/registry/imagestreamtag/rest.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,21 @@ func (r *REST) Update(ctx apirequest.Context, tagName string, objInfo rest.Updat
263263
imageStream.Spec.Tags = map[string]imageapi.TagReference{}
264264
}
265265
tagRef, exists := imageStream.Spec.Tags[tag]
266+
267+
if !exists {
268+
return nil, false, kapierrors.NewBadRequest(fmt.Sprintf("imagestreamtag %s is not a spec tag in imagestream %s/%s, cannot be updated", tag, imageStream.Namespace, imageStream.Name))
269+
}
270+
266271
// if the caller set tag, override the spec tag
267272
if istag.Tag != nil {
268273
tagRef = *istag.Tag
269274
tagRef.Name = tag
270275
}
271276
tagRef.Annotations = istag.Annotations
277+
278+
if len(tagRef.ReferencePolicy.Type) == 0 {
279+
tagRef.ReferencePolicy.Type = imageapi.SourceTagReferencePolicy
280+
}
272281
imageStream.Spec.Tags[tag] = tagRef
273282

274283
// mutate the image stream

0 commit comments

Comments
 (0)