@gitpod/gitpod-protocol 0.1.5-sje-pacman.1 → 0.1.5-sje-kots-node-reqs.1
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 +153 -2
- package/lib/accounting-protocol.d.ts +7 -0
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +8 -1
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +4 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/attribution.d.ts +20 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +40 -0
- package/lib/attribution.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/context-url.js +1 -1
- package/lib/context-url.js.map +1 -1
- package/lib/env.d.ts +0 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +1 -20
- package/lib/env.js.map +1 -1
- package/lib/experiments/always-default.d.ts +8 -0
- package/lib/experiments/always-default.d.ts.map +1 -0
- package/lib/experiments/always-default.js +20 -0
- package/lib/experiments/always-default.js.map +1 -0
- package/lib/experiments/configcat-server.d.ts +8 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -0
- package/lib/experiments/configcat-server.js +35 -0
- package/lib/experiments/configcat-server.js.map +1 -0
- package/lib/experiments/configcat.d.ts +22 -0
- package/lib/experiments/configcat.d.ts.map +1 -0
- package/lib/experiments/configcat.js +53 -0
- package/lib/experiments/configcat.js.map +1 -0
- package/lib/experiments/types.d.ts +23 -0
- package/lib/experiments/types.d.ts.map +1 -0
- package/lib/experiments/types.js +10 -0
- package/lib/experiments/types.js.map +1 -0
- package/lib/gitpod-service.d.ts +29 -5
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +20 -10
- package/lib/gitpod-service.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +3 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +1 -0
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts +7 -0
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -0
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -0
- package/lib/messaging/error.js.map +1 -1
- package/lib/protocol.d.ts +86 -4
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +183 -12
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +16 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +12 -1
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +18 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/usage.d.ts +22 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +115 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/debug-app.d.ts +25 -0
- package/lib/util/debug-app.d.ts.map +1 -0
- package/lib/util/debug-app.js +100 -0
- package/lib/util/debug-app.js.map +1 -0
- package/lib/util/generate-workspace-id.d.ts +5 -0
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +12 -8
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +10 -3
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +9 -2
- package/lib/util/logging.js.map +1 -1
- package/lib/util/timeutil.d.ts +1 -0
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +7 -1
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +8 -10
- package/lib/util/tracing.js.map +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/webhook-event.js +8 -0
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-cluster.d.ts +5 -7
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +17 -1
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.js +1 -1
- package/package.json +9 -6
- package/pkg-yarn.lock +7 -5
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +10 -0
- package/src/admin-protocol.ts +7 -0
- package/src/attribution.ts +48 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.ts +1 -1
- package/src/env.ts +0 -22
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +38 -0
- package/src/experiments/configcat.ts +58 -0
- package/src/experiments/types.ts +35 -0
- package/src/gitpod-service.ts +54 -11
- package/src/index.ts +1 -0
- package/src/installation-admin-protocol.ts +3 -0
- package/src/license-protocol.ts +7 -0
- package/src/messaging/error.ts +6 -0
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +258 -13
- package/src/team-subscription-protocol.ts +24 -0
- package/src/teams-projects-protocol.ts +20 -0
- package/src/usage.ts +146 -0
- package/src/util/debug-app.ts +81 -0
- package/src/util/generate-workspace-id.spec.ts +10 -3
- package/src/util/generate-workspace-id.ts +9 -3
- package/src/util/logging.ts +11 -3
- package/src/util/timeutil.ts +6 -0
- package/src/util/tracing.ts +8 -10
- package/src/webhook-event.ts +55 -0
- package/src/workspace-cluster.ts +2 -4
- package/src/workspace-instance.ts +30 -1
- package/src/wsready.ts +1 -1
|
@@ -14,7 +14,7 @@ const expect = chai.expect;
|
|
|
14
14
|
@suite
|
|
15
15
|
class TestGenerateWorkspaceId {
|
|
16
16
|
@test public async testGenerateWorkspaceId() {
|
|
17
|
-
for (let i = 0; i <
|
|
17
|
+
for (let i = 0; i < 10; i++) {
|
|
18
18
|
const id = await generateWorkspaceID();
|
|
19
19
|
expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
|
|
20
20
|
}
|
|
@@ -32,13 +32,20 @@ class TestGenerateWorkspaceId {
|
|
|
32
32
|
["foo", "bar", "foo-bar-"],
|
|
33
33
|
["f", "bar", ".{2,16}-bar-"],
|
|
34
34
|
["gitpod-io", "gitpod", "gitpodio-gitpod-"],
|
|
35
|
+
["breatheco-de", "python-flask-api-tutorial", "breathecode-pythonflask-"],
|
|
36
|
+
["short", "muchlongerthaneleven", "short-muchlongerthanel-"],
|
|
37
|
+
["muchlongerthaneleven", "short", "muchlongerthanel-short-"],
|
|
35
38
|
[
|
|
36
39
|
'this is rather long and has some "§$"% special chars',
|
|
37
40
|
"also here pretty long and needs abbreviation",
|
|
38
|
-
"
|
|
41
|
+
"thisisrathe-alsoherepre-",
|
|
39
42
|
],
|
|
40
|
-
["breatheco-de", "python-flask-api-tutorial", "breathecode-pythonflaska-"],
|
|
41
43
|
["UPPER", "CaSe", "upper-case-"],
|
|
44
|
+
[
|
|
45
|
+
"superlongfirstsegment",
|
|
46
|
+
"---------",
|
|
47
|
+
"superlong" /* we don't mantch for the whole first segment, because it has different length depending on the animal that is used to replace the -------*/,
|
|
48
|
+
],
|
|
42
49
|
];
|
|
43
50
|
for (const d of data) {
|
|
44
51
|
const id = await generateWorkspaceID(d[0], d[1]);
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import randomNumber = require("random-number-csprng");
|
|
7
8
|
|
|
8
9
|
export async function generateWorkspaceID(firstSegment?: string, secondSegment?: string): Promise<string> {
|
|
9
10
|
const firstSeg = clean(firstSegment) || (await random(colors));
|
|
10
|
-
const secSeg = clean(secondSegment
|
|
11
|
-
|
|
11
|
+
const secSeg = clean(secondSegment) || (await random(animals));
|
|
12
|
+
function fit(makeFit: string, otherSeg: string) {
|
|
13
|
+
return makeFit.substring(0, Math.max(segLength, 2 * segLength - otherSeg.length));
|
|
14
|
+
}
|
|
15
|
+
return fit(firstSeg, secSeg) + "-" + fit(secSeg, firstSeg) + "-" + (await random(characters, segLength));
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
function clean(segment: string | undefined, maxChars: number =
|
|
18
|
+
function clean(segment: string | undefined, maxChars: number = 16) {
|
|
15
19
|
if (!segment) {
|
|
16
20
|
return undefined;
|
|
17
21
|
}
|
|
@@ -35,6 +39,8 @@ async function random(array: string[], length: number = 1): Promise<string> {
|
|
|
35
39
|
return result;
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
const segLength = 11;
|
|
43
|
+
|
|
38
44
|
const characters = "abcdefghijklmnopqrstuvwxyz0123456789".split("");
|
|
39
45
|
|
|
40
46
|
export const colors = [
|
package/src/util/logging.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const inspect: (object: any) => string = require("util").inspect; // undefined in frontend
|
|
8
8
|
|
|
9
|
+
let plainLogging: boolean = false; // set to true during development to get non JSON output
|
|
9
10
|
let jsonLogging: boolean = false;
|
|
10
11
|
let component: string | undefined;
|
|
11
12
|
let version: string | undefined;
|
|
@@ -309,24 +310,31 @@ function makeLogItem(
|
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
const payload: any = payloadArgs.length == 0 ? undefined : payloadArgs.length == 1 ? payloadArgs[0] : payloadArgs;
|
|
312
|
-
const logItem
|
|
313
|
+
const logItem = {
|
|
313
314
|
// undefined fields get eliminated in JSON.stringify()
|
|
314
315
|
...reportedErrorEvent,
|
|
315
316
|
component,
|
|
316
317
|
severity,
|
|
317
318
|
time: new Date().toISOString(),
|
|
318
|
-
environment: process.env.KUBE_STAGE,
|
|
319
319
|
context,
|
|
320
320
|
message,
|
|
321
321
|
error,
|
|
322
322
|
payload,
|
|
323
323
|
loggedViaConsole: calledViaConsole ? true : undefined,
|
|
324
324
|
};
|
|
325
|
+
if (plainLogging) {
|
|
326
|
+
return `[${logItem.severity}] [${logItem.component}] ${logItem.message}
|
|
327
|
+
${JSON.stringify(payload || "", undefined, " ")}
|
|
328
|
+
${error || ""}
|
|
329
|
+
`.trim();
|
|
330
|
+
}
|
|
325
331
|
let result: string = stringifyLogItem(logItem);
|
|
326
332
|
|
|
327
333
|
if (result.length > maxAllowedLogItemLength && payload !== undefined) {
|
|
328
334
|
delete logItem.payload;
|
|
329
|
-
|
|
335
|
+
(<any>(
|
|
336
|
+
logItem
|
|
337
|
+
)).payloadStub = `Payload stripped as log item was longer than ${maxAllowedLogItemLength} characters`;
|
|
330
338
|
|
|
331
339
|
result = stringifyLogItem(logItem);
|
|
332
340
|
|
package/src/util/timeutil.ts
CHANGED
|
@@ -47,6 +47,12 @@ export const orderAsc = (d1: string, d2: string): number => liftDate(d1, d2, (d1
|
|
|
47
47
|
export const liftDate1 = <T>(d1: string, f: (d1: Date) => T): T => f(new Date(d1));
|
|
48
48
|
export const liftDate = <T>(d1: string, d2: string, f: (d1: Date, d2: Date) => T): T => f(new Date(d1), new Date(d2));
|
|
49
49
|
|
|
50
|
+
export function hoursBefore(date: string, hours: number): string {
|
|
51
|
+
const result = new Date(date);
|
|
52
|
+
result.setHours(result.getHours() - hours);
|
|
53
|
+
return result.toISOString();
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
export function hoursLater(date: string, hours: number): string {
|
|
51
57
|
const result = new Date(date);
|
|
52
58
|
result.setHours(result.getHours() + hours);
|
package/src/util/tracing.ts
CHANGED
|
@@ -22,17 +22,15 @@ export type TraceContextWithSpan = TraceContext & {
|
|
|
22
22
|
export namespace TraceContext {
|
|
23
23
|
export function startSpan(operation: string, parentCtx?: TraceContext): opentracing.Span {
|
|
24
24
|
const options: opentracing.SpanOptions = {};
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
// references should contain span id.
|
|
27
|
+
// cf. https://github.com/jaegertracing/jaeger-client-node/issues/432
|
|
28
|
+
if (!!parentCtx?.span) {
|
|
29
|
+
const ctx = parentCtx?.span?.context();
|
|
30
|
+
if (ctx && !!ctx.toTraceId() && !!ctx.toSpanId()) {
|
|
31
|
+
options.references = [opentracing.followsFrom(ctx)];
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
|
-
// TODO(gpl) references lead to a huge amount of errors in prod logs. Avoid those until we have time to figure out how to fix it.
|
|
29
|
-
// if (referencedSpans) {
|
|
30
|
-
// // note: allthough followsForm's type says it takes 'opentracing.Span | opentracing.SpanContext', it only works with SpanContext (typing mismatch)
|
|
31
|
-
// // note2: we need to filter out debug spans (spanId === "")
|
|
32
|
-
// options.references = referencedSpans.filter(s => s !== undefined)
|
|
33
|
-
// .filter(s => !!s!.context().toSpanId())
|
|
34
|
-
// .map(s => followsFrom(s!.context()));
|
|
35
|
-
// }
|
|
36
34
|
|
|
37
35
|
return opentracing.globalTracer().startSpan(operation, options);
|
|
38
36
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 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 interface WebhookEvent {
|
|
8
|
+
id: string;
|
|
9
|
+
creationTime: string;
|
|
10
|
+
type: "push" | string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Typically the webhook installer is referenced here.
|
|
14
|
+
*/
|
|
15
|
+
authorizedUserId?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* webhook event's payload
|
|
19
|
+
*/
|
|
20
|
+
rawEvent: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The general status of the received webhook event.
|
|
24
|
+
*/
|
|
25
|
+
status: WebhookEvent.Status;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Optional message to help understand errors with handling events.
|
|
29
|
+
*/
|
|
30
|
+
message?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* If the webhook event is considered to trigger a prebuild, the `prebuildStatus`
|
|
34
|
+
* contains a more specific status.
|
|
35
|
+
*/
|
|
36
|
+
prebuildStatus?: WebhookEvent.PrebuildStatus;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If `prebuildStatus` is `prebuild_triggered` this points to a prebuild.
|
|
40
|
+
*/
|
|
41
|
+
prebuildId?: string;
|
|
42
|
+
|
|
43
|
+
projectId?: string;
|
|
44
|
+
|
|
45
|
+
cloneUrl?: string;
|
|
46
|
+
|
|
47
|
+
branch?: string;
|
|
48
|
+
|
|
49
|
+
commit?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export namespace WebhookEvent {
|
|
53
|
+
export type Status = "received" | "dismissed_unauthorized" | "ignored" | "processed";
|
|
54
|
+
export type PrebuildStatus = "ignored_unconfigured" | "prebuild_trigger_failed" | "prebuild_triggered";
|
|
55
|
+
}
|
package/src/workspace-cluster.ts
CHANGED
|
@@ -56,12 +56,10 @@ export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "ur
|
|
|
56
56
|
export type AdmissionConstraint =
|
|
57
57
|
| AdmissionConstraintFeaturePreview
|
|
58
58
|
| AdmissionConstraintHasPermission
|
|
59
|
-
|
|
|
60
|
-
| AdmissionConstraintHasMoreResources;
|
|
59
|
+
| AdmissionConstraintHasClass;
|
|
61
60
|
export type AdmissionConstraintFeaturePreview = { type: "has-feature-preview" };
|
|
62
61
|
export type AdmissionConstraintHasPermission = { type: "has-permission"; permission: PermissionName };
|
|
63
|
-
export type
|
|
64
|
-
export type AdmissionConstraintHasMoreResources = { type: "has-more-resources" };
|
|
62
|
+
export type AdmissionConstraintHasClass = { type: "has-class"; id: string; displayName: string };
|
|
65
63
|
|
|
66
64
|
export namespace AdmissionConstraint {
|
|
67
65
|
export function is(o: any): o is AdmissionConstraint {
|
|
@@ -56,10 +56,27 @@ export interface WorkspaceInstance {
|
|
|
56
56
|
* Contains information about the image build, if there was any
|
|
57
57
|
*/
|
|
58
58
|
imageBuildInfo?: ImageBuildInfo;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* workspace class, also known as workspace size, determines the type of
|
|
62
|
+
* resources that are provided to the workspace.
|
|
63
|
+
*/
|
|
64
|
+
workspaceClass?: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Identifies the team or user to which this instance's runtime should be attributed to
|
|
68
|
+
* (e.g. for usage analytics or billing purposes).
|
|
69
|
+
*/
|
|
70
|
+
usageAttributionId?: string;
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
// WorkspaceInstanceStatus describes the current state of a workspace instance
|
|
62
74
|
export interface WorkspaceInstanceStatus {
|
|
75
|
+
// version is the current version of the workspace instance status
|
|
76
|
+
// Note: consider this value opague. The only guarantee given is that it imposes
|
|
77
|
+
// a partial order on status updates, i.e. a.version > b.version -> a newer than b.
|
|
78
|
+
version?: number;
|
|
79
|
+
|
|
63
80
|
// phase describes a high-level state of the workspace instance
|
|
64
81
|
phase: WorkspaceInstancePhase;
|
|
65
82
|
|
|
@@ -98,9 +115,13 @@ export type WorkspaceInstancePhase =
|
|
|
98
115
|
| "unknown"
|
|
99
116
|
|
|
100
117
|
// Preparing means that we haven't actually started the workspace instance just yet, but rather
|
|
101
|
-
// are still preparing for launch.
|
|
118
|
+
// are still preparing for launch.
|
|
102
119
|
| "preparing"
|
|
103
120
|
|
|
121
|
+
// Building means that we are building the Docker image for the workspace. A workspace will enter this phase only
|
|
122
|
+
// if an image build is required for that workspace.
|
|
123
|
+
| "building"
|
|
124
|
+
|
|
104
125
|
// Pending means the workspace does not yet consume resources in the cluster, but rather is looking for
|
|
105
126
|
// some space within the cluster. If for example the cluster needs to scale up to accomodate the
|
|
106
127
|
// workspace, the workspace will be in Pending state until that happened.
|
|
@@ -204,6 +225,12 @@ export interface WorkspaceInstanceRepoStatus {
|
|
|
204
225
|
totalUnpushedCommits?: number;
|
|
205
226
|
}
|
|
206
227
|
|
|
228
|
+
// ConfigurationIdeConfig ide config of WorkspaceInstanceConfiguration
|
|
229
|
+
export interface ConfigurationIdeConfig {
|
|
230
|
+
useLatest?: boolean;
|
|
231
|
+
desktopIdeAlias?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
207
234
|
// WorkspaceInstanceConfiguration contains all per-instance configuration
|
|
208
235
|
export interface WorkspaceInstanceConfiguration {
|
|
209
236
|
// theiaVersion is the version of Theia this workspace instance uses
|
|
@@ -221,6 +248,8 @@ export interface WorkspaceInstanceConfiguration {
|
|
|
221
248
|
|
|
222
249
|
// supervisorImage is the ref of the supervisor image this instance uses.
|
|
223
250
|
supervisorImage?: string;
|
|
251
|
+
|
|
252
|
+
ideConfig?: ConfigurationIdeConfig;
|
|
224
253
|
}
|
|
225
254
|
|
|
226
255
|
/**
|
package/src/wsready.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
// generated using github.com/32leaves/bel on 2022-
|
|
7
|
+
// generated using github.com/32leaves/bel on 2022-05-18 18:19:49.011672619 +0000 UTC m=+0.006607361
|
|
8
8
|
// DO NOT MODIFY
|
|
9
9
|
|
|
10
10
|
export enum WorkspaceInitSource {
|