-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
s2i_images.go
131 lines (120 loc) · 2.74 KB
/
s2i_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package image_ecosystem
import "fmt"
type ImageBaseType string
const (
RHELBased ImageBaseType = "rhel7"
CentosBased ImageBaseType = "centos7"
AllImages ImageBaseType = "all"
)
type tc struct {
// The image version string (eg. '27' or '34')
Version string
// The base OS ('rhel7' or 'centos7')
BaseOS ImageBaseType
// Command to execute
Cmd string
// Expected output from the command
Expected string
// Repository is either openshift/ or rhcsl/
// The default is 'openshift'
Repository string
// Internal: We resolve this in JustBeforeEach
DockerImageReference string
}
// Internal OpenShift registry to fetch the RHEL7 images from
const InternalRegistryAddr = "ci.dev.openshift.redhat.com:5000"
// This is a complete list of supported S2I images
var s2iImages = map[string][]tc{
"ruby": {
{
Version: "20",
Cmd: "ruby --version",
Expected: "ruby 2.0.0",
},
{
Version: "22",
Cmd: "ruby --version",
Expected: "ruby 2.2.2",
},
},
"python": {
{
Version: "27",
Cmd: "python --version",
Expected: "Python 2.7.8",
},
{
Version: "33",
Cmd: "python --version",
Expected: "Python 3.3.2",
},
},
"nodejs": {
{
Version: "010",
Cmd: "node --version",
Expected: "v0.10",
},
},
"perl": {
{
Version: "516",
Cmd: "perl --version",
Expected: "v5.16.3",
},
{
Version: "520",
Cmd: "perl --version",
Expected: "v5.20.1",
},
},
"php": {
{
Version: "55",
Cmd: "php --version",
Expected: "5.5",
},
{
Version: "56",
Cmd: "php --version",
Expected: "5.6",
},
},
}
func GetTestCaseForImages(base ImageBaseType) map[string][]tc {
if base == AllImages {
result := GetTestCaseForImages(RHELBased)
for n, t := range GetTestCaseForImages(CentosBased) {
result[n] = append(result[n], t...)
}
return result
}
result := make(map[string][]tc)
for name, variants := range s2iImages {
switch base {
case RHELBased:
for i := range variants {
variants[i].BaseOS = RHELBased
resolveDockerImageReference(name, &variants[i])
result[name] = append(result[name], variants[i])
}
case CentosBased:
for i := range variants {
variants[i].BaseOS = CentosBased
resolveDockerImageReference(name, &variants[i])
result[name] = append(result[name], variants[i])
}
}
}
return result
}
// resolveDockerImageReferences resolves the pull specs for all images
func resolveDockerImageReference(name string, t *tc) {
if len(t.Repository) == 0 {
t.Repository = "openshift"
}
t.DockerImageReference = fmt.Sprintf("%s/%s-%s-%s", t.Repository, name, t.Version, t.BaseOS)
if t.BaseOS == RHELBased {
t.DockerImageReference = fmt.Sprintf("%s/%s", InternalRegistryAddr, t.DockerImageReference)
}
}