-
Notifications
You must be signed in to change notification settings - Fork 300
/
imageprovider.go
43 lines (34 loc) · 1.04 KB
/
imageprovider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package imageprovider
import "github.com/openshift/hypershift/support/releaseinfo"
type ReleaseImageProvider struct {
missingImages []string
componentsImages map[string]string
*releaseinfo.ReleaseImage
}
func New(releaseImage *releaseinfo.ReleaseImage) *ReleaseImageProvider {
return &ReleaseImageProvider{
componentsImages: releaseImage.ComponentImages(),
missingImages: make([]string, 0),
ReleaseImage: releaseImage,
}
}
func NewFromImages(componentsImages map[string]string) *ReleaseImageProvider {
return &ReleaseImageProvider{
componentsImages: componentsImages,
missingImages: make([]string, 0),
}
}
func (p *ReleaseImageProvider) GetImage(key string) string {
image, exist := p.componentsImages[key]
if !exist || image == "" {
p.missingImages = append(p.missingImages, key)
}
return image
}
func (p *ReleaseImageProvider) GetMissingImages() []string {
return p.missingImages
}
func (p *ReleaseImageProvider) ImageExist(key string) (string, bool) {
img, exist := p.componentsImages[key]
return img, exist
}