-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
48 lines (40 loc) · 1.47 KB
/
utils.go
File metadata and controls
48 lines (40 loc) · 1.47 KB
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
package github
import "fmt"
// Maps repositories to namespace templates
var repoToNamespaceTemplateMap map[string]string
// Contains the list of Renku global images
var globalImagesSlice []string
func DeriveK8sNamespace(repo string, pr int) (string, error) {
tpl, found := repoToNamespaceTemplateMap[repo]
if found {
return fmt.Sprintf(tpl, pr), nil
}
return "", fmt.Errorf("could not derive namespace from repository: %s", repo)
}
func GetGlobalImages() []string {
return globalImagesSlice[:]
}
func init() {
initRepoToNamespaceTemplateMap()
initGlobalImagesSlice()
}
func initRepoToNamespaceTemplateMap() {
repoToNamespaceTemplateMap = map[string]string{
"SwissDataScienceCenter/amalthea": "renku-ci-am-%d",
"SwissDataScienceCenter/renku": "ci-renku-%d",
"SwissDataScienceCenter/renku-data-services": "renku-ci-ds-%d",
"SwissDataScienceCenter/renku-ui": "renku-ci-ui-%d",
}
}
func initGlobalImagesSlice() {
// TODO: can we derive this from GitHub API calls?
prefix := "ghcr.io/swissdatasciencecenter/renku"
packageVariants := []string{"basic", "datascience"}
frontendVariants := []string{"jupyterlab", "ttyd", "vscodium"}
globalImagesSlice = make([]string, 0, len(packageVariants)*len(frontendVariants))
for _, packageVariant := range packageVariants {
for _, frontendVariant := range frontendVariants {
globalImagesSlice = append(globalImagesSlice, fmt.Sprintf("%s/py-%s-%s", prefix, packageVariant, frontendVariant))
}
}
}