Skip to content

Commit 11f67f8

Browse files
committed
[supervisor] fix gitpod config changed analytics
1 parent 463f32e commit 11f67f8

File tree

14 files changed

+1058
-159
lines changed

14 files changed

+1058
-159
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ repos:
4545

4646
- repo: local
4747
hooks:
48+
- id: generate-gitpod-config-types
49+
name: generate-gitpod-config-types
50+
entry: ./components/gitpod-protocol/hack/generate-config.sh
51+
language: script
52+
pass_filenames: false
4853
- id: license-header
4954
name: license-header
5055
entry: leeway run components:update-license-header

.werft/jobs/build/deploy-to-preview-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ async function deployToDevWithInstaller(
334334
}
335335
werft.done(installerSlices.IMAGE_PULL_SECRET);
336336

337-
let analytics: Analytics;
337+
let analytics: Analytics | undefined;
338338
if ((deploymentConfig.analytics || "").startsWith("segment|")) {
339339
analytics = {
340340
type: "segment",

.werft/jobs/build/installer/installer.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type InstallerOptions = {
3131
previewName: string;
3232
imagePullSecretName: string;
3333
deploymentNamespace: string;
34-
analytics: Analytics;
34+
analytics?: Analytics;
3535
withEELicense: boolean;
3636
workspaceFeatureFlags: string[];
3737
gitpodDaemonsetPorts: GitpodDaemonsetPorts;
@@ -75,6 +75,8 @@ export class Installer {
7575
this.configureUsage(slice);
7676
this.configureConfigCat(slice);
7777

78+
this.configureDefaultTemplate(slice);
79+
7880
if (this.options.analytics) {
7981
this.includeAnalytics(slice);
8082
} else {
@@ -103,6 +105,11 @@ export class Installer {
103105
}
104106
this.options.werft.done(slice);
105107
}
108+
configureDefaultTemplate(slice: string): void {
109+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers[+].name' workspace`);
110+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env[+].name' GITPOD_PREVENT_METADATA_ACCESS`);
111+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env.(name==GITPOD_PREVENT_METADATA_ACCESS).value' "true"`);
112+
}
106113

107114
private getDevCustomValues(slice: string): void {
108115
exec(
@@ -253,6 +260,10 @@ EOF`);
253260
exec(`yq w -i ${this.options.installerConfigPath} analytics.segmentKey ${this.options.analytics.token}`, {
254261
slice: slice,
255262
});
263+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env[+].name' GITPOD_ANALYTICS_WRITER`);
264+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env.(name==GITPOD_ANALYTICS_WRITER).value' "segment"`);
265+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env[+].name' GITPOD_ANALYTICS_SEGMENT_KEY`);
266+
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env.(name==GITPOD_ANALYTICS_SEGMENT_KEY).value' "${this.options.analytics.token}"`);
256267
}
257268

258269
private dontIncludeAnalytics(slice: string): void {

.werft/jobs/build/installer/post-process.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ while [ "$documentIndex" -le "$DOCS" ]; do
276276
LABEL="gitpod.io/workspace_$NODE_POOL_INDEX"
277277
yq w -i /tmp/"$NAME"overrides.yaml spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key "$LABEL"
278278
yq w -i /tmp/"$NAME"overrides.yaml spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator Exists
279-
yq w -i /tmp/"$NAME"overrides.yaml spec.containers[+].name workspace
280-
yq w -i /tmp/"$NAME"overrides.yaml "spec.containers.(name==workspace).env[+].name" GITPOD_PREVENT_METADATA_ACCESS
281-
yq w -i /tmp/"$NAME"overrides.yaml "spec.containers.(name==workspace).env.(name==GITPOD_PREVENT_METADATA_ACCESS).value" "true"
282279

283280
yq w -i k8s.yaml -d "$documentIndex" "data.[default.yaml]" -- "$(< /tmp/"$NAME"overrides.yaml)"
284281
fi

components/common-go/analytics/analytics.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ type TrackMessage struct {
4141
func NewFromEnvironment() Writer {
4242
switch os.Getenv("GITPOD_ANALYTICS_WRITER") {
4343
case "log":
44+
log.Debug("log analytics")
4445
return &logAnalyticsWriter{}
4546
case "segment":
47+
log.Debug("segment analytics")
4648
return &segmentAnalyticsWriter{Client: segment.New(os.Getenv("GITPOD_ANALYTICS_SEGMENT_KEY"))}
4749
default:
50+
log.Debug("no analytics")
4851
return &noAnalyticsWriter{}
4952
}
5053
}

components/gitpod-protocol/data/gitpod-schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
},
275275
"prebuilds": {
276276
"type": "object",
277-
"description": "Enable warming up of IntelliJ in prebuilds.",
277+
"description": "Enable warming up of JetBrains backend in prebuilds.",
278278
"additionalProperties": false,
279279
"properties": {
280280
"version": {
@@ -308,7 +308,7 @@
308308
},
309309
"prebuilds": {
310310
"type": "object",
311-
"description": "Enable warming up of GoLand in prebuilds.",
311+
"description": "Enable warming up of JetBrains backend in prebuilds.",
312312
"additionalProperties": false,
313313
"properties": {
314314
"version": {
@@ -342,7 +342,7 @@
342342
},
343343
"prebuilds": {
344344
"type": "object",
345-
"description": "Enable warming up of PyCharm in prebuilds.",
345+
"description": "Enable warming up of JetBrains backend in prebuilds.",
346346
"additionalProperties": false,
347347
"properties": {
348348
"version": {
@@ -376,7 +376,7 @@
376376
},
377377
"prebuilds": {
378378
"type": "object",
379-
"description": "Enable warming up of PhpStorm in prebuilds.",
379+
"description": "Enable warming up of JetBrains backend in prebuilds.",
380380
"additionalProperties": false,
381381
"properties": {
382382
"version": {

0 commit comments

Comments
 (0)