@gitpod/gitpod-protocol 0.1.5-se-github-app-check-7518.1 → 0.1.5-se-multi-repo.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 +28 -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 +44 -37
- 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 +1 -0
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +24 -2
- 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 +66 -38
- 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 +23 -2
- package/src/wsready.ts +6 -5
package/src/protocol.ts
CHANGED
|
@@ -154,12 +154,23 @@ export interface UserFeatureSettings {
|
|
|
154
154
|
export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
|
|
155
155
|
export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
|
|
156
156
|
|
|
157
|
-
export interface
|
|
158
|
-
id?: string;
|
|
157
|
+
export interface EnvVarWithValue {
|
|
159
158
|
name: string;
|
|
160
|
-
repositoryPattern: string;
|
|
161
159
|
value: string;
|
|
162
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
|
+
}
|
|
163
174
|
export interface UserEnvVar extends UserEnvVarValue {
|
|
164
175
|
id: string;
|
|
165
176
|
userId: string;
|
|
@@ -168,10 +179,12 @@ export interface UserEnvVar extends UserEnvVarValue {
|
|
|
168
179
|
|
|
169
180
|
export namespace UserEnvVar {
|
|
170
181
|
|
|
182
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
171
183
|
export function normalizeRepoPattern(pattern: string) {
|
|
172
184
|
return pattern.toLocaleLowerCase();
|
|
173
185
|
}
|
|
174
186
|
|
|
187
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
175
188
|
export function score(value: UserEnvVarValue): number {
|
|
176
189
|
// We use a score to enforce precedence:
|
|
177
190
|
// value/value = 0
|
|
@@ -194,6 +207,7 @@ export namespace UserEnvVar {
|
|
|
194
207
|
return score;
|
|
195
208
|
}
|
|
196
209
|
|
|
210
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
197
211
|
export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
|
|
198
212
|
let result = vars.filter(e => {
|
|
199
213
|
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
@@ -241,6 +255,7 @@ export namespace UserEnvVar {
|
|
|
241
255
|
return result;
|
|
242
256
|
}
|
|
243
257
|
|
|
258
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
244
259
|
export function splitRepositoryPattern(repositoryPattern: string): string[] {
|
|
245
260
|
const patterns = repositoryPattern.split('/');
|
|
246
261
|
const repoPattern = patterns.pop() || "";
|
|
@@ -551,7 +566,14 @@ export interface VSCodeConfig {
|
|
|
551
566
|
extensions?: string[];
|
|
552
567
|
}
|
|
553
568
|
|
|
569
|
+
export interface SubRepository {
|
|
570
|
+
url: string;
|
|
571
|
+
checkoutLocation?: string;
|
|
572
|
+
}
|
|
573
|
+
|
|
554
574
|
export interface WorkspaceConfig {
|
|
575
|
+
mainRepository?: string;
|
|
576
|
+
subRepositories?: SubRepository[];
|
|
555
577
|
image?: ImageConfig;
|
|
556
578
|
ports?: PortConfig[];
|
|
557
579
|
tasks?: TaskConfig[];
|
|
@@ -851,6 +873,7 @@ export namespace SnapshotContext {
|
|
|
851
873
|
export interface StartPrebuildContext extends WorkspaceContext {
|
|
852
874
|
actual: WorkspaceContext;
|
|
853
875
|
commitHistory?: string[];
|
|
876
|
+
subRepoCommitHistories?: string[][];
|
|
854
877
|
project?: Project;
|
|
855
878
|
branch?: string;
|
|
856
879
|
}
|
|
@@ -877,7 +900,7 @@ export namespace PrebuiltWorkspaceContext {
|
|
|
877
900
|
}
|
|
878
901
|
|
|
879
902
|
export interface WithEnvvarsContext extends WorkspaceContext {
|
|
880
|
-
envvars:
|
|
903
|
+
envvars: EnvVarWithValue[];
|
|
881
904
|
}
|
|
882
905
|
|
|
883
906
|
export namespace WithEnvvarsContext {
|
|
@@ -941,9 +964,47 @@ export namespace AdditionalContentContext {
|
|
|
941
964
|
}
|
|
942
965
|
}
|
|
943
966
|
|
|
944
|
-
export interface CommitContext extends WorkspaceContext,
|
|
967
|
+
export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
|
|
945
968
|
/** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
|
|
946
969
|
cloneUrl?: string
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* The clone and checkout information for the sub-repositories in case of multi-repo projects.
|
|
973
|
+
*/
|
|
974
|
+
subRepositoryCheckoutInfo?: GitCheckoutInfo[];
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
export namespace CommitContext {
|
|
978
|
+
/**
|
|
979
|
+
* Creates an identifier pointing to the commits of the CommitContext and all sub-repo commit infos.
|
|
980
|
+
* The identifier is max 255 chars long.
|
|
981
|
+
* @param commitContext
|
|
982
|
+
* @returns identifier for set of commits
|
|
983
|
+
*/
|
|
984
|
+
export function getCommitSHAs(commitContext: CommitContext): string {
|
|
985
|
+
if (!commitContext.subRepositoryCheckoutInfo || commitContext.subRepositoryCheckoutInfo.length === 0) {
|
|
986
|
+
return commitContext.revision;
|
|
987
|
+
}
|
|
988
|
+
// 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.
|
|
989
|
+
const commits = [commitContext.revision, ... commitContext.subRepositoryCheckoutInfo.map(i => i.revision)];
|
|
990
|
+
const maxLength = Math.min(7, 255 / commits.length);
|
|
991
|
+
return commits.map( r => r.substring(0, maxLength)).join(',');
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* unparses the commitShaIdentifier into an array of commit SHAs.
|
|
996
|
+
* @param commitSHAIdentifier
|
|
997
|
+
* @returns the array of commit SHAs
|
|
998
|
+
*/
|
|
999
|
+
export function parseCommitSHAs(commitSHAIdentifier: string): string[] {
|
|
1000
|
+
return commitSHAIdentifier.split(',');
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
export interface GitCheckoutInfo extends Commit {
|
|
1005
|
+
checkoutLocation?: string;
|
|
1006
|
+
upstreamRemoteURI?: string;
|
|
1007
|
+
localBranch?: string;
|
|
947
1008
|
}
|
|
948
1009
|
|
|
949
1010
|
export namespace CommitContext {
|
|
@@ -1175,39 +1236,6 @@ export namespace AuthProviderEntry {
|
|
|
1175
1236
|
}
|
|
1176
1237
|
}
|
|
1177
1238
|
|
|
1178
|
-
export interface Branding {
|
|
1179
|
-
readonly name: string;
|
|
1180
|
-
readonly favicon?: string;
|
|
1181
|
-
/** Either including domain OR absolute path (interpreted relative to host URL) */
|
|
1182
|
-
readonly logo: string;
|
|
1183
|
-
readonly startupLogo: string;
|
|
1184
|
-
readonly showProductivityTips: boolean;
|
|
1185
|
-
readonly redirectUrlIfNotAuthenticated?: string;
|
|
1186
|
-
readonly redirectUrlAfterLogout?: string;
|
|
1187
|
-
readonly homepage: string;
|
|
1188
|
-
readonly ide?: {
|
|
1189
|
-
readonly logo: string;
|
|
1190
|
-
readonly showReleaseNotes: boolean;
|
|
1191
|
-
readonly helpMenu: Branding.Link[];
|
|
1192
|
-
}
|
|
1193
|
-
readonly links: {
|
|
1194
|
-
readonly header: Branding.Link[];
|
|
1195
|
-
readonly footer: Branding.Link[];
|
|
1196
|
-
readonly social: Branding.SocialLink[];
|
|
1197
|
-
readonly legal: Branding.Link[];
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
export namespace Branding {
|
|
1201
|
-
export interface Link {
|
|
1202
|
-
readonly name: string;
|
|
1203
|
-
readonly url: string;
|
|
1204
|
-
}
|
|
1205
|
-
export interface SocialLink {
|
|
1206
|
-
readonly type: string;
|
|
1207
|
-
readonly url: string;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
1239
|
export interface Configuration {
|
|
1212
1240
|
readonly daysBeforeGarbageCollection: number;
|
|
1213
1241
|
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;
|
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
|
-
}
|