(value string, config config2.Config, dependencies []types.Dependency, tryImageKey, onlyImage, onlyTag bool)
| 63 | } |
| 64 | |
| 65 | func resolveImage(value string, config config2.Config, dependencies []types.Dependency, tryImageKey, onlyImage, onlyTag bool) (bool, bool, string, error) { |
| 66 | builtImages := map[string]buildtypes.ImageNameTag{} |
| 67 | builtImagesInterface, ok := config.GetRuntimeVariable(constants.BuiltImagesKey) |
| 68 | if ok { |
| 69 | builtImages, _ = builtImagesInterface.(map[string]buildtypes.ImageNameTag) |
| 70 | } |
| 71 | |
| 72 | resolvedImage := value |
| 73 | if tryImageKey { |
| 74 | selector, err := imageselector.Resolve(value, config, dependencies) |
| 75 | if err == nil && selector != nil { |
| 76 | resolvedImage = selector.Image |
| 77 | if selector.Dependency != nil { |
| 78 | config = selector.Dependency.Config() |
| 79 | |
| 80 | builtImagesInterface, ok := selector.Dependency.Config().GetRuntimeVariable(constants.BuiltImagesKey) |
| 81 | if ok { |
| 82 | builtImages, _ = builtImagesInterface.(map[string]buildtypes.ImageNameTag) |
| 83 | } else { |
| 84 | builtImages = map[string]buildtypes.ImageNameTag{} |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // ensure we don't run into any nil pointers |
| 91 | config = config2.Ensure(config) |
| 92 | |
| 93 | // strip out images from cache that are not in the images conf anymore |
| 94 | imageCacheMap := config.LocalCache().ListImageCache() |
| 95 | |
| 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 | |
| 111 | // strip original image name |
| 112 | originalImage := "" |
| 113 | if imageCache != nil { |
| 114 | strippedImage, _, err := dockerfile.GetStrippedDockerImageName(imageCache.ImageName) |
| 115 | if err != nil { |
| 116 | return false, false, "", nil |
| 117 | } |
| 118 | originalImage = strippedImage |
| 119 | } |
| 120 | |
| 121 | // strip docker image name |
| 122 | image, originalTag, err := dockerfile.GetStrippedDockerImageName(resolvedImage) |
no test coverage detected