...
1 package resource
2
3 import (
4 corev1 "k8s.io/api/core/v1"
5 )
6
7 const (
8 xdgRuntimeVol = "xdg-runtime"
9 xdgRuntimeDirEnvVar = "XDG_RUNTIME_DIR"
10 xdgRuntimeDir = "/tmp/xdg_runtime"
11
12 pulseServerEnvVar = "PULSE_SERVER"
13 pulseServerPath = xdgRuntimeDir + "/pa.socket"
14 )
15
16
17
18
19
20
21
22
23 func addAudioRequestResourcesToPod(template corev1.PodTemplateSpec) corev1.PodTemplateSpec {
24 template = addPodResourceRequestLabel(template, AudioRequestResource)
25 template = addPodHostPathVolume(template, xdgRuntimeVol, xdgRuntimeDir)
26
27 for idx, container := range template.Spec.Containers {
28 for resourceName := range container.Resources.Requests {
29 if resourceName != corev1.ResourceName(AudioRequestResource) {
30 continue
31 }
32 container = addContainerVolumeMount(container, xdgRuntimeVol, xdgRuntimeDir, false)
33 container = addContainerEnvVar(container, xdgRuntimeDirEnvVar, xdgRuntimeDir)
34 container = addContainerEnvVar(container, pulseServerEnvVar, pulseServerPath)
35 template.Spec.Containers[idx] = container
36 }
37 }
38 return template
39 }
40
View as plain text