@gitpod/gitpod-protocol 0.1.5-se-workspaceid.10 → 0.1.5-se-multi-repo.4
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 +40 -2
- package/lib/gitpod-service.d.ts +4 -2
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +4 -2
- package/lib/gitpod-service.js.map +1 -1
- package/lib/messaging/node/connection.d.ts +1 -7
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +20 -18
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/protocol.d.ts +47 -38
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +31 -0
- package/lib/protocol.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +1 -0
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +1 -0
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts +0 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +0 -3
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/tracing.d.ts +2 -1
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +30 -4
- package/lib/util/tracing.js.map +1 -1
- package/lib/wsready.d.ts +4 -4
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +1 -3
- package/lib/wsready.js.map +1 -1
- package/package.json +1 -1
- package/pkg-yarn.lock +1 -1
- package/provenance-bundle.jsonl +1 -1
- package/src/gitpod-service.ts +10 -6
- package/src/ide-frontend-service.ts +1 -1
- package/src/messaging/node/connection.ts +20 -23
- package/src/protocol.ts +71 -39
- package/src/util/generate-workspace-id.spec.ts +1 -0
- package/src/util/generate-workspace-id.ts +1 -0
- package/src/util/gitpod-host-url.ts +1 -5
- package/src/util/tracing.ts +30 -4
- package/src/wsready.ts +6 -5
package/src/protocol.ts
CHANGED
|
@@ -104,6 +104,9 @@ export interface AdditionalUserData {
|
|
|
104
104
|
oauthClientsApproved?: { [key: string]: string }
|
|
105
105
|
// to remember GH Orgs the user installed/updated the GH App for
|
|
106
106
|
knownGitHubOrgs?: string[];
|
|
107
|
+
|
|
108
|
+
// Git clone URL pointing to the user's dotfile repo
|
|
109
|
+
dotfileRepo?: string;
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
export interface EmailNotificationSettings {
|
|
@@ -151,12 +154,23 @@ export interface UserFeatureSettings {
|
|
|
151
154
|
export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
|
|
152
155
|
export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
|
|
153
156
|
|
|
154
|
-
export interface
|
|
155
|
-
id?: string;
|
|
157
|
+
export interface EnvVarWithValue {
|
|
156
158
|
name: string;
|
|
157
|
-
repositoryPattern: string;
|
|
158
159
|
value: string;
|
|
159
160
|
}
|
|
161
|
+
|
|
162
|
+
export interface ProjectEnvVarWithValue extends EnvVarWithValue {
|
|
163
|
+
id: string;
|
|
164
|
+
projectId: string;
|
|
165
|
+
censored: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
|
|
169
|
+
|
|
170
|
+
export interface UserEnvVarValue extends EnvVarWithValue {
|
|
171
|
+
id?: string;
|
|
172
|
+
repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
173
|
+
}
|
|
160
174
|
export interface UserEnvVar extends UserEnvVarValue {
|
|
161
175
|
id: string;
|
|
162
176
|
userId: string;
|
|
@@ -165,10 +179,12 @@ export interface UserEnvVar extends UserEnvVarValue {
|
|
|
165
179
|
|
|
166
180
|
export namespace UserEnvVar {
|
|
167
181
|
|
|
182
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
168
183
|
export function normalizeRepoPattern(pattern: string) {
|
|
169
184
|
return pattern.toLocaleLowerCase();
|
|
170
185
|
}
|
|
171
186
|
|
|
187
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
172
188
|
export function score(value: UserEnvVarValue): number {
|
|
173
189
|
// We use a score to enforce precedence:
|
|
174
190
|
// value/value = 0
|
|
@@ -191,6 +207,7 @@ export namespace UserEnvVar {
|
|
|
191
207
|
return score;
|
|
192
208
|
}
|
|
193
209
|
|
|
210
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
194
211
|
export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
|
|
195
212
|
let result = vars.filter(e => {
|
|
196
213
|
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
@@ -238,6 +255,7 @@ export namespace UserEnvVar {
|
|
|
238
255
|
return result;
|
|
239
256
|
}
|
|
240
257
|
|
|
258
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
241
259
|
export function splitRepositoryPattern(repositoryPattern: string): string[] {
|
|
242
260
|
const patterns = repositoryPattern.split('/');
|
|
243
261
|
const repoPattern = patterns.pop() || "";
|
|
@@ -548,7 +566,14 @@ export interface VSCodeConfig {
|
|
|
548
566
|
extensions?: string[];
|
|
549
567
|
}
|
|
550
568
|
|
|
569
|
+
export interface SubRepository {
|
|
570
|
+
url: string;
|
|
571
|
+
checkoutLocation?: string;
|
|
572
|
+
}
|
|
573
|
+
|
|
551
574
|
export interface WorkspaceConfig {
|
|
575
|
+
mainRepository?: string;
|
|
576
|
+
subRepositories?: SubRepository[];
|
|
552
577
|
image?: ImageConfig;
|
|
553
578
|
ports?: PortConfig[];
|
|
554
579
|
tasks?: TaskConfig[];
|
|
@@ -588,7 +613,7 @@ export interface GithubAppPrebuildConfig {
|
|
|
588
613
|
branches?: boolean
|
|
589
614
|
pullRequests?: boolean
|
|
590
615
|
pullRequestsFromForks?: boolean
|
|
591
|
-
addCheck?: boolean
|
|
616
|
+
addCheck?: boolean | 'prevent-merge-on-error'
|
|
592
617
|
addBadge?: boolean
|
|
593
618
|
addLabel?: boolean | string
|
|
594
619
|
addComment?: boolean
|
|
@@ -667,6 +692,7 @@ export interface PrebuiltWorkspaceUpdatable {
|
|
|
667
692
|
repo: string;
|
|
668
693
|
isResolved: boolean;
|
|
669
694
|
installationId: string;
|
|
695
|
+
commitSHA?: string;
|
|
670
696
|
issue?: string;
|
|
671
697
|
contextUrl?: string;
|
|
672
698
|
}
|
|
@@ -848,6 +874,7 @@ export namespace SnapshotContext {
|
|
|
848
874
|
export interface StartPrebuildContext extends WorkspaceContext {
|
|
849
875
|
actual: WorkspaceContext;
|
|
850
876
|
commitHistory?: string[];
|
|
877
|
+
subRepoCommitHistories?: string[][];
|
|
851
878
|
project?: Project;
|
|
852
879
|
branch?: string;
|
|
853
880
|
}
|
|
@@ -874,7 +901,7 @@ export namespace PrebuiltWorkspaceContext {
|
|
|
874
901
|
}
|
|
875
902
|
|
|
876
903
|
export interface WithEnvvarsContext extends WorkspaceContext {
|
|
877
|
-
envvars:
|
|
904
|
+
envvars: EnvVarWithValue[];
|
|
878
905
|
}
|
|
879
906
|
|
|
880
907
|
export namespace WithEnvvarsContext {
|
|
@@ -938,9 +965,47 @@ export namespace AdditionalContentContext {
|
|
|
938
965
|
}
|
|
939
966
|
}
|
|
940
967
|
|
|
941
|
-
export interface CommitContext extends WorkspaceContext,
|
|
968
|
+
export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
|
|
942
969
|
/** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
|
|
943
970
|
cloneUrl?: string
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* The clone and checkout information for the sub-repositories in case of multi-repo projects.
|
|
974
|
+
*/
|
|
975
|
+
subRepositoryCheckoutInfo?: GitCheckoutInfo[];
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
export namespace CommitContext {
|
|
979
|
+
/**
|
|
980
|
+
* Creates an identifier pointing to the commits of the CommitContext and all sub-repo commit infos.
|
|
981
|
+
* The identifier is max 255 chars long.
|
|
982
|
+
* @param commitContext
|
|
983
|
+
* @returns identifier for set of commits
|
|
984
|
+
*/
|
|
985
|
+
export function getCommitSHAs(commitContext: CommitContext): string {
|
|
986
|
+
if (!commitContext.subRepositoryCheckoutInfo || commitContext.subRepositoryCheckoutInfo.length === 0) {
|
|
987
|
+
return commitContext.revision;
|
|
988
|
+
}
|
|
989
|
+
// it's a multi-repo project, we need to store all commit shas and that needs to fit into 255 chars. Let's only store at most first seven.
|
|
990
|
+
const commits = [commitContext.revision, ... commitContext.subRepositoryCheckoutInfo.map(i => i.revision)];
|
|
991
|
+
const maxLength = Math.min(7, 255 / commits.length);
|
|
992
|
+
return commits.map( r => r.substring(0, maxLength)).join(',');
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* unparses the commitShaIdentifier into an array of commit SHAs.
|
|
997
|
+
* @param commitSHAIdentifier
|
|
998
|
+
* @returns the array of commit SHAs
|
|
999
|
+
*/
|
|
1000
|
+
export function parseCommitSHAs(commitSHAIdentifier: string): string[] {
|
|
1001
|
+
return commitSHAIdentifier.split(',');
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
export interface GitCheckoutInfo extends Commit {
|
|
1006
|
+
checkoutLocation?: string;
|
|
1007
|
+
upstreamRemoteURI?: string;
|
|
1008
|
+
localBranch?: string;
|
|
944
1009
|
}
|
|
945
1010
|
|
|
946
1011
|
export namespace CommitContext {
|
|
@@ -1172,39 +1237,6 @@ export namespace AuthProviderEntry {
|
|
|
1172
1237
|
}
|
|
1173
1238
|
}
|
|
1174
1239
|
|
|
1175
|
-
export interface Branding {
|
|
1176
|
-
readonly name: string;
|
|
1177
|
-
readonly favicon?: string;
|
|
1178
|
-
/** Either including domain OR absolute path (interpreted relative to host URL) */
|
|
1179
|
-
readonly logo: string;
|
|
1180
|
-
readonly startupLogo: string;
|
|
1181
|
-
readonly showProductivityTips: boolean;
|
|
1182
|
-
readonly redirectUrlIfNotAuthenticated?: string;
|
|
1183
|
-
readonly redirectUrlAfterLogout?: string;
|
|
1184
|
-
readonly homepage: string;
|
|
1185
|
-
readonly ide?: {
|
|
1186
|
-
readonly logo: string;
|
|
1187
|
-
readonly showReleaseNotes: boolean;
|
|
1188
|
-
readonly helpMenu: Branding.Link[];
|
|
1189
|
-
}
|
|
1190
|
-
readonly links: {
|
|
1191
|
-
readonly header: Branding.Link[];
|
|
1192
|
-
readonly footer: Branding.Link[];
|
|
1193
|
-
readonly social: Branding.SocialLink[];
|
|
1194
|
-
readonly legal: Branding.Link[];
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
export namespace Branding {
|
|
1198
|
-
export interface Link {
|
|
1199
|
-
readonly name: string;
|
|
1200
|
-
readonly url: string;
|
|
1201
|
-
}
|
|
1202
|
-
export interface SocialLink {
|
|
1203
|
-
readonly type: string;
|
|
1204
|
-
readonly url: string;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
1240
|
export interface Configuration {
|
|
1209
1241
|
readonly daysBeforeGarbageCollection: number;
|
|
1210
1242
|
readonly garbageCollectionStartDate: number;
|
|
@@ -34,6 +34,7 @@ const expect = chai.expect
|
|
|
34
34
|
['gitpod-io','gitpod','gitpodio-gitpod-'],
|
|
35
35
|
['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
|
|
36
36
|
['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
|
|
37
|
+
['UPPER', "CaSe", "upper-case-"]
|
|
37
38
|
]
|
|
38
39
|
for (const d of data) {
|
|
39
40
|
const id = await generateWorkspaceID(d[0], d[1]);
|
|
@@ -15,6 +15,7 @@ function clean(segment: string | undefined, maxChars: number = 15) {
|
|
|
15
15
|
if (!segment) {
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
|
+
segment = segment.toLowerCase();
|
|
18
19
|
let result = '';
|
|
19
20
|
for (let i =0; i < segment.length; i++) {
|
|
20
21
|
if (characters.indexOf(segment[i]) !== -1) {
|
|
@@ -108,10 +108,6 @@ export class GitpodHostUrl {
|
|
|
108
108
|
return this.with(url => ({ pathname: '/preferences' }));
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
asGraphQLApi(): GitpodHostUrl {
|
|
112
|
-
return this.with(url => ({ pathname: '/graphql/' }));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
111
|
asStart(workspaceId = this.workspaceId): GitpodHostUrl {
|
|
116
112
|
return this.withoutWorkspacePrefix().with({
|
|
117
113
|
pathname: '/start/',
|
|
@@ -154,7 +150,7 @@ export class GitpodHostUrl {
|
|
|
154
150
|
return undefined;
|
|
155
151
|
}
|
|
156
152
|
|
|
157
|
-
get blobServe(): boolean
|
|
153
|
+
get blobServe(): boolean {
|
|
158
154
|
const hostSegments = this.url.host.split(".");
|
|
159
155
|
if (hostSegments[0] === 'blobserve') {
|
|
160
156
|
return true;
|
package/src/util/tracing.ts
CHANGED
|
@@ -24,12 +24,15 @@ export type TraceContextWithSpan = TraceContext & {
|
|
|
24
24
|
export namespace TraceContext {
|
|
25
25
|
export function startSpan(operation: string, parentCtx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): opentracing.Span {
|
|
26
26
|
const options: opentracing.SpanOptions = {};
|
|
27
|
-
if (parentCtx) {
|
|
27
|
+
if (parentCtx && parentCtx.span && !!parentCtx.span.context().toSpanId()) {
|
|
28
28
|
options.childOf = parentCtx.span;
|
|
29
29
|
}
|
|
30
30
|
if (referencedSpans) {
|
|
31
31
|
// note: allthough followsForm's type says it takes 'opentracing.Span | opentracing.SpanContext', it only works with SpanContext (typing mismatch)
|
|
32
|
-
|
|
32
|
+
// note2: we need to filter out debug spans (spanId === "")
|
|
33
|
+
options.references = referencedSpans.filter(s => s !== undefined)
|
|
34
|
+
.filter(s => !!s!.context().toSpanId())
|
|
35
|
+
.map(s => followsFrom(s!.context()));
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
return opentracing.globalTracer().startSpan(operation, options);
|
|
@@ -40,6 +43,24 @@ export namespace TraceContext {
|
|
|
40
43
|
return { span };
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
export function withSpan(operation: string, callback: () => void, ctx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): void {
|
|
47
|
+
// if we don't have a parent span, don't create a trace here as those <trace-without-root-spans> are not useful.
|
|
48
|
+
if (!ctx || !ctx.span || !ctx.span.context()) {
|
|
49
|
+
callback();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const span = TraceContext.startSpan(operation, ctx, ...referencedSpans);
|
|
54
|
+
try {
|
|
55
|
+
callback();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
TraceContext.setError({span}, e);
|
|
58
|
+
throw e;
|
|
59
|
+
} finally {
|
|
60
|
+
span.finish();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
export function setError(ctx: TraceContext, err: Error) {
|
|
44
65
|
if (!ctx.span) {
|
|
45
66
|
return;
|
|
@@ -71,13 +92,13 @@ export namespace TraceContext {
|
|
|
71
92
|
addNestedTags(ctx, tags);
|
|
72
93
|
}
|
|
73
94
|
|
|
74
|
-
export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any
|
|
95
|
+
export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>, withStatusCode: boolean = false) {
|
|
75
96
|
if (!ctx.span) {
|
|
76
97
|
return;
|
|
77
98
|
}
|
|
78
99
|
// not use setError bc this is (most likely) a working operation
|
|
79
100
|
|
|
80
|
-
setJsonRPCMetadata(ctx);
|
|
101
|
+
setJsonRPCMetadata(ctx, method);
|
|
81
102
|
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
|
|
82
103
|
addNestedTags(ctx, {
|
|
83
104
|
rpc: {
|
|
@@ -87,6 +108,11 @@ export namespace TraceContext {
|
|
|
87
108
|
},
|
|
88
109
|
},
|
|
89
110
|
});
|
|
111
|
+
|
|
112
|
+
// the field "status_code" is used by honeycomb to derive insights like success rate, etc. Defaults to "0".
|
|
113
|
+
if (withStatusCode) {
|
|
114
|
+
ctx.span.setTag("status_code", err.code);
|
|
115
|
+
}
|
|
90
116
|
}
|
|
91
117
|
|
|
92
118
|
export function addJsonRPCParameters(ctx: TraceContext, params: { [key: string]: any }) {
|
package/src/wsready.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
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
|
-
// generated using github.com/32leaves/bel on
|
|
7
|
+
// generated using github.com/32leaves/bel on 2022-01-18 11:58:21.410853112 +0000 UTC m=+0.010268211
|
|
8
8
|
// DO NOT MODIFY
|
|
9
9
|
|
|
10
|
+
export interface WorkspaceReadyMessage {
|
|
11
|
+
source: WorkspaceInitSource
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export enum WorkspaceInitSource {
|
|
11
15
|
WorkspaceInitFromBackup = "from-backup",
|
|
12
16
|
WorkspaceInitFromPrebuild = "from-prebuild",
|
|
13
17
|
WorkspaceInitFromOther = "from-other",
|
|
14
18
|
}
|
|
15
|
-
export interface WorkspaceReadyMessage {
|
|
16
|
-
source: WorkspaceInitSource
|
|
17
|
-
}
|