-
Notifications
You must be signed in to change notification settings - Fork 131
/
images.go
63 lines (52 loc) · 1.16 KB
/
images.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package images
import (
"fmt"
"os"
gomega "github.com/onsi/gomega"
)
var (
registry string
cnfTestsImage string
dpdkTestImage string
images map[string]imageLocation
)
const (
// TestUtils is the image name to be used to retrieve the test utils image
TestUtils = "testutils"
// Dpdk is the image name to be used to retrieve the dpdk image
Dpdk = "dpdk"
)
func init() {
registry = os.Getenv("IMAGE_REGISTRY")
if registry == "" {
registry = "quay.io/openshift-kni/"
}
cnfTestsImage = os.Getenv("CNF_TESTS_IMAGE")
if cnfTestsImage == "" {
cnfTestsImage = "cnf-tests:4.16"
}
dpdkTestImage = os.Getenv("DPDK_TESTS_IMAGE")
if dpdkTestImage == "" {
dpdkTestImage = "dpdk:4.16"
}
images = map[string]imageLocation{
TestUtils: {
registry: registry,
image: cnfTestsImage,
},
Dpdk: {
registry: registry,
image: dpdkTestImage,
},
}
}
type imageLocation struct {
registry string
image string
}
// For returns the image to be used for the given key
func For(name string) string {
img, ok := images[name]
gomega.Expect(ok).To(gomega.BeTrue(), "Image not found")
return fmt.Sprintf("%s%s", img.registry, img.image)
}