Skip to content

Commit 757a159

Browse files
geroplroboquat
authored andcommitted
[server] Introduce Config and use it everywhere
1 parent a4f3803 commit 757a159

File tree

62 files changed

+576
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+576
-610
lines changed

.werft/build.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ export async function build(context, version) {
9090
const dontTest = "no-test" in buildConfig;
9191
const cacheLevel = "no-cache" in buildConfig ? "remote-push" : "remote";
9292
const publishRelease = "publish-release" in buildConfig;
93-
const workspaceFeatureFlags = (buildConfig["ws-feature-flags"] || "").split(",").map(e => e.trim())
93+
const workspaceFeatureFlags: string[] = ((): string[] => {
94+
const raw: string = buildConfig["ws-feature-flags"] || "";
95+
if (!raw) {
96+
return [];
97+
}
98+
return raw.split(",").map(e => e.trim());
99+
})();
94100
const dynamicCPULimits = "dynamic-cpu-limits" in buildConfig;
95101
const withInstaller = "with-installer" in buildConfig || mainBuild;
96102
const noPreview = ("no-preview" in buildConfig && buildConfig["no-preview"] !== "false") || publishRelease;
@@ -257,7 +263,7 @@ interface DeploymentConfig {
257263
/**
258264
* Deploy dev
259265
*/
260-
export async function deployToDev(deploymentConfig: DeploymentConfig, workspaceFeatureFlags, dynamicCPULimits, storage) {
266+
export async function deployToDev(deploymentConfig: DeploymentConfig, workspaceFeatureFlags: string[], dynamicCPULimits, storage) {
261267
werft.phase("deploy", "deploying to dev");
262268
const { version, destname, namespace, domain, url, k3sWsCluster } = deploymentConfig;
263269
const [wsdaemonPortMeta, registryNodePortMeta] = findFreeHostPorts("", [

.werft/values.dev.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ components:
4242
server:
4343
replicas: 1
4444
makeNewUsersAdmin: true # for development
45-
theiaPluginsBucketName: gitpod-core-dev-plugins
45+
theiaPluginsBucketNameOverride: gitpod-core-dev-plugins
4646
enableLocalApp: true
47-
enableOAuthServer: true
48-
blockNewUsers: true
49-
blockNewUsersPasslist:
50-
- "gitpod.io"
47+
oauthServer:
48+
enabled: true
49+
blockNewUsers:
50+
enabled: true
51+
passlist:
52+
- "gitpod.io"
5153
resources:
5254
# in preview envs, we want deployments to push scale-up early
5355
memory: 350Mi

chart/templates/proxy-deployment.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ spec:
8181
{{ include "gitpod.container.defaultEnv" (dict "root" . "gp" $.Values "comp" $comp) | indent 8 }}
8282
- name: PROXY_DOMAIN
8383
value: "{{ $.Values.hostname }}"
84-
- name: SERVER_PROXY_APIKEY
85-
valueFrom:
86-
secretKeyRef:
87-
name: server-proxy-apikey
88-
key: apikey
8984
volumes:
9085
- name: vhosts
9186
configMap:

chart/templates/server-configmap.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2+
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.
3+
4+
{{ $comp := .Values.components.server -}}
5+
{{- $this := dict "root" . "gp" $.Values "comp" $comp -}}
6+
apiVersion: v1
7+
kind: ConfigMap
8+
metadata:
9+
name: server-config
10+
labels:
11+
app: {{ template "gitpod.fullname" . }}
12+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
13+
release: "{{ .Release.Name }}"
14+
heritage: "{{ .Release.Service }}"
15+
data:
16+
config.json: |-
17+
{
18+
"version": "{{ template "gitpod.comp.version" $this }}",
19+
"hostUrl": "https://{{ .Values.hostname }}",
20+
"installationShortname": "{{ template "gitpod.installation.shortname" $this }}",
21+
"stage": "{{ .Values.installation.stage }}",
22+
{{- if .Values.devBranch }}
23+
"devBranch": "{{ .Values.devBranch }}",
24+
{{- end }}
25+
"license": "{{ .Values.license }}",
26+
"trialLicensePrivateKey": "{{ .Values.trialLicensePrivateKey }}",
27+
"workspaceHeartbeat": {{ $comp.workspaceHeartbeat | toJson }},
28+
"workspaceDefaults": {
29+
"ideVersion": "{{ template "gitpod.comp.version" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.theiaImage) }}",
30+
"ideImageRepo": "{{ template "gitpod.comp.imageRepo" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.theiaImage) }}",
31+
"ideImageAliases": {{ (dict "code" (include "gitpod.comp.imageFull" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage))) | toJson }},
32+
"workspaceImage": "{{ template "gitpod.comp.imageFull" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.defaultImage) }}",
33+
"previewFeatureFlags": {{ $comp.previewFeatureFlags | toJson }},
34+
"defaultFeatureFlags": {{ $comp.defaultFeatureFlags | toJson }}
35+
},
36+
"session": {{ $comp.session | toJson }},
37+
{{- if $comp.github.app }}
38+
"githubApp": {{ $comp.github.app | toJson }},
39+
{{- end }}
40+
"definitelyGpDisabled": {{ $comp.definitelyGpDisabled }},
41+
"workspaceGarbageCollection": {{ $comp.garbageCollection | toJson }},
42+
"enableLocalApp": {{ $comp.enableLocalApp }},
43+
"authProviderConfigs": {{ .Values.authProviders | toJson }},
44+
"disableDynamicAuthProviderLogin": {{ $comp.disableDynamicAuthProviderLogin }},
45+
"brandingConfig": {{ .Values.branding | toJson }},
46+
"maxEnvvarPerUserCount": {{ $comp.maxEnvvarPerUserCount }},
47+
"maxConcurrentPrebuildsPerRef": {{ $comp.maxConcurrentPrebuildsPerRef }},
48+
"incrementalPrebuilds": {{ $comp.incrementalPrebuilds | toJson }},
49+
"blockNewUsers": {{ $comp.blockNewUsers | toJson }},
50+
"makeNewUsersAdmin": {{ $comp.makeNewUsersAdmin }},
51+
{{- if $comp.theiaPluginsBucketNameOverride }}
52+
"theiaPluginsBucketNameOverride": "{{ $comp.theiaPluginsBucketNameOverride }}",
53+
{{- end }}
54+
"defaultBaseImageRegistryWhitelist": {{ $comp.defaultBaseImageRegistryWhitelist | toJson }},
55+
"runDbDeleter": {{ $comp.runDbDeleter }},
56+
"oauthServer": {
57+
"enabled": {{ $comp.oauthServer.enabled }}
58+
{{- if $comp.oauthServer.enabled }}
59+
, "jwtSecret": {{ (randAlphaNum 20) | quote }}
60+
{{- end }}
61+
},
62+
"rateLimiter": {{ $comp.rateLimiter | toJson }},
63+
"contentServiceAddr": {{ $comp.contentServiceAddr | quote }},
64+
"imageBuilderAddr": {{ $comp.imageBuilderAddr | quote }},
65+
{{- if $comp.serverProxyApiKey }}
66+
"serverProxyApiKey": "{{ $comp.serverProxyApiKey }}",
67+
{{- end }}
68+
"codeSync": {{ $comp.codeSync | toJson }},
69+
"enablePayment": {{ $comp.enablePayment }},
70+
"insecureNoDomain": {{ $comp.insecureNoDomain }}
71+
}

chart/templates/server-proxy-apikey-secret.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

chart/values.yaml

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ installation:
1818
shortname: ""
1919
kubedomain: "svc.cluster.local"
2020
license: ""
21+
trialLicensePrivateKey: ""
2122
installNetworkPolicies: true
2223
installPodSecurityPolicies: true
2324
imagePullPolicy: IfNotPresent
@@ -132,7 +133,6 @@ branding:
132133
url: https://www.gitpod.io/terms/
133134
workspaceScheduler: workspace-scheduler
134135
serverProxyApiKey: "fF7+aCPvF9Pa0AEjmoZ+yWVh6PqBjM5VEA0wyQs3FH4="
135-
previewFeatureFlags: []
136136

137137
components:
138138

@@ -290,20 +290,23 @@ components:
290290

291291
server:
292292
name: "server"
293-
dependsOn:
294-
- "server-proxy-apikey-secret.yaml"
295-
- "auth-providers-configmap.yaml"
296-
sessionSecret: Important!Really-Change-This-Key!
293+
dependsOn: []
297294
resources:
298295
cpu: "200m"
299296
github:
300-
app: {}
301-
blockNewUsers: false
302-
blockNewUsersPasslist: []
297+
app:
298+
enabled: false
299+
blockNewUsers:
300+
enabled: false
301+
passlist: []
303302
runDbDeleter: true
304303
storage: {}
305304
wsman: []
306305
defaultBaseImageRegistryWhitelist: []
306+
session:
307+
maxAgeMs: 259200000 # 3 days
308+
secret: Important!Really-Change-This-Key!
309+
previewFeatureFlags: []
307310
defaultFeatureFlags: []
308311
incrementalPrebuilds:
309312
repositoryPasslist: []
@@ -325,8 +328,44 @@ components:
325328
env: null
326329
volumes: null
327330
garbageCollection:
328-
disabled: "false"
331+
disabled: false
332+
startDate: null
333+
chunkLimit: 1000
334+
minAgeDays: 14
335+
minAgePrebuildDays: 7
336+
contentRetentionPeriodDays: 21
337+
contentChunkLimit: 1000
329338
definitelyGpDisabled: "false"
339+
enableLocalApp: true
340+
disableDynamicAuthProviderLogin: false
341+
maxEnvvarPerUserCount: 4048
342+
maxConcurrentPrebuildsPerRef: 10
343+
makeNewUsersAdmin: false
344+
theiaPluginsBucketNameOverride: null
345+
oauthServer:
346+
enabled: false
347+
rateLimiter:
348+
groups:
349+
inWorkspaceUserAction:
350+
points: 10
351+
durationsSec: 2
352+
functions:
353+
openPort:
354+
group: inWorkspaceUserAction
355+
closePort:
356+
group: inWorkspaceUserAction
357+
controlAdmission:
358+
group: inWorkspaceUserAction
359+
shareSnapshot:
360+
group: inWorkspaceUserAction
361+
contentServiceAddr: "content-service:8080"
362+
imageBuilderAddr: "image-builder-mk3:8080"
363+
codeSync: {}
364+
enablePayment: false
365+
workspaceHeartbeat:
366+
intervalSeconds: 60
367+
timeoutSeconds: 300
368+
insecureNoDomain: false
330369

331370
serviceWaiter:
332371
imageName: "service-waiter"
@@ -375,7 +414,6 @@ components:
375414
svcName: "proxy"
376415
dependsOn:
377416
- "proxy-configmap.yaml"
378-
- "server-proxy-apikey-secret.yaml"
379417
ports:
380418
http:
381419
containerPort: 80

components/server/ee/src/container-module.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import { WorkspaceFactoryEE } from "./workspace/workspace-factory";
3535
import { MonitoringEndpointsAppEE } from "./monitoring-endpoint-ee";
3636
import { MonitoringEndpointsApp } from "../../src/monitoring-endpoints";
3737
import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitoring";
38-
import { EnvEE } from "./env";
39-
import { Env } from "../../src/env";
4038
import { AccountService } from "@gitpod/gitpod-payment-endpoint/lib/accounting/account-service";
4139
import { AccountServiceImpl, SubscriptionService, TeamSubscriptionService } from "@gitpod/gitpod-payment-endpoint/lib/accounting";
4240
import { ChargebeeProvider, ChargebeeProviderOptions, UpgradeHelper } from "@gitpod/gitpod-payment-endpoint/lib/chargebee";
@@ -54,6 +52,7 @@ import { EMailDomainService, EMailDomainServiceImpl } from "./auth/email-domain-
5452
import { UserDeletionServiceEE } from "./user/user-deletion-service";
5553
import { GitHubAppSupport } from "./github/github-app-support";
5654
import { GitLabAppSupport } from "./gitlab/gitlab-app-support";
55+
import { Config } from "../../src/config";
5756

5857
export const productionEEContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
5958
rebind(Server).to(ServerEE).inSingletonScope();
@@ -87,9 +86,6 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
8786
bind(AccountStatementProvider).toSelf().inRequestScope();
8887

8988
// various
90-
bind(EnvEE).toSelf().inSingletonScope();
91-
rebind(Env).to(EnvEE).inSingletonScope();
92-
9389
rebind(MessageBusIntegration).to(MessageBusIntegrationEE).inSingletonScope();
9490
rebind(HostContainerMapping).to(HostContainerMappingEE).inSingletonScope();
9591
bind(EMailDomainService).to(EMailDomainServiceImpl).inSingletonScope();
@@ -110,8 +106,8 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
110106
// payment/billing
111107
bind(ChargebeeProvider).toSelf().inSingletonScope();
112108
bind(ChargebeeProviderOptions).toDynamicValue(ctx => {
113-
const env = ctx.container.get(EnvEE);
114-
return env.chargebeeProviderOptions;
109+
const config = ctx.container.get<Config>(Config);
110+
return config.chargebeeProviderOptions;
115111
}).inSingletonScope();
116112
bind(UpgradeHelper).toSelf().inSingletonScope();
117113
bind(ChargebeeCouponComputer).toSelf().inSingletonScope();

components/server/ee/src/license-source.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
import { LicenseKeySource } from "@gitpod/licensor/lib";
88
import { inject, injectable } from "inversify";
9-
import { Env } from "../../src/env";
109
import { LicenseDB } from "@gitpod/gitpod-db/lib";
1110
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
11+
import { Config } from "../../src/config";
1212

1313
@injectable()
1414
export class DBLicenseKeySource implements LicenseKeySource {
15-
@inject(Env) protected readonly env: Env;
15+
@inject(Config) protected readonly config: Config;
1616
@inject(LicenseDB) protected readonly licenseDB: LicenseDB;
1717

1818
async getKey(): Promise<{ key: string; domain: string; }> {
@@ -23,8 +23,8 @@ export class DBLicenseKeySource implements LicenseKeySource {
2323
log.error("cannot get license key - even if you have a license, the EE features won't work", err);
2424
}
2525
return {
26-
key: key || this.env.gitpodLicense || "",
27-
domain: this.env.hostUrl.url.host,
26+
key: key || this.config.license || "",
27+
domain: this.config.hostUrl.url.host,
2828
};
2929
}
3030
}

components/server/ee/src/prebuilds/bitbucket-service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { inject, injectable } from "inversify";
1010
import { BitbucketApiFactory } from "../../../src/bitbucket/bitbucket-api-factory";
1111
import { AuthProviderParams } from "../../../src/auth/auth-provider";
1212
import { BitbucketApp } from "./bitbucket-app";
13-
import { Env } from "../../../src/env";
13+
import { Config } from "../../../src/config";
1414
import { TokenService } from "../../../src/user/token-service";
1515
import { BitbucketContextParser } from "../../../src/bitbucket/bitbucket-context-parser";
1616

@@ -20,14 +20,14 @@ export class BitbucketService extends RepositoryService {
2020
static PREBUILD_TOKEN_SCOPE = 'prebuilds';
2121

2222
@inject(BitbucketApiFactory) protected api: BitbucketApiFactory;
23-
@inject(Env) protected env: Env;
24-
@inject(AuthProviderParams) protected config: AuthProviderParams;
23+
@inject(Config) protected readonly config: Config;
24+
@inject(AuthProviderParams) protected authProviderConfig: AuthProviderParams;
2525
@inject(TokenService) protected tokenService: TokenService;
2626
@inject(BitbucketContextParser) protected bitbucketContextParser: BitbucketContextParser;
2727

2828
async canInstallAutomatedPrebuilds(user: User, cloneUrl: string): Promise<boolean> {
2929
const { host } = await this.bitbucketContextParser.parseURL(user, cloneUrl);
30-
return host === this.config.host;
30+
return host === this.authProviderConfig.host;
3131
}
3232

3333
async installAutomatedPrebuilds(user: User, cloneUrl: string): Promise<void> {
@@ -50,7 +50,7 @@ export class BitbucketService extends RepositoryService {
5050
workspace: owner,
5151
// see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/hooks#post
5252
_body: {
53-
"description": `Gitpod Prebuilds for ${this.env.hostUrl}.`,
53+
"description": `Gitpod Prebuilds for ${this.config.hostUrl}.`,
5454
"url": hookUrl + `?token=${user.id + '|' + tokenEntry.token.value}`,
5555
"active": true,
5656
"events": [
@@ -68,7 +68,7 @@ export class BitbucketService extends RepositoryService {
6868
}
6969

7070
protected getHookUrl() {
71-
return this.env.hostUrl.with({
71+
return this.config.hostUrl.with({
7272
pathname: BitbucketApp.path
7373
}).toString();
7474
}

0 commit comments

Comments
 (0)