Skip to content

Commit

Permalink
explicitly reject updates to non-spec imagestreamtags
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Feb 14, 2018
1 parent 4957392 commit d9ec94f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/image/registry/imagestreamtag/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,21 @@ func (r *REST) Update(ctx apirequest.Context, tagName string, objInfo rest.Updat
imageStream.Spec.Tags = map[string]imageapi.TagReference{}
}
tagRef, exists := imageStream.Spec.Tags[tag]

if !exists {
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))
}

// if the caller set tag, override the spec tag
if istag.Tag != nil {
tagRef = *istag.Tag
tagRef.Name = tag
}
tagRef.Annotations = istag.Annotations

if len(tagRef.ReferencePolicy.Type) == 0 {
tagRef.ReferencePolicy.Type = imageapi.SourceTagReferencePolicy
}
imageStream.Spec.Tags[tag] = tagRef

// mutate the image stream
Expand Down

0 comments on commit d9ec94f

Please sign in to comment.