forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getters.go
51 lines (44 loc) · 1.25 KB
/
getters.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
package util
import (
v1 "github.com/solo-io/supergloo/pkg/api/v1"
)
func getLinkerdMeshForInstall(install *v1.LinkerdInstall, meshes v1.MeshList, namespace string) *v1.Mesh {
for _, mesh := range meshes {
linkerdMesh := mesh.GetLinkerd()
if linkerdMesh == nil {
continue
}
if linkerdMesh.InstallationNamespace == namespace &&
linkerdMesh.Version == install.Version {
return mesh
}
}
return nil
}
func getIstioMeshForInstall(install *v1.IstioInstall, meshes v1.MeshList, namespace string) *v1.Mesh {
for _, mesh := range meshes {
istioMesh := mesh.GetIstio()
if istioMesh == nil {
continue
}
if istioMesh.InstallationNamespace == namespace &&
istioMesh.Version == install.Version {
return mesh
}
}
return nil
}
func GetMeshForInstall(install *v1.Install, meshes v1.MeshList) *v1.Mesh {
meshInstall, ok := install.GetInstallType().(*v1.Install_Mesh)
if !ok {
return nil
}
switch meshInstallType := meshInstall.Mesh.GetMeshInstallType().(type) {
case *v1.MeshInstall_Linkerd:
return getLinkerdMeshForInstall(meshInstallType.Linkerd, meshes, install.InstallationNamespace)
case *v1.MeshInstall_Istio:
return getIstioMeshForInstall(meshInstallType.Istio, meshes, install.InstallationNamespace)
default:
return nil
}
}