/
resources.go
63 lines (55 loc) · 1.61 KB
/
resources.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
package servicemesh
import (
"strings"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature"
)
// MeshRefs stores service mesh configuration in the config map, so it can
// be easily accessed by other components which rely on this information.
func MeshRefs(f *feature.Feature) error {
meshConfig := f.Spec.ControlPlane
namespace := f.Spec.AppNamespace
data := map[string]string{
"CONTROL_PLANE_NAME": meshConfig.Name,
"MESH_NAMESPACE": meshConfig.Namespace,
}
return cluster.CreateOrUpdateConfigMap(
f.Client,
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "service-mesh-refs",
Namespace: namespace,
},
Data: data,
},
feature.OwnedBy(f),
)
}
// AuthRefs stores authorization configuration in the config map, so it can
// be easily accessed by other components which rely on this information.
func AuthRefs(f *feature.Feature) error {
audiences := f.Spec.Auth.Audiences
namespace := f.Spec.AppNamespace
audiencesList := ""
if audiences != nil && len(*audiences) > 0 {
audiencesList = strings.Join(*audiences, ",")
}
data := map[string]string{
"AUTH_AUDIENCE": audiencesList,
"AUTH_PROVIDER": namespace + "-auth-provider",
"AUTHORINO_LABEL": "security.opendatahub.io/authorization-group=default",
}
return cluster.CreateOrUpdateConfigMap(
f.Client,
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "auth-refs",
Namespace: namespace,
},
Data: data,
},
feature.OwnedBy(f),
)
}