@gitpod/gitpod-protocol 0.1.5-tar-telemetry-data-settings.0 → 0.1.5-tar-telemetry-settings-data.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/lib/context-url.d.ts +17 -5
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +55 -4
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +2 -0
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +25 -4
- package/lib/context-url.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +9 -0
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js.map +1 -1
- package/lib/ide-protocol.d.ts +4 -0
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/permission.d.ts +3 -0
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +20 -4
- package/lib/permission.js.map +1 -1
- package/lib/protocol.d.ts +1 -0
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js.map +1 -1
- package/lib/util/tracing.d.ts +2 -2
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +13 -12
- package/lib/util/tracing.js.map +1 -1
- package/lib/workspace-cluster.d.ts +7 -2
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +18 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/package.json +1 -1
- package/pkg-yarn.lock +1 -1
- package/provenance-bundle.jsonl +1 -1
- package/src/context-url.spec.ts +18 -4
- package/src/context-url.ts +59 -5
- package/src/gitpod-service.ts +11 -0
- package/src/ide-protocol.ts +5 -0
- package/src/permission.ts +17 -3
- package/src/protocol.ts +1 -0
- package/src/util/tracing.ts +14 -13
- package/src/workspace-cluster.ts +15 -2
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -34
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/src/messaging/connection-error-handler.ts +0 -62
package/src/ide-protocol.ts
CHANGED
|
@@ -102,6 +102,11 @@ export interface IDEOption {
|
|
|
102
102
|
*/
|
|
103
103
|
image: string;
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The latest image ref to the IDE image, this image ref always resolve to digest.
|
|
107
|
+
*/
|
|
108
|
+
latestImage?: string;
|
|
109
|
+
|
|
105
110
|
/**
|
|
106
111
|
* When this is `true`, the tag of this image is resolved to the latest
|
|
107
112
|
* image digest regularly.
|
package/src/permission.ts
CHANGED
|
@@ -35,6 +35,22 @@ export interface Role {
|
|
|
35
35
|
permissions: PermissionName[],
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
export namespace RolesOrPermissions {
|
|
39
|
+
export function toPermissionSet(rolesOrPermissions: RoleOrPermission[] | undefined): Set<PermissionName> {
|
|
40
|
+
rolesOrPermissions = rolesOrPermissions || [];
|
|
41
|
+
|
|
42
|
+
const permissions = new Set<PermissionName>();
|
|
43
|
+
for (const rop of rolesOrPermissions) {
|
|
44
|
+
if (Permission.is(rop)) {
|
|
45
|
+
permissions.add(rop);
|
|
46
|
+
} else if (RoleName.is(rop)) {
|
|
47
|
+
Role.getByName(rop).permissions.forEach(p => permissions.add(p));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return permissions;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
38
54
|
export namespace Permission {
|
|
39
55
|
/** The permission to monitor the (live) state of a Gitpod installation */
|
|
40
56
|
export const MONITOR: PermissionName = "monitor";
|
|
@@ -66,9 +82,7 @@ export namespace Permission {
|
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
export const all = (): PermissionName[] => {
|
|
69
|
-
return Object.keys(
|
|
70
|
-
.map(k => (Permission as any)[k])
|
|
71
|
-
.filter(k => typeof(k) === 'string');
|
|
85
|
+
return Object.keys(Permissions) as PermissionName[];
|
|
72
86
|
};
|
|
73
87
|
}
|
|
74
88
|
|
package/src/protocol.ts
CHANGED
package/src/util/tracing.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as opentracing from 'opentracing';
|
|
9
9
|
import { TracingConfig, initTracerFromEnv } from 'jaeger-client';
|
|
10
10
|
import { Sampler, SamplingDecision } from './jaeger-client-types';
|
|
11
|
-
import {
|
|
11
|
+
import { initGlobalTracer } from 'opentracing';
|
|
12
12
|
import { injectable } from 'inversify';
|
|
13
13
|
import { ResponseError } from 'vscode-jsonrpc';
|
|
14
14
|
import { log, LogContext } from './logging';
|
|
@@ -22,18 +22,19 @@ export type TraceContextWithSpan = TraceContext & {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
export namespace TraceContext {
|
|
25
|
-
export function startSpan(operation: string, parentCtx?: TraceContext
|
|
25
|
+
export function startSpan(operation: string, parentCtx?: TraceContext): opentracing.Span {
|
|
26
26
|
const options: opentracing.SpanOptions = {};
|
|
27
27
|
if (parentCtx && parentCtx.span && !!parentCtx.span.context().toSpanId()) {
|
|
28
28
|
options.childOf = parentCtx.span;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
// 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.
|
|
31
|
+
// if (referencedSpans) {
|
|
32
|
+
// // note: allthough followsForm's type says it takes 'opentracing.Span | opentracing.SpanContext', it only works with SpanContext (typing mismatch)
|
|
33
|
+
// // note2: we need to filter out debug spans (spanId === "")
|
|
34
|
+
// options.references = referencedSpans.filter(s => s !== undefined)
|
|
35
|
+
// .filter(s => !!s!.context().toSpanId())
|
|
36
|
+
// .map(s => followsFrom(s!.context()));
|
|
37
|
+
// }
|
|
37
38
|
|
|
38
39
|
return opentracing.globalTracer().startSpan(operation, options);
|
|
39
40
|
}
|
|
@@ -43,16 +44,16 @@ export namespace TraceContext {
|
|
|
43
44
|
return { span };
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function withSpan(operation: string, callback: () => void, ctx?: TraceContext
|
|
47
|
+
export function withSpan(operation: string, callback: (ctx: TraceContext) => void, ctx?: TraceContext): void {
|
|
47
48
|
// if we don't have a parent span, don't create a trace here as those <trace-without-root-spans> are not useful.
|
|
48
49
|
if (!ctx || !ctx.span || !ctx.span.context()) {
|
|
49
|
-
callback();
|
|
50
|
+
callback({});
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const span = TraceContext.startSpan(operation, ctx
|
|
54
|
+
const span = TraceContext.startSpan(operation, ctx);
|
|
54
55
|
try {
|
|
55
|
-
callback();
|
|
56
|
+
callback({span});
|
|
56
57
|
} catch (e) {
|
|
57
58
|
TraceContext.setError({span}, e);
|
|
58
59
|
throw e;
|
package/src/workspace-cluster.ts
CHANGED
|
@@ -52,12 +52,25 @@ export namespace TLSConfig {
|
|
|
52
52
|
export type WorkspaceClusterWoTLS = Omit<WorkspaceCluster, "tls">;
|
|
53
53
|
export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "url" | "tls">;
|
|
54
54
|
|
|
55
|
-
export type AdmissionConstraint = AdmissionConstraintFeaturePreview |
|
|
55
|
+
export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasPermission | AdmissionConstraintHasUserLevel | AdmissionConstraintHasMoreResources;
|
|
56
56
|
export type AdmissionConstraintFeaturePreview = { type: "has-feature-preview" };
|
|
57
|
-
export type
|
|
57
|
+
export type AdmissionConstraintHasPermission = { type: "has-permission", permission: PermissionName };
|
|
58
58
|
export type AdmissionConstraintHasUserLevel = { type: "has-user-level", level: string };
|
|
59
59
|
export type AdmissionConstraintHasMoreResources = { type: "has-more-resources" };
|
|
60
60
|
|
|
61
|
+
export namespace AdmissionConstraint {
|
|
62
|
+
export function is(o: any): o is AdmissionConstraint {
|
|
63
|
+
return !!o
|
|
64
|
+
&& 'type' in o;
|
|
65
|
+
}
|
|
66
|
+
export function isHasPermissionConstraint(o: any): o is AdmissionConstraintHasPermission {
|
|
67
|
+
return is(o)
|
|
68
|
+
&& o.type === "has-permission";
|
|
69
|
+
}
|
|
70
|
+
export function hasPermission(ac: AdmissionConstraint, permission: PermissionName): boolean {
|
|
71
|
+
return isHasPermissionConstraint(ac) && ac.permission === permission;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
61
74
|
|
|
62
75
|
export const WorkspaceClusterDB = Symbol("WorkspaceClusterDB");
|
|
63
76
|
export interface WorkspaceClusterDB {
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Message } from "vscode-jsonrpc";
|
|
2
|
-
export interface ResolvedConnectionErrorHandlerOptions {
|
|
3
|
-
readonly serverName: string;
|
|
4
|
-
/**
|
|
5
|
-
* The maximum amount of errors allowed before stopping the server.
|
|
6
|
-
*/
|
|
7
|
-
readonly maxErrors: number;
|
|
8
|
-
/**
|
|
9
|
-
* The maimum amount of restarts allowed in the restart interval.
|
|
10
|
-
*/
|
|
11
|
-
readonly maxRestarts: number;
|
|
12
|
-
/**
|
|
13
|
-
* In minutes.
|
|
14
|
-
*/
|
|
15
|
-
readonly restartInterval: number;
|
|
16
|
-
}
|
|
17
|
-
export declare type ConnectionErrorHandlerOptions = Partial<ResolvedConnectionErrorHandlerOptions> & {
|
|
18
|
-
readonly serverName: string;
|
|
19
|
-
};
|
|
20
|
-
export declare class ConnectionErrorHandler {
|
|
21
|
-
protected readonly options: ResolvedConnectionErrorHandlerOptions;
|
|
22
|
-
constructor(options: ConnectionErrorHandlerOptions);
|
|
23
|
-
shouldStop(error: Error, message?: Message, count?: number): boolean;
|
|
24
|
-
protected readonly restarts: number[];
|
|
25
|
-
shouldRestart(): boolean;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=connection-error-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-error-handler.d.ts","sourceRoot":"","sources":["../../src/messaging/connection-error-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,MAAM,WAAW,qCAAqC;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACnC;AAED,oBAAY,6BAA6B,GAAG,OAAO,CAAC,qCAAqC,CAAC,GAAG;IACzF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC9B,CAAC;AAEF,qBAAa,sBAAsB;IAE/B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,qCAAqC,CAAC;gBACtD,OAAO,EAAE,6BAA6B;IASlD,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAIpE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAM;IAC3C,aAAa,IAAI,OAAO;CAc3B"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (C) 2017 TypeFox and others.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ConnectionErrorHandler = void 0;
|
|
10
|
-
const logging_1 = require("../util/logging");
|
|
11
|
-
class ConnectionErrorHandler {
|
|
12
|
-
constructor(options) {
|
|
13
|
-
this.restarts = [];
|
|
14
|
-
this.options = Object.assign({ maxErrors: 3, maxRestarts: 5, restartInterval: 3 }, options);
|
|
15
|
-
}
|
|
16
|
-
shouldStop(error, message, count) {
|
|
17
|
-
return !count || count > this.options.maxErrors;
|
|
18
|
-
}
|
|
19
|
-
shouldRestart() {
|
|
20
|
-
this.restarts.push(Date.now());
|
|
21
|
-
if (this.restarts.length <= this.options.maxRestarts) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
const diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
|
|
25
|
-
if (diff <= this.options.restartInterval * 60 * 1000) {
|
|
26
|
-
logging_1.log.error(`Server ${this.options.serverName} crashed ${this.options.maxRestarts} times in the last ${this.options.restartInterval} minutes. Will not restart`);
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
this.restarts.shift();
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.ConnectionErrorHandler = ConnectionErrorHandler;
|
|
34
|
-
//# sourceMappingURL=connection-error-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-error-handler.js","sourceRoot":"","sources":["../../src/messaging/connection-error-handler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAsC;AAsBtC,MAAa,sBAAsB;IAG/B,YAAY,OAAsC;QAa/B,aAAQ,GAAa,EAAE,CAAC;QAZvC,IAAI,CAAC,OAAO,mBACR,SAAS,EAAE,CAAC,EACZ,WAAW,EAAE,CAAC,EACd,eAAe,EAAE,CAAC,IACf,OAAO,CACb,CAAC;IACN,CAAC;IAED,UAAU,CAAC,KAAY,EAAE,OAAiB,EAAE,KAAc;QACtD,OAAO,CAAC,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACpD,CAAC;IAGD,aAAa;QACT,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAClD,OAAO,IAAI,CAAC;SACf;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,EAAE,GAAG,IAAI,EAAE;YAClD,aAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,UAAU,YAAY,IAAI,CAAC,OAAO,CAAC,WAAW,sBAAsB,IAAI,CAAC,OAAO,CAAC,eAAe,4BAA4B,CAAC,CAAC;YAC/J,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ;AA/BD,wDA+BC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2017 TypeFox and others.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { Message } from "vscode-jsonrpc";
|
|
9
|
-
import { log } from '../util/logging';
|
|
10
|
-
|
|
11
|
-
export interface ResolvedConnectionErrorHandlerOptions {
|
|
12
|
-
readonly serverName: string
|
|
13
|
-
/**
|
|
14
|
-
* The maximum amount of errors allowed before stopping the server.
|
|
15
|
-
*/
|
|
16
|
-
readonly maxErrors: number
|
|
17
|
-
/**
|
|
18
|
-
* The maimum amount of restarts allowed in the restart interval.
|
|
19
|
-
*/
|
|
20
|
-
readonly maxRestarts: number
|
|
21
|
-
/**
|
|
22
|
-
* In minutes.
|
|
23
|
-
*/
|
|
24
|
-
readonly restartInterval: number
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type ConnectionErrorHandlerOptions = Partial<ResolvedConnectionErrorHandlerOptions> & {
|
|
28
|
-
readonly serverName: string
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export class ConnectionErrorHandler {
|
|
32
|
-
|
|
33
|
-
protected readonly options: ResolvedConnectionErrorHandlerOptions;
|
|
34
|
-
constructor(options: ConnectionErrorHandlerOptions) {
|
|
35
|
-
this.options = {
|
|
36
|
-
maxErrors: 3,
|
|
37
|
-
maxRestarts: 5,
|
|
38
|
-
restartInterval: 3,
|
|
39
|
-
...options
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
shouldStop(error: Error, message?: Message, count?: number): boolean {
|
|
44
|
-
return !count || count > this.options.maxErrors;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected readonly restarts: number[] = [];
|
|
48
|
-
shouldRestart(): boolean {
|
|
49
|
-
this.restarts.push(Date.now());
|
|
50
|
-
if (this.restarts.length <= this.options.maxRestarts) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
const diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
|
|
54
|
-
if (diff <= this.options.restartInterval * 60 * 1000) {
|
|
55
|
-
log.error(`Server ${this.options.serverName} crashed ${this.options.maxRestarts} times in the last ${this.options.restartInterval} minutes. Will not restart`);
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
this.restarts.shift();
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}
|