@@ -113,21 +113,31 @@ func (r ImageStreamSearcher) Search(precise bool, terms ...string) (ComponentMat
113
113
componentMatches = append (componentMatches , match )
114
114
}
115
115
116
- // When an image stream contains a tag that references another local tag, and the user has not
117
- // provided a tag themselves (i.e. they asked for mysql and we defaulted to mysql:latest), walk
118
- // the chain of references to the end. This ensures that applications can default to using a "stable"
119
- // branch by giving the control over version to the image stream author.
116
+ // When the user has not provided a tag themselves (i.e. they asked for
117
+ // mysql and we defaulted to mysql:latest), and "latest" references
118
+ // another local tag, and neither tag is hidden, use the referenced tag
119
+ // instead of "latest". This ensures that applications can default to
120
+ // using a "stable" branch by giving the control over version to the
121
+ // image stream author.
120
122
finalTag := searchTag
121
- if specTag , ok := stream .Spec .Tags [searchTag ]; ok && followTag {
123
+ if specTag , ok := stream .Spec .Tags [searchTag ]; ok && followTag && ! specTag . HasAnnotationTag ( imageapi . TagReferenceAnnotationTagHidden ) {
122
124
if specTag .From != nil && specTag .From .Kind == "ImageStreamTag" && ! strings .Contains (specTag .From .Name , ":" ) {
123
- if imageapi .LatestTaggedImage (stream , specTag .From .Name ) != nil {
124
- finalTag = specTag .From .Name
125
+ if destSpecTag , ok := stream .Spec .Tags [specTag .From .Name ]; ok && ! destSpecTag .HasAnnotationTag (imageapi .TagReferenceAnnotationTagHidden ) {
126
+ if imageapi .LatestTaggedImage (stream , specTag .From .Name ) != nil {
127
+ finalTag = specTag .From .Name
128
+ }
125
129
}
126
130
}
127
131
}
128
132
129
133
latest := imageapi .LatestTaggedImage (stream , finalTag )
130
- if latest == nil || len (latest .Image ) == 0 {
134
+
135
+ // Special case in addition to the other tag not found cases: if no tag
136
+ // was specified, and "latest" is hidden, then behave as if "latest"
137
+ // doesn't exist (in this case, to get to "latest", the user must hard
138
+ // specify tag "latest").
139
+ if specTag , ok := stream .Spec .Tags [searchTag ]; (ok && followTag && specTag .HasAnnotationTag (imageapi .TagReferenceAnnotationTagHidden )) ||
140
+ latest == nil || len (latest .Image ) == 0 {
131
141
132
142
glog .V (2 ).Infof ("no image recorded for %s/%s:%s" , stream .Namespace , stream .Name , finalTag )
133
143
if r .AllowMissingTags {
0 commit comments