@gitpod/gitpod-protocol 0.1.5-pluggable-workspace-cluster.21 → 0.1.5-port-description-3059-fork.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/gitpod-schema.json +12 -22
- package/lib/accounting-protocol.d.ts +3 -6
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -16
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +15 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +15 -0
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +45 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/context-url.d.ts +18 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +49 -0
- package/lib/context-url.js.map +1 -0
- package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +2 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +73 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +4 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +94 -19
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +155 -278
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +81 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/{util/without.js → ide-protocol.js} +2 -2
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +4 -6
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +175 -44
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/connection-error-handler.js +11 -23
- package/lib/messaging/connection-error-handler.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +22 -22
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/permission.d.ts +2 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +14 -13
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +210 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +570 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +66 -13
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +68 -115
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +4 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +15 -12
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +103 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +23 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/util/analytics.d.ts +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +79 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.js +22 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +13 -67
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +34 -79
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +98 -98
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +6 -0
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +102 -30
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeater.js +35 -88
- package/lib/util/repeater.js.map +1 -1
- package/lib/util/safe-promise.js +9 -12
- package/lib/util/safe-promise.js.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +16 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +14 -1
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +84 -50
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/workspace-port-authentication.js +2 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +22 -3
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +3 -3
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +5 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +28 -16
- package/pkg-yarn.lock +17 -9
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +33 -5
- package/src/analytics.ts +54 -0
- package/src/context-url.spec.ts +39 -0
- package/src/context-url.ts +51 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +129 -35
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-protocol.ts +92 -0
- package/src/index.ts +5 -1
- package/src/messaging/browser/connection.ts +184 -23
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +5 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +2 -2
- package/src/messaging/proxy-factory.ts +13 -5
- package/src/permission.ts +2 -1
- package/src/plans.ts +632 -0
- package/src/protocol.ts +89 -18
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +7 -5
- package/src/teams-projects-protocol.ts +132 -0
- package/src/util/analytics.ts +87 -0
- package/src/util/garbage-collected-cache.ts +2 -2
- package/src/util/generate-workspace-id.spec.ts +3 -3
- package/src/util/generate-workspace-id.ts +2 -0
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +24 -0
- package/src/util/gitpod-host-url.ts +23 -10
- package/src/util/grpc.ts +15 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/semaphore.ts +2 -2
- package/src/util/skip-if.ts +1 -1
- package/src/util/timeutil.ts +4 -4
- package/src/util/tracing.ts +65 -3
- package/src/workspace-cluster.ts +24 -8
- package/src/workspace-instance.ts +25 -13
- package/src/wsready.ts +2 -2
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
|
@@ -12,8 +12,13 @@ export interface UrlChange {
|
|
|
12
12
|
}
|
|
13
13
|
export type UrlUpdate = UrlChange | Partial<URL>;
|
|
14
14
|
|
|
15
|
+
const basewoWkspaceIDRegex = "(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8}))";
|
|
16
|
+
|
|
15
17
|
// this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
|
|
16
|
-
|
|
18
|
+
const workspaceIDRegex = RegExp(`^${basewoWkspaceIDRegex}$`);
|
|
19
|
+
|
|
20
|
+
// this pattern matches URL prefixes of workspaces
|
|
21
|
+
const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${basewoWkspaceIDRegex}\\.`);
|
|
17
22
|
|
|
18
23
|
export class GitpodHostUrl {
|
|
19
24
|
readonly url: URL;
|
|
@@ -44,7 +49,7 @@ export class GitpodHostUrl {
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
withoutWorkspacePrefix(): GitpodHostUrl {
|
|
47
|
-
if (!this.url.host.match(
|
|
52
|
+
if (!this.url.host.match(workspaceUrlPrefixRegex)) {
|
|
48
53
|
// URL has no workspace prefix
|
|
49
54
|
return this;
|
|
50
55
|
}
|
|
@@ -80,23 +85,27 @@ export class GitpodHostUrl {
|
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
asDashboard(): GitpodHostUrl {
|
|
83
|
-
return this.with(url => ({ pathname: '/
|
|
88
|
+
return this.with(url => ({ pathname: '/' }));
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
asLogin(): GitpodHostUrl {
|
|
87
|
-
return this.with(url => ({ pathname: '/login
|
|
92
|
+
return this.with(url => ({ pathname: '/login' }));
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
asUpgradeSubscription(): GitpodHostUrl {
|
|
91
|
-
return this.with(url => ({ pathname: '/
|
|
96
|
+
return this.with(url => ({ pathname: '/plans' }));
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
asAccessControl(): GitpodHostUrl {
|
|
95
|
-
return this.with(url => ({ pathname: '/
|
|
100
|
+
return this.with(url => ({ pathname: '/integrations' }));
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
asSettings(): GitpodHostUrl {
|
|
99
|
-
return this.with(url => ({ pathname: '/settings
|
|
104
|
+
return this.with(url => ({ pathname: '/settings' }));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
asPreferences(): GitpodHostUrl {
|
|
108
|
+
return this.with(url => ({ pathname: '/preferences' }));
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
asGraphQLApi(): GitpodHostUrl {
|
|
@@ -128,9 +137,13 @@ export class GitpodHostUrl {
|
|
|
128
137
|
|
|
129
138
|
get workspaceId(): string | undefined {
|
|
130
139
|
const hostSegs = this.url.host.split(".");
|
|
131
|
-
if (hostSegs.length > 1
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
if (hostSegs.length > 1) {
|
|
141
|
+
const matchResults = hostSegs[0].match(workspaceIDRegex);
|
|
142
|
+
if (matchResults) {
|
|
143
|
+
// URL has a workspace prefix
|
|
144
|
+
// port prefixes are excluded
|
|
145
|
+
return matchResults[0];
|
|
146
|
+
}
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
const pathSegs = this.url.pathname.split("/")
|
package/src/util/grpc.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License-AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const defaultGRPCOptions = {
|
|
8
|
+
"grpc.keepalive_timeout_ms": 10000,
|
|
9
|
+
"grpc.keepalive_time_ms": 60000,
|
|
10
|
+
"grpc.http2.min_time_between_pings_ms": 10000,
|
|
11
|
+
"grpc.keepalive_permit_without_calls": 1,
|
|
12
|
+
"grpc-node.max_session_memory": 50,
|
|
13
|
+
"grpc.max_reconnect_backoff_ms": 5000,
|
|
14
|
+
"grpc.max_receive_message_length": 1024 * 1024 * 16,
|
|
15
|
+
};
|
package/src/util/logging.ts
CHANGED
|
@@ -30,66 +30,66 @@ export interface LogPayload {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export namespace log {
|
|
33
|
-
export function error(context: LogContext, message: string, error:
|
|
34
|
-
export function error(context: LogContext, message: string, error:
|
|
33
|
+
export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
34
|
+
export function error(context: LogContext, message: string, error: any): void;
|
|
35
35
|
export function error(context: LogContext, message: string, payload: LogPayload): void;
|
|
36
36
|
export function error(context: LogContext, message: string): void;
|
|
37
|
-
export function error(context: LogContext, error:
|
|
38
|
-
export function error(context: LogContext, error:
|
|
39
|
-
export function error(message: string, error:
|
|
40
|
-
export function error(message: string, error:
|
|
37
|
+
export function error(context: LogContext, error: any, payload: LogPayload): void;
|
|
38
|
+
export function error(context: LogContext, error: any): void;
|
|
39
|
+
export function error(message: string, error: any, payload: LogPayload): void;
|
|
40
|
+
export function error(message: string, error: any): void;
|
|
41
41
|
export function error(message: string, payload: LogPayload): void;
|
|
42
42
|
export function error(message: string): void;
|
|
43
|
-
export function error(error:
|
|
44
|
-
export function error(error:
|
|
43
|
+
export function error(error: any, payload: LogPayload): void;
|
|
44
|
+
export function error(error: any): void;
|
|
45
45
|
export function error(...args: any[]): void {
|
|
46
46
|
errorLog(false, args);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function warn(context: LogContext, message: string, error:
|
|
50
|
-
export function warn(context: LogContext, message: string, error:
|
|
49
|
+
export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
50
|
+
export function warn(context: LogContext, message: string, error: any): void;
|
|
51
51
|
export function warn(context: LogContext, message: string, payload: LogPayload): void;
|
|
52
52
|
export function warn(context: LogContext, message: string): void;
|
|
53
|
-
export function warn(context: LogContext, error:
|
|
54
|
-
export function warn(context: LogContext, error:
|
|
55
|
-
export function warn(message: string, error:
|
|
56
|
-
export function warn(message: string, error:
|
|
53
|
+
export function warn(context: LogContext, error: any, payload: LogPayload): void;
|
|
54
|
+
export function warn(context: LogContext, error: any): void;
|
|
55
|
+
export function warn(message: string, error: any, payload: LogPayload): void;
|
|
56
|
+
export function warn(message: string, error: any): void;
|
|
57
57
|
export function warn(message: string, payload: LogPayload): void;
|
|
58
58
|
export function warn(message: string): void;
|
|
59
|
-
export function warn(error:
|
|
60
|
-
export function warn(error:
|
|
59
|
+
export function warn(error: any, payload: LogPayload): void;
|
|
60
|
+
export function warn(error: any): void;
|
|
61
61
|
export function warn(...args: any[]): void {
|
|
62
62
|
warnLog(false, args);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function info(context: LogContext, message: string, error:
|
|
66
|
-
export function info(context: LogContext, message: string, error:
|
|
65
|
+
export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
66
|
+
export function info(context: LogContext, message: string, error: any): void;
|
|
67
67
|
export function info(context: LogContext, message: string, payload: LogPayload): void;
|
|
68
68
|
export function info(context: LogContext, message: string): void;
|
|
69
|
-
export function info(context: LogContext, error:
|
|
70
|
-
export function info(context: LogContext, error:
|
|
71
|
-
export function info(message: string, error:
|
|
72
|
-
export function info(message: string, error:
|
|
69
|
+
export function info(context: LogContext, error: any, payload: LogPayload): void;
|
|
70
|
+
export function info(context: LogContext, error: any): void;
|
|
71
|
+
export function info(message: string, error: any, payload: LogPayload): void;
|
|
72
|
+
export function info(message: string, error: any): void;
|
|
73
73
|
export function info(message: string, payload: LogPayload): void;
|
|
74
74
|
export function info(message: string): void;
|
|
75
|
-
export function info(error:
|
|
76
|
-
export function info(error:
|
|
75
|
+
export function info(error: any, payload: LogPayload): void;
|
|
76
|
+
export function info(error: any): void;
|
|
77
77
|
export function info(...args: any[]): void {
|
|
78
78
|
infoLog(false, args);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export function debug(context: LogContext, message: string, error:
|
|
82
|
-
export function debug(context: LogContext, message: string, error:
|
|
81
|
+
export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
82
|
+
export function debug(context: LogContext, message: string, error: any): void;
|
|
83
83
|
export function debug(context: LogContext, message: string, payload: LogPayload): void;
|
|
84
84
|
export function debug(context: LogContext, message: string): void;
|
|
85
|
-
export function debug(context: LogContext, error:
|
|
86
|
-
export function debug(context: LogContext, error:
|
|
87
|
-
export function debug(message: string, error:
|
|
88
|
-
export function debug(message: string, error:
|
|
85
|
+
export function debug(context: LogContext, error: any, payload: LogPayload): void;
|
|
86
|
+
export function debug(context: LogContext, error: any): void;
|
|
87
|
+
export function debug(message: string, error: any, payload: LogPayload): void;
|
|
88
|
+
export function debug(message: string, error: any): void;
|
|
89
89
|
export function debug(message: string, payload: LogPayload): void;
|
|
90
90
|
export function debug(message: string): void;
|
|
91
|
-
export function debug(error:
|
|
92
|
-
export function debug(error:
|
|
91
|
+
export function debug(error: any, payload: LogPayload): void;
|
|
92
|
+
export function debug(error: any): void;
|
|
93
93
|
export function debug(...args: any[]): void {
|
|
94
94
|
debugLog(false, args);
|
|
95
95
|
}
|
|
@@ -97,10 +97,14 @@ export namespace log {
|
|
|
97
97
|
/**
|
|
98
98
|
* Do not use in frontend.
|
|
99
99
|
*/
|
|
100
|
-
export function enableJSONLogging(componentArg: string, versionArg: string | undefined): void {
|
|
100
|
+
export function enableJSONLogging(componentArg: string, versionArg: string | undefined, logLevel?: LogrusLogLevel): void {
|
|
101
101
|
component = componentArg;
|
|
102
102
|
version = versionArg;
|
|
103
103
|
|
|
104
|
+
setLogLevel(logLevel);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
|
|
104
108
|
jsonLogging = true;
|
|
105
109
|
|
|
106
110
|
console.error = function (...args: any[]): void {
|
|
@@ -115,8 +119,20 @@ export namespace log {
|
|
|
115
119
|
console.debug = function (...args: any[]): void {
|
|
116
120
|
debugLog(true, args);
|
|
117
121
|
}
|
|
122
|
+
|
|
118
123
|
console.log = console.info;
|
|
119
124
|
// FIXME wrap also other console methods (e.g. trace())
|
|
125
|
+
|
|
126
|
+
// set/unset log functions based on loglevel so we only have to evaluate once, not every call
|
|
127
|
+
const noop = () => {};
|
|
128
|
+
const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
|
|
129
|
+
return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
errorLog = setLog(doErrorLog, "error");
|
|
133
|
+
warnLog = setLog(doWarnLog, "warning");
|
|
134
|
+
infoLog = setLog(doInfoLog, "info");
|
|
135
|
+
debugLog = setLog(doDebugLog, "debug");
|
|
120
136
|
}
|
|
121
137
|
|
|
122
138
|
export function resetToDefaultLogging(): void {
|
|
@@ -128,24 +144,73 @@ export namespace log {
|
|
|
128
144
|
console.info = infoConsoleLog;
|
|
129
145
|
console.debug = debugConsoleLog;
|
|
130
146
|
}
|
|
147
|
+
|
|
148
|
+
export function setVersion(versionArg: string) {
|
|
149
|
+
version = versionArg;
|
|
150
|
+
}
|
|
131
151
|
}
|
|
132
152
|
|
|
133
|
-
|
|
153
|
+
type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
|
|
154
|
+
|
|
155
|
+
let errorLog = doErrorLog;
|
|
156
|
+
function doErrorLog(calledViaConsole: boolean, args: any[]): void {
|
|
134
157
|
doLog(calledViaConsole, errorConsoleLog, 'ERROR', args);
|
|
135
158
|
}
|
|
136
159
|
|
|
137
|
-
|
|
160
|
+
let warnLog = doWarnLog;
|
|
161
|
+
function doWarnLog(calledViaConsole: boolean, args: any[]): void {
|
|
138
162
|
doLog(calledViaConsole, warnConsoleLog, 'WARNING', args);
|
|
139
163
|
}
|
|
140
164
|
|
|
141
|
-
|
|
165
|
+
let infoLog = doInfoLog;
|
|
166
|
+
function doInfoLog(calledViaConsole: boolean, args: any[]): void {
|
|
142
167
|
doLog(calledViaConsole, infoConsoleLog, 'INFO', args);
|
|
143
168
|
}
|
|
144
169
|
|
|
145
|
-
|
|
170
|
+
let debugLog = doDebugLog;
|
|
171
|
+
function doDebugLog(calledViaConsole: boolean, args: any[]): void {
|
|
146
172
|
doLog(calledViaConsole, debugConsoleLog, 'DEBUG', args);
|
|
147
173
|
}
|
|
148
174
|
|
|
175
|
+
// Ref: https://github.com/sirupsen/logrus#level-logging
|
|
176
|
+
export type LogrusLogLevel = keyof (typeof LogrusLogLevels);
|
|
177
|
+
export const LogrusLogLevels = {
|
|
178
|
+
trace: true,
|
|
179
|
+
debug: true,
|
|
180
|
+
info: true,
|
|
181
|
+
warning: true,
|
|
182
|
+
error: true,
|
|
183
|
+
fatal: true,
|
|
184
|
+
panic: true,
|
|
185
|
+
}
|
|
186
|
+
export namespace LogrusLogLevel {
|
|
187
|
+
export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
|
|
188
|
+
if (lvl === undefined) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (ref === undefined) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
return getLevelArity(lvl) >= getLevelArity(ref);
|
|
195
|
+
}
|
|
196
|
+
function getLevelArity(lvl: LogrusLogLevel): number {
|
|
197
|
+
return Object.keys(LogrusLogLevels)
|
|
198
|
+
.findIndex((l) => l === lvl);
|
|
199
|
+
}
|
|
200
|
+
export function getFromEnv(): LogrusLogLevel | undefined {
|
|
201
|
+
const lvlStr = process.env.LOG_LEVEL;
|
|
202
|
+
if (!lvlStr) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
const lvl = lvlStr as LogrusLogLevel;
|
|
206
|
+
const exists = LogrusLogLevels[lvl]
|
|
207
|
+
if (!exists) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
return lvl;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
149
214
|
// Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
|
150
215
|
type GoogleLogSeverity = 'EMERGENCY' | 'ALERT' | 'CRITICAL' | 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
|
|
151
216
|
namespace GoogleLogSeverity {
|
|
@@ -243,7 +308,6 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
|
|
|
243
308
|
severity,
|
|
244
309
|
time: new Date().toISOString(),
|
|
245
310
|
environment: process.env.KUBE_STAGE,
|
|
246
|
-
region: process.env.GITPOD_REGION,
|
|
247
311
|
context,
|
|
248
312
|
message,
|
|
249
313
|
error,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import * as chai from 'chai';
|
|
8
8
|
import { suite, test } from 'mocha-typescript';
|
|
9
|
-
import { parseWorkspaceIdFromHostname } from './parse-workspace-id';
|
|
9
|
+
import { matchesInstanceIdOrLegacyWorkspaceIdExactly, matchesNewWorkspaceIdExactly, parseWorkspaceIdFromHostname } from './parse-workspace-id';
|
|
10
10
|
const expect = chai.expect;
|
|
11
11
|
|
|
12
12
|
@suite
|
|
@@ -52,5 +52,25 @@ export class ParseWorkspaceIdTest {
|
|
|
52
52
|
const actual = parseWorkspaceIdFromHostname("webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com");
|
|
53
53
|
expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
// match - instance ID
|
|
57
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
|
|
58
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
59
|
+
expect(actual).to.be.true;
|
|
60
|
+
}
|
|
61
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
|
|
62
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
|
|
63
|
+
expect(actual).to.be.false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// match - new workspace ID
|
|
67
|
+
@test public matchesWorkspaceIdExactly_new_positive() {
|
|
68
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
|
|
69
|
+
expect(actual).to.be.true;
|
|
70
|
+
}
|
|
71
|
+
@test public matchesWorkspaceIdExactly_new_negative() {
|
|
72
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
|
|
73
|
+
expect(actual).to.be.false;
|
|
74
|
+
}
|
|
55
75
|
}
|
|
56
76
|
module.exports = new ParseWorkspaceIdTest()
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8}/;
|
|
8
|
+
const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
|
|
9
|
+
// We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
|
|
10
|
+
const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
|
|
11
|
+
|
|
12
|
+
const REGEX_WORKSPACE_ID_LEGACY = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
13
|
+
const REGEX_WORKSPACE_ID_LEGACY_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID_LEGACY.source}$`);
|
|
14
|
+
const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID_LEGACY.source})\.ws`);
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hostname may be of the form:
|
|
@@ -13,17 +21,35 @@
|
|
|
13
21
|
* @param hostname The hostname the request is headed to
|
|
14
22
|
*/
|
|
15
23
|
export const parseWorkspaceIdFromHostname = function(hostname: string) {
|
|
16
|
-
|
|
17
|
-
const wsIdExpression = /([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8})\.ws/g;
|
|
18
|
-
const match = wsIdExpression.exec(hostname);
|
|
24
|
+
const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
|
|
19
25
|
if (match && match.length >= 2) {
|
|
20
26
|
return match[1];
|
|
21
27
|
} else {
|
|
22
|
-
const
|
|
23
|
-
const legacyMatch = legacyUrlFormat.exec(hostname);
|
|
28
|
+
const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
|
|
24
29
|
if (legacyMatch && legacyMatch.length >= 2) {
|
|
25
30
|
return legacyMatch[1];
|
|
26
31
|
}
|
|
27
32
|
return undefined;
|
|
28
33
|
}
|
|
29
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Equalls UUIDv4 (and REGEX_WORKSPACE_ID_LEGACY!) */
|
|
37
|
+
const REGEX_INSTANCE_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
38
|
+
const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param maybeId
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function(maybeId: string): boolean {
|
|
45
|
+
return REGEX_INSTANCE_ID_EXACT.test(maybeId)
|
|
46
|
+
|| REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param maybeWorkspaceId
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
export const matchesNewWorkspaceIdExactly = function(maybeWorkspaceId: string): boolean {
|
|
54
|
+
return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
|
|
55
|
+
};
|
package/src/util/semaphore.ts
CHANGED
|
@@ -9,7 +9,7 @@ export class Semaphore {
|
|
|
9
9
|
protected queue: (() => void)[] = [];
|
|
10
10
|
protected used: number;
|
|
11
11
|
|
|
12
|
-
constructor(protected readonly capacity: number) {
|
|
12
|
+
constructor(protected readonly capacity: number) {
|
|
13
13
|
if(capacity < 1) {
|
|
14
14
|
throw new Error("Capacity cannot be less than 1");
|
|
15
15
|
}
|
|
@@ -17,7 +17,7 @@ export class Semaphore {
|
|
|
17
17
|
|
|
18
18
|
public release() {
|
|
19
19
|
if(this.used == 0) return;
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
const queued = this.queue.shift();
|
|
22
22
|
if (queued) {
|
|
23
23
|
queued();
|
package/src/util/skip-if.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function skipIf(doSkip: (suite: TestSuiteContext) => boolean): MochaTypeS
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
// Mark as "trait": mimics the behavior of https://github.com/testdeck/testdeck/blob/9d2dd6a458c2c86c945f6f2999b8278b7528a7a7/index.ts#L433
|
|
32
32
|
(trait as any)["__mts_isTrait"] = true;
|
|
33
33
|
return trait;
|
package/src/util/timeutil.ts
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Returns the <code>day</code>th of the next month from <code>formDate</code>.
|
|
9
|
-
* If the next month does not have a <code>day</code>th, the last day of that
|
|
9
|
+
* If the next month does not have a <code>day</code>th, the last day of that
|
|
10
10
|
* month is taken.
|
|
11
11
|
* The time is copied from <code>fromDate</code>.
|
|
12
|
-
*
|
|
13
|
-
* @param fromDate
|
|
14
|
-
* @param day
|
|
12
|
+
*
|
|
13
|
+
* @param fromDate
|
|
14
|
+
* @param day
|
|
15
15
|
*/
|
|
16
16
|
export function oneMonthLater(fromDate: string, day?: number): string {
|
|
17
17
|
const later = new Date(fromDate);
|
package/src/util/tracing.ts
CHANGED
|
@@ -9,19 +9,29 @@ import * as opentracing from 'opentracing';
|
|
|
9
9
|
import { TracingConfig, initTracerFromEnv, Sampler, SamplingDecision } from 'jaeger-client';
|
|
10
10
|
import { initGlobalTracer } from 'opentracing';
|
|
11
11
|
import { injectable } from 'inversify';
|
|
12
|
+
import { ResponseError } from 'vscode-jsonrpc';
|
|
12
13
|
|
|
13
14
|
export interface TraceContext {
|
|
14
15
|
span?: opentracing.Span
|
|
15
16
|
}
|
|
17
|
+
export type TraceContextWithSpan = TraceContext & {
|
|
18
|
+
span: opentracing.Span
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
export namespace TraceContext {
|
|
18
|
-
export function startSpan(operation: string,
|
|
23
|
+
export function startSpan(operation: string, parentCtx: TraceContext): opentracing.Span {
|
|
19
24
|
const options: opentracing.SpanOptions = {
|
|
20
|
-
childOf:
|
|
25
|
+
childOf: parentCtx.span
|
|
21
26
|
}
|
|
22
27
|
return opentracing.globalTracer().startSpan(operation, options);
|
|
23
28
|
}
|
|
24
29
|
|
|
30
|
+
export function childContextWithSpan(operation: string, parentCtx: TraceContext): TraceContextWithSpan {
|
|
31
|
+
const span = startSpan(operation, parentCtx);
|
|
32
|
+
return { span };
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
export function startAsyncSpan(operation: string, ctx: TraceContext): opentracing.Span {
|
|
26
36
|
const options: opentracing.SpanOptions = {};
|
|
27
37
|
if (!!ctx.span) {
|
|
@@ -39,7 +49,42 @@ export namespace TraceContext {
|
|
|
39
49
|
"error": err.message,
|
|
40
50
|
"stacktrace": err.stack
|
|
41
51
|
})
|
|
42
|
-
ctx.span.setTag("error", true)
|
|
52
|
+
ctx.span.setTag("error", true);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function logJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>) {
|
|
56
|
+
if (!ctx.span) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
logError(ctx, err);
|
|
60
|
+
|
|
61
|
+
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
|
|
62
|
+
ctx.span.addTags({
|
|
63
|
+
rpc: {
|
|
64
|
+
system: "jsonrpc",
|
|
65
|
+
method,
|
|
66
|
+
jsonrpc: {
|
|
67
|
+
error_code: err.code,
|
|
68
|
+
error_message: err.message,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function addJsonRPCParameters(ctx: TraceContext, method: string, args: any[]) {
|
|
75
|
+
if (!ctx.span) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
ctx.span.addTags({
|
|
80
|
+
rpc: {
|
|
81
|
+
system: "jsonrpc",
|
|
82
|
+
method,
|
|
83
|
+
jsonrpc: {
|
|
84
|
+
parameters: args.slice(),
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
43
88
|
}
|
|
44
89
|
}
|
|
45
90
|
|
|
@@ -132,3 +177,20 @@ export class PerOperationSampler implements Sampler {
|
|
|
132
177
|
}
|
|
133
178
|
}
|
|
134
179
|
}
|
|
180
|
+
|
|
181
|
+
// Augment interfaces with an leading parameter "TraceContext" on every method
|
|
182
|
+
type IsValidArg<T> = T extends object ? keyof T extends never ? false : true : true;
|
|
183
|
+
type AddTraceContext<T> =
|
|
184
|
+
T extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E, f: infer F) => infer R ? (
|
|
185
|
+
IsValidArg<F> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E, f: F) => R :
|
|
186
|
+
IsValidArg<E> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E) => R :
|
|
187
|
+
IsValidArg<D> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D) => R :
|
|
188
|
+
IsValidArg<C> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C) => R :
|
|
189
|
+
IsValidArg<B> extends true ? (ctx: TraceContextWithSpan, a: A, b: B) => R :
|
|
190
|
+
IsValidArg<A> extends true ? (ctx: TraceContextWithSpan, a: A) => R :
|
|
191
|
+
(ctx: TraceContextWithSpan) => Promise<R>
|
|
192
|
+
) : never;
|
|
193
|
+
|
|
194
|
+
export type InterfaceWithTraceContext<T> = {
|
|
195
|
+
[P in keyof T]: AddTraceContext<T[P]>
|
|
196
|
+
};
|
package/src/workspace-cluster.ts
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import { filePathTelepresenceAware } from './env';
|
|
9
9
|
import { DeepPartial } from "./util/deep-partial";
|
|
10
|
-
import {
|
|
10
|
+
import { PermissionName } from './permission';
|
|
11
11
|
|
|
12
12
|
export interface WorkspaceCluster {
|
|
13
13
|
// Name of the workspace cluster.
|
|
14
|
-
// This is the string set in each
|
|
14
|
+
// This is the string set in each
|
|
15
15
|
// Must be identical to the installationShortname of the cluster it represents!
|
|
16
16
|
name: string;
|
|
17
17
|
|
|
@@ -32,7 +32,14 @@ export interface WorkspaceCluster {
|
|
|
32
32
|
|
|
33
33
|
// True if this bridge should control this cluster
|
|
34
34
|
govern: boolean;
|
|
35
|
+
|
|
36
|
+
// An optional set of constraints that limit who can start workspaces on the cluster
|
|
37
|
+
admissionConstraints?: AdmissionConstraint[];
|
|
38
|
+
|
|
39
|
+
// An optional set of admission preferences that guide cluster selection
|
|
40
|
+
admissionPreferences?: AdmissionPreference[];
|
|
35
41
|
}
|
|
42
|
+
|
|
36
43
|
export type WorkspaceClusterState = "available" | "cordoned" | "draining";
|
|
37
44
|
export interface TLSConfig {
|
|
38
45
|
// the CA shared between client and server (base64 encoded)
|
|
@@ -45,35 +52,44 @@ export interface TLSConfig {
|
|
|
45
52
|
export namespace TLSConfig {
|
|
46
53
|
export const loadFromBase64File = (path: string): string => fs.readFileSync(filePathTelepresenceAware(path)).toString("base64");
|
|
47
54
|
}
|
|
48
|
-
export type
|
|
55
|
+
export type WorkspaceClusterWoTLS = Omit<WorkspaceCluster, "tls">;
|
|
49
56
|
export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "url" | "tls">;
|
|
50
57
|
|
|
58
|
+
export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasRole | AdmissionConstraintHasUserLevel;
|
|
59
|
+
export type AdmissionConstraintFeaturePreview = { type: "has-feature-preview" };
|
|
60
|
+
export type AdmissionConstraintHasRole = { type: "has-permission", permission: PermissionName };
|
|
61
|
+
export type AdmissionConstraintHasUserLevel = { type: "has-user-level", level: string };
|
|
62
|
+
|
|
63
|
+
export type AdmissionPreference = AdmissionPreferenceUserLevel;
|
|
64
|
+
export type AdmissionPreferenceUserLevel = { type: 'user-level', level: string };
|
|
65
|
+
|
|
66
|
+
|
|
51
67
|
export const WorkspaceClusterDB = Symbol("WorkspaceClusterDB");
|
|
52
68
|
export interface WorkspaceClusterDB {
|
|
53
69
|
/**
|
|
54
70
|
* Stores the given WorkspaceCluster to the cluster-local DB in a consistent manner.
|
|
55
71
|
* If there already is an entry with the same name it's merged and updated with the given state.
|
|
56
|
-
* @param cluster
|
|
72
|
+
* @param cluster
|
|
57
73
|
*/
|
|
58
74
|
save(cluster: WorkspaceCluster): Promise<void>;
|
|
59
75
|
|
|
60
76
|
/**
|
|
61
77
|
* Deletes the cluster identified by this name, if any.
|
|
62
|
-
* @param name
|
|
78
|
+
* @param name
|
|
63
79
|
*/
|
|
64
80
|
deleteByName(name: string): Promise<void>;
|
|
65
81
|
|
|
66
82
|
/**
|
|
67
83
|
* Finds a WorkspaceCluster with the given name. If there is none, `undefined` is returned.
|
|
68
|
-
* @param name
|
|
84
|
+
* @param name
|
|
69
85
|
*/
|
|
70
86
|
findByName(name: string): Promise<WorkspaceCluster | undefined>;
|
|
71
87
|
|
|
72
88
|
/**
|
|
73
89
|
* Lists all WorkspaceClusterWoTls for which the given predicate is true (does not return TLS for size/speed concerns)
|
|
74
|
-
* @param predicate
|
|
90
|
+
* @param predicate
|
|
75
91
|
*/
|
|
76
|
-
findFiltered(predicate: DeepPartial<WorkspaceClusterFilter>): Promise<
|
|
92
|
+
findFiltered(predicate: DeepPartial<WorkspaceClusterFilter>): Promise<WorkspaceClusterWoTLS[]>;
|
|
77
93
|
}
|
|
78
94
|
export interface WorkspaceClusterFilter extends Pick<WorkspaceCluster, "state" | "govern" | "url"> {
|
|
79
95
|
minScore: number;
|