77
88 buildtypes "github.com/loft-sh/devspace/pkg/devspace/build/types"
99 "github.com/loft-sh/devspace/pkg/devspace/config/constants"
10+ "github.com/loft-sh/devspace/pkg/devspace/config/localcache"
1011 "github.com/loft-sh/devspace/pkg/devspace/imageselector"
1112 "github.com/loft-sh/devspace/pkg/util/dockerfile"
1213
@@ -92,9 +93,24 @@ func resolveImage(value string, config config2.Config, dependencies []types.Depe
9293 // strip out images from cache that are not in the images conf anymore
9394 imageCacheMap := config .LocalCache ().ListImageCache ()
9495
96+ // Find matching image in image cache
97+ var imageCache * localcache.ImageCache
98+ if tryImageKey {
99+ if match , ok := imageCacheMap [value ]; ok {
100+ imageCache = & match
101+ }
102+ } else {
103+ for _ , match := range imageCacheMap {
104+ if match .ImageName == value {
105+ imageCache = & match
106+ break
107+ }
108+ }
109+ }
110+
95111 // strip original image name
96112 originalImage := ""
97- if imageCache , ok := imageCacheMap [ value ]; ok {
113+ if imageCache != nil {
98114 strippedImage , _ , err := dockerfile .GetStrippedDockerImageName (imageCache .ImageName )
99115 if err != nil {
100116 return false , false , "" , nil
@@ -117,6 +133,23 @@ func resolveImage(value string, config config2.Config, dependencies []types.Depe
117133 }
118134 }
119135
136+ // Found a match in the image cache
137+ if imageCache != nil {
138+ if onlyImage {
139+ return true , shouldRedeploy , imageCache .ResolveImage (), nil
140+ }
141+
142+ if onlyTag {
143+ if imageCache .Tag == "" {
144+ return true , shouldRedeploy , "latest" , nil
145+ }
146+
147+ return true , shouldRedeploy , imageCache .Tag , nil
148+ }
149+
150+ return true , shouldRedeploy , imageCache .ResolveImage () + ":" + imageCache .Tag , nil
151+ }
152+
120153 // config images
121154 configImages := config .Config ().Images
122155 if configImages == nil {
@@ -210,7 +243,8 @@ func Replace(value string, config config2.Config, dependencies []types.Dependenc
210243 return shouldRedeploy , resolvedImage , nil
211244 }
212245
213- return ReplaceHelpers (value , config , dependencies )
246+ helperShouldRedeploy , helperResolvedImage , err := ReplaceHelpers (value , config , dependencies )
247+ return shouldRedeploy || helperShouldRedeploy , helperResolvedImage , err
214248}
215249
216250func ReplaceHelpers (value string , config config2.Config , dependencies []types.Dependency ) (bool , interface {}, error ) {
0 commit comments