forked from joeholley/supergloo
/
input_linkerd_mesh.go
56 lines (50 loc) · 1.57 KB
/
input_linkerd_mesh.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
package inputs
import (
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
v1 "github.com/solo-io/supergloo/pkg/api/v1"
)
const (
LinkerdTestInstallNs = "linkerd-was-installed-herr"
LinkerdTestVersion = "2.2.1"
)
func LinkerdMesh(namespace string, secretRef *core.ResourceRef) *v1.Mesh {
if secretRef != nil {
panic("linkerd mesh does not currently support secret refs, so don't test it!")
}
return LinkerdMeshWithInstallNs(namespace, LinkerdTestInstallNs, secretRef)
}
func LinkerdMeshWithVersion(namespace, installNs, version string) *v1.Mesh {
return linkerdMesh(namespace, installNs, version, nil)
}
func linkerdMesh(namespace, installNs, version string, secretRef *core.ResourceRef) *v1.Mesh {
return &v1.Mesh{
Metadata: core.Metadata{
Namespace: namespace,
Name: "fancy-linkerd",
},
MeshType: &v1.Mesh_Linkerd{
Linkerd: &v1.LinkerdMesh{
InstallationNamespace: installNs,
Version: version,
},
},
MtlsConfig: &v1.MtlsConfig{
MtlsEnabled: true,
RootCertificate: secretRef,
},
}
}
func LinkerdMeshWithInstallNs(namespace, installNs string, secretRef *core.ResourceRef) *v1.Mesh {
return linkerdMesh(namespace, installNs, "", secretRef)
}
func LinkerdMeshWithInstallNsPrometheus(namespace, installNs string, secretRef *core.ResourceRef, promCfgRefs []core.ResourceRef) *v1.Mesh {
var monit *v1.MonitoringConfig
if len(promCfgRefs) > 0 {
monit = &v1.MonitoringConfig{
PrometheusConfigmaps: promCfgRefs,
}
}
mesh := linkerdMesh(namespace, installNs, "", secretRef)
mesh.MonitoringConfig = monit
return mesh
}