Skip to content

[supervisor]: gitpod config changed analytics #11653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ repos:

- repo: local
hooks:
- id: generate-gitpod-config-types
name: generate-gitpod-config-types
entry: ./components/gitpod-protocol/hack/generate-config.sh
language: script
pass_filenames: false
- id: license-header
name: license-header
entry: leeway run components:update-license-header
Expand Down
2 changes: 1 addition & 1 deletion .werft/jobs/build/deploy-to-preview-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ async function deployToDevWithInstaller(
}
werft.done(installerSlices.IMAGE_PULL_SECRET);

let analytics: Analytics;
let analytics: Analytics | undefined;
if ((deploymentConfig.analytics || "").startsWith("segment|")) {
analytics = {
type: "segment",
Expand Down
13 changes: 12 additions & 1 deletion .werft/jobs/build/installer/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type InstallerOptions = {
previewName: string;
imagePullSecretName: string;
deploymentNamespace: string;
analytics: Analytics;
analytics?: Analytics;
withEELicense: boolean;
workspaceFeatureFlags: string[];
gitpodDaemonsetPorts: GitpodDaemonsetPorts;
Expand Down Expand Up @@ -75,6 +75,8 @@ export class Installer {
this.configureUsage(slice);
this.configureConfigCat(slice);

this.configureDefaultTemplate(slice);

if (this.options.analytics) {
this.includeAnalytics(slice);
} else {
Expand Down Expand Up @@ -103,6 +105,11 @@ export class Installer {
}
this.options.werft.done(slice);
}
configureDefaultTemplate(slice: string): void {
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers[+].name' workspace`);
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env[+].name' GITPOD_PREVENT_METADATA_ACCESS`);
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env.(name==GITPOD_PREVENT_METADATA_ACCESS).value' "true"`);
}

private getDevCustomValues(slice: string): void {
exec(
Expand Down Expand Up @@ -253,6 +260,10 @@ EOF`);
exec(`yq w -i ${this.options.installerConfigPath} analytics.segmentKey ${this.options.analytics.token}`, {
slice: slice,
});
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env[+].name' GITPOD_ANALYTICS_WRITER`);
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env.(name==GITPOD_ANALYTICS_WRITER).value' "segment"`);
exec(`yq w -i ${this.options.installerConfigPath} 'workspace.templates.default.spec.containers.(name==workspace).env[+].name' GITPOD_ANALYTICS_SEGMENT_KEY`);
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}"`);
}

private dontIncludeAnalytics(slice: string): void {
Expand Down
3 changes: 0 additions & 3 deletions .werft/jobs/build/installer/post-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,6 @@ while [ "$documentIndex" -le "$DOCS" ]; do
LABEL="gitpod.io/workspace_$NODE_POOL_INDEX"
yq w -i /tmp/"$NAME"overrides.yaml spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key "$LABEL"
yq w -i /tmp/"$NAME"overrides.yaml spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator Exists
yq w -i /tmp/"$NAME"overrides.yaml spec.containers[+].name workspace
yq w -i /tmp/"$NAME"overrides.yaml "spec.containers.(name==workspace).env[+].name" GITPOD_PREVENT_METADATA_ACCESS
yq w -i /tmp/"$NAME"overrides.yaml "spec.containers.(name==workspace).env.(name==GITPOD_PREVENT_METADATA_ACCESS).value" "true"

yq w -i k8s.yaml -d "$documentIndex" "data.[default.yaml]" -- "$(< /tmp/"$NAME"overrides.yaml)"
fi
Expand Down
3 changes: 3 additions & 0 deletions components/common-go/analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ type TrackMessage struct {
func NewFromEnvironment() Writer {
switch os.Getenv("GITPOD_ANALYTICS_WRITER") {
case "log":
log.Debug("log analytics")
return &logAnalyticsWriter{}
case "segment":
log.Debug("segment analytics")
return &segmentAnalyticsWriter{Client: segment.New(os.Getenv("GITPOD_ANALYTICS_SEGMENT_KEY"))}
default:
log.Debug("no analytics")
return &noAnalyticsWriter{}
}
}
Expand Down
173 changes: 44 additions & 129 deletions components/gitpod-protocol/data/gitpod-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,140 +261,20 @@
}
},
"intellij": {
"type": "object",
"description": "Configure IntelliJ integration",
"additionalProperties": false,
"properties": {
"plugins": {
"type": "array",
"description": "List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install.",
"items": {
"type": "string"
}
},
"prebuilds": {
"type": "object",
"description": "Enable warming up of IntelliJ in prebuilds.",
"additionalProperties": false,
"properties": {
"version": {
"type": "string",
"enum": [
"stable",
"latest",
"both"
],
"description": "Whether only stable, latest or both versions should be warmed up. Default is stable only."
}
}
},
"vmoptions": {
"type": "string",
"description": "Configure JVM options, for instance '-Xmx=4096m'."
}
}
"$ref": "#/definitions/jetbrainsProduct",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to extract a common properties to the definition and stabilize code generation.

"description": "Configure IntelliJ integration"
},
"goland": {
"type": "object",
"description": "Configure GoLand integration",
"additionalProperties": false,
"properties": {
"plugins": {
"type": "array",
"description": "List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install.",
"items": {
"type": "string"
}
},
"prebuilds": {
"type": "object",
"description": "Enable warming up of GoLand in prebuilds.",
"additionalProperties": false,
"properties": {
"version": {
"type": "string",
"enum": [
"stable",
"latest",
"both"
],
"description": "Whether only stable, latest or both versions should be warmed up. Default is stable only."
}
}
},
"vmoptions": {
"type": "string",
"description": "Configure JVM options, for instance '-Xmx=4096m'."
}
}
"$ref": "#/definitions/jetbrainsProduct",
"description": "Configure GoLand integration"
},
"pycharm": {
"type": "object",
"description": "Configure PyCharm integration",
"additionalProperties": false,
"properties": {
"plugins": {
"type": "array",
"description": "List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install.",
"items": {
"type": "string"
}
},
"prebuilds": {
"type": "object",
"description": "Enable warming up of PyCharm in prebuilds.",
"additionalProperties": false,
"properties": {
"version": {
"type": "string",
"enum": [
"stable",
"latest",
"both"
],
"description": "Whether only stable, latest or both versions should be warmed up. Default is stable only."
}
}
},
"vmoptions": {
"type": "string",
"description": "Configure JVM options, for instance '-Xmx=4096m'."
}
}
"$ref": "#/definitions/jetbrainsProduct",
"description": "Configure PyCharm integration"
},
"phpstorm": {
"type": "object",
"description": "Configure PhpStorm integration",
"additionalProperties": false,
"properties": {
"plugins": {
"type": "array",
"description": "List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install.",
"items": {
"type": "string"
}
},
"prebuilds": {
"type": "object",
"description": "Enable warming up of PhpStorm in prebuilds.",
"additionalProperties": false,
"properties": {
"version": {
"type": "string",
"enum": [
"stable",
"latest",
"both"
],
"description": "Whether only stable, latest or both versions should be warmed up. Default is stable only."
}
}
},
"vmoptions": {
"type": "string",
"description": "Configure JVM options, for instance '-Xmx=4096m'."
}
}
"$ref": "#/definitions/jetbrainsProduct",
"description": "Configure PhpStorm integration"
}
}
},
Expand All @@ -404,5 +284,40 @@
"description": "Experimental network configuration in workspaces (deprecated). Enabled by default"
}
},
"additionalProperties": false
"additionalProperties": false,
"definitions": {
"jetbrainsProduct": {
"type": "object",
"additionalProperties": false,
"properties": {
"plugins": {
"type": "array",
"description": "List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install.",
"items": {
"type": "string"
}
},
"prebuilds": {
"type": "object",
"description": "Enable warming up of JetBrains backend in prebuilds.",
"additionalProperties": false,
"properties": {
"version": {
"type": "string",
"enum": [
"stable",
"latest",
"both"
],
"description": "Whether only stable, latest or both versions should be warmed up. Default is stable only."
}
}
},
"vmoptions": {
"type": "string",
"description": "Configure JVM options, for instance '-Xmx=4096m'."
}
}
}
}
}
Loading