@@ -7,6 +7,7 @@ package ide_metrics
7
7
import (
8
8
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
9
9
"github.com/gitpod-io/gitpod/installer/pkg/common"
10
+ "github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
10
11
11
12
appsv1 "k8s.io/api/apps/v1"
12
13
corev1 "k8s.io/api/core/v1"
@@ -25,6 +26,67 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
25
26
return nil , err
26
27
}
27
28
29
+ volumes := make ([]corev1.Volume , 0 )
30
+ volumeMounts := make ([]corev1.VolumeMount , 0 )
31
+
32
+ volumes = append (volumes , corev1.Volume {
33
+ Name : VolumeConfig ,
34
+ VolumeSource : corev1.VolumeSource {
35
+ ConfigMap : & corev1.ConfigMapVolumeSource {
36
+ LocalObjectReference : corev1.LocalObjectReference {Name : Component },
37
+ },
38
+ },
39
+ })
40
+
41
+ volumeMounts = append (volumeMounts , corev1.VolumeMount {
42
+ Name : VolumeConfig ,
43
+ MountPath : "/config" ,
44
+ ReadOnly : true ,
45
+ })
46
+
47
+ env := common .CustomizeEnvvar (ctx , Component , common .MergeEnv (
48
+ common .DefaultEnv (& ctx .Config ),
49
+ ))
50
+
51
+ _ = ctx .WithExperimental (func (cfg * experimental.Config ) error {
52
+ if cfg .IDE != nil && cfg .IDE .IDEMetricsConfig != nil {
53
+ if cfg .IDE .IDEMetricsConfig .EnabledErrorReporting {
54
+ env = append (env , corev1.EnvVar {
55
+ Name : "GITPOD_ENABLED_ERROR_REPORTING" ,
56
+ Value : "true" ,
57
+ })
58
+
59
+ if cfg .IDE .IDEMetricsConfig .GCPADCSecret != "" && cfg .IDE .IDEMetricsConfig .GCPProject != "" {
60
+ volumes = append (volumes , corev1.Volume {
61
+ Name : "gcp-adc-file" ,
62
+ VolumeSource : corev1.VolumeSource {
63
+ ConfigMap : & corev1.ConfigMapVolumeSource {
64
+ LocalObjectReference : corev1.LocalObjectReference {Name : Component },
65
+ },
66
+ },
67
+ })
68
+
69
+ volumeMounts = append (volumeMounts , corev1.VolumeMount {
70
+ Name : "gcp-adc-file" ,
71
+ MountPath : "/gcp" ,
72
+ ReadOnly : true ,
73
+ })
74
+
75
+ env = append (env , corev1.EnvVar {
76
+ Name : "GOOGLE_PROJECT" ,
77
+ Value : cfg .IDE .IDEMetricsConfig .GCPProject ,
78
+ })
79
+ env = append (env , corev1.EnvVar {
80
+ Name : "GOOGLE_APPLICATION_CREDENTIALS" ,
81
+ Value : "/gcp/credentials.json" ,
82
+ })
83
+ }
84
+ }
85
+
86
+ }
87
+ return nil
88
+ })
89
+
28
90
return []runtime.Object {
29
91
& appsv1.Deployment {
30
92
TypeMeta : common .TypeMetaDeployment ,
@@ -74,16 +136,8 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
74
136
SecurityContext : & corev1.SecurityContext {
75
137
Privileged : pointer .Bool (false ),
76
138
},
77
- Env : common .CustomizeEnvvar (ctx , Component , common .MergeEnv (
78
- common .DefaultEnv (& ctx .Config ),
79
- )),
80
- VolumeMounts : []corev1.VolumeMount {
81
- {
82
- Name : VolumeConfig ,
83
- MountPath : "/config" ,
84
- ReadOnly : true ,
85
- },
86
- },
139
+ Env : env ,
140
+ VolumeMounts : volumeMounts ,
87
141
ReadinessProbe : & corev1.Probe {
88
142
ProbeHandler : corev1.ProbeHandler {
89
143
TCPSocket : & corev1.TCPSocketAction {
@@ -97,16 +151,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
97
151
},
98
152
* common .KubeRBACProxyContainerWithConfig (ctx ),
99
153
},
100
- Volumes : []corev1.Volume {
101
- {
102
- Name : VolumeConfig ,
103
- VolumeSource : corev1.VolumeSource {
104
- ConfigMap : & corev1.ConfigMapVolumeSource {
105
- LocalObjectReference : corev1.LocalObjectReference {Name : Component },
106
- },
107
- },
108
- },
109
- },
154
+ Volumes : volumes ,
110
155
},
111
156
},
112
157
},
0 commit comments