-
Notifications
You must be signed in to change notification settings - Fork 14
/
common_links.go
67 lines (55 loc) · 1.73 KB
/
common_links.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
package links
import (
"fmt"
"strings"
"github.com/jenkins-x/octant-jx/pkg/plugin"
)
func GetDeploymentsLink(namespace string) string {
return plugin.PathPrefix + "/overview/namespace/" + namespace + "/workloads/deployments"
}
func GetDeploymentLink(namespace, name string) string {
return GetDeploymentsLink(namespace) + "/" + name
}
func GetJobsLink(namespace string) string {
return plugin.PathPrefix + "/overview/namespace/" + namespace + "/workloads/jobs"
}
func GetJobLink(namespace, name string) string {
return GetJobsLink(namespace) + "/" + name
}
func GetPodsLink(namespace string) string {
return plugin.PathPrefix + "/overview/namespace/" + namespace + "/workloads/pods"
}
func GetPodLink(namespace, name string) string {
return GetPodsLink(namespace) + "/" + name
}
func GetPodTerminalLink(namespace, name string) string {
return GetPodLink(namespace, name) + "#terminal"
}
func GetSecretsLink(namespace string) string {
return plugin.PathPrefix + "/overview/namespace/" + namespace + "/config-and-storage/secrets"
}
func GetSecretLink(namespace, name string) string {
return GetSecretsLink(namespace) + "/" + name
}
// GetImageLink returns the HTML link for the given container image name
func GetImageLink(image string) string {
if image == "" {
return ""
}
paths := strings.Split(image, "/")
registry := paths[0]
switch len(paths) {
case 1:
return fmt.Sprintf("https://hub.docker.com/_/%s", image)
case 2:
return fmt.Sprintf("https://hub.docker.com/r/%s/%s", paths[0], paths[1])
case 3:
if registry == "index.docker.io" {
return fmt.Sprintf("https://hub.docker.com/r/%s/%s", paths[1], paths[2])
}
}
if registry == "gcr.io" || strings.HasSuffix(registry, ".gcr.io") {
return "https://" + image
}
return ""
}