@gitpod/gitpod-protocol 0.1.5-minor-updates.0 → 0.1.5-mp-docs-wsp-phase.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 +53 -26
- 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 +27 -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 +44 -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 +31 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +102 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +14 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +94 -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 +124 -30
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +167 -278
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +9 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +5 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +105 -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 +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/messaging/browser/connection.d.ts +5 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +183 -33
- 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/error.d.ts +3 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +6 -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.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- 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/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/permission.d.ts +8 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +36 -15
- 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 +152 -76
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +139 -131
- 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 +6 -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 +113 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +30 -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 +88 -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.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +31 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -78
- 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 -2
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +95 -98
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +7 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +103 -31
- 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/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/{theia-plugins.js → util/jaeger-client-types.js} +1 -1
- package/lib/util/jaeger-client-types.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/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- 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 +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -62
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- 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 +76 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +33 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +26 -4
- 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 +31 -17
- package/pkg-yarn.lock +17 -9
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +48 -5
- package/src/analytics.ts +52 -0
- package/src/context-url.spec.ts +53 -0
- package/src/context-url.ts +107 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +181 -53
- package/src/headless-workspace-log.ts +8 -11
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +7 -1
- package/src/installation-admin-protocol.ts +42 -0
- package/src/messaging/browser/connection.ts +195 -14
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +8 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +21 -68
- package/src/messaging/proxy-factory.ts +13 -5
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +24 -4
- package/src/plans.ts +632 -0
- package/src/protocol.ts +245 -112
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +9 -5
- package/src/teams-projects-protocol.ts +147 -0
- package/src/util/analytics.ts +105 -0
- package/src/util/garbage-collected-cache.ts +9 -3
- package/src/util/generate-workspace-id.spec.ts +20 -3
- package/src/util/generate-workspace-id.ts +22 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +25 -1
- package/src/util/gitpod-host-url.ts +22 -13
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -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/repeat.ts +45 -0
- 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.spec.ts +83 -0
- package/src/util/tracing.ts +183 -17
- package/src/workspace-cluster.ts +104 -0
- package/src/workspace-instance.ts +66 -30
- package/src/wsready.ts +2 -2
- package/data/builtin-theia-plugins.json +0 -372
- 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 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js.map +0 -1
- 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 +0 -10
- 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/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.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/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
package/src/protocol.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
|
|
8
8
|
import { RoleOrPermission } from "./permission";
|
|
9
|
+
import { Project } from "./teams-projects-protocol";
|
|
10
|
+
import { createHash } from "crypto";
|
|
9
11
|
|
|
10
12
|
export interface UserInfo {
|
|
11
13
|
name?: string
|
|
@@ -27,8 +29,6 @@ export interface User {
|
|
|
27
29
|
|
|
28
30
|
identities: Identity[]
|
|
29
31
|
|
|
30
|
-
allowsMarketingCommunication: boolean;
|
|
31
|
-
|
|
32
32
|
/**
|
|
33
33
|
* Whether the user has been blocked to use our service, because of TOS violation for example.
|
|
34
34
|
* Optional for backwards compatibility.
|
|
@@ -98,14 +98,29 @@ export interface AdditionalUserData {
|
|
|
98
98
|
emailNotificationSettings?: EmailNotificationSettings;
|
|
99
99
|
featurePreview?: boolean;
|
|
100
100
|
ideSettings?: IDESettings;
|
|
101
|
+
// key is the name of the news, string the iso date when it was seen
|
|
102
|
+
whatsNewSeen?: { [key: string]: string }
|
|
103
|
+
// key is the name of the OAuth client i.e. local app, string the iso date when it was approved
|
|
104
|
+
// TODO(rl): provide a management UX to allow rescinding of approval
|
|
105
|
+
oauthClientsApproved?: { [key: string]: string }
|
|
106
|
+
// to remember GH Orgs the user installed/updated the GH App for
|
|
107
|
+
knownGitHubOrgs?: string[];
|
|
108
|
+
|
|
109
|
+
// Git clone URL pointing to the user's dotfile repo
|
|
110
|
+
dotfileRepo?: string;
|
|
101
111
|
}
|
|
102
112
|
|
|
103
113
|
export interface EmailNotificationSettings {
|
|
104
|
-
|
|
114
|
+
allowsChangelogMail?: boolean;
|
|
115
|
+
allowsDevXMail?: boolean;
|
|
116
|
+
allowsOnboardingMail?: boolean;
|
|
105
117
|
}
|
|
106
118
|
|
|
107
119
|
export type IDESettings = {
|
|
108
120
|
defaultIde?: string
|
|
121
|
+
useDesktopIde?: boolean
|
|
122
|
+
defaultDesktopIde?: string
|
|
123
|
+
useLatestVersion?: boolean
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
export interface UserPlatform {
|
|
@@ -127,14 +142,6 @@ export interface UserPlatform {
|
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
export interface UserFeatureSettings {
|
|
130
|
-
/**
|
|
131
|
-
* This field is used as marker to grant users a free trial for using private repositories,
|
|
132
|
-
* independent of any subscription or Chargebee.
|
|
133
|
-
* - it is set when the user uses their first private repo
|
|
134
|
-
* - whether the trial is expired or not is juged by the UserService
|
|
135
|
-
*/
|
|
136
|
-
privateRepoTrialStartDate?: string;
|
|
137
|
-
|
|
138
145
|
/**
|
|
139
146
|
* Permanent feature flags are added to each and every workspace instance
|
|
140
147
|
* this user starts.
|
|
@@ -146,15 +153,26 @@ export interface UserFeatureSettings {
|
|
|
146
153
|
* The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
|
|
147
154
|
* If they don't we'll break things during workspace startup.
|
|
148
155
|
*/
|
|
149
|
-
export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined
|
|
156
|
+
export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
|
|
150
157
|
export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
|
|
151
158
|
|
|
152
|
-
export interface
|
|
153
|
-
id?: string;
|
|
159
|
+
export interface EnvVarWithValue {
|
|
154
160
|
name: string;
|
|
155
|
-
repositoryPattern: string;
|
|
156
161
|
value: string;
|
|
157
162
|
}
|
|
163
|
+
|
|
164
|
+
export interface ProjectEnvVarWithValue extends EnvVarWithValue {
|
|
165
|
+
id: string;
|
|
166
|
+
projectId: string;
|
|
167
|
+
censored: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
|
|
171
|
+
|
|
172
|
+
export interface UserEnvVarValue extends EnvVarWithValue {
|
|
173
|
+
id?: string;
|
|
174
|
+
repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
175
|
+
}
|
|
158
176
|
export interface UserEnvVar extends UserEnvVarValue {
|
|
159
177
|
id: string;
|
|
160
178
|
userId: string;
|
|
@@ -163,10 +181,35 @@ export interface UserEnvVar extends UserEnvVarValue {
|
|
|
163
181
|
|
|
164
182
|
export namespace UserEnvVar {
|
|
165
183
|
|
|
184
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
166
185
|
export function normalizeRepoPattern(pattern: string) {
|
|
167
186
|
return pattern.toLocaleLowerCase();
|
|
168
187
|
}
|
|
169
188
|
|
|
189
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
190
|
+
export function score(value: UserEnvVarValue): number {
|
|
191
|
+
// We use a score to enforce precedence:
|
|
192
|
+
// value/value = 0
|
|
193
|
+
// value/* = 1
|
|
194
|
+
// */value = 2
|
|
195
|
+
// */* = 3
|
|
196
|
+
// #/# = 4 (used for env vars passed through the URL)
|
|
197
|
+
// the lower the score, the higher the precedence.
|
|
198
|
+
const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
|
|
199
|
+
let score = 0;
|
|
200
|
+
if (repoPattern == "*") {
|
|
201
|
+
score += 1;
|
|
202
|
+
}
|
|
203
|
+
if (ownerPattern == '*') {
|
|
204
|
+
score += 2;
|
|
205
|
+
}
|
|
206
|
+
if (ownerPattern == "#" || repoPattern == "#") {
|
|
207
|
+
score = 4;
|
|
208
|
+
}
|
|
209
|
+
return score;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
170
213
|
export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
|
|
171
214
|
let result = vars.filter(e => {
|
|
172
215
|
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
@@ -202,25 +245,7 @@ export namespace UserEnvVar {
|
|
|
202
245
|
let minscore = 10;
|
|
203
246
|
let bestCandidate: T | undefined;
|
|
204
247
|
for (const e of candidates) {
|
|
205
|
-
|
|
206
|
-
// value/value = 0
|
|
207
|
-
// value/* = 1
|
|
208
|
-
// */value = 2
|
|
209
|
-
// */* = 3
|
|
210
|
-
// #/# = 4 (used for env vars passed through the URL)
|
|
211
|
-
// the lower the score, the higher the precedence.
|
|
212
|
-
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
213
|
-
let score = 0;
|
|
214
|
-
if (repoPattern == "*") {
|
|
215
|
-
score += 1;
|
|
216
|
-
}
|
|
217
|
-
if (ownerPattern == '*') {
|
|
218
|
-
score += 2;
|
|
219
|
-
}
|
|
220
|
-
if (ownerPattern == "#" || repoPattern == "#") {
|
|
221
|
-
score = 4;
|
|
222
|
-
}
|
|
223
|
-
|
|
248
|
+
const score = UserEnvVar.score(e);
|
|
224
249
|
if (!bestCandidate || score < minscore) {
|
|
225
250
|
minscore = score;
|
|
226
251
|
bestCandidate = e;
|
|
@@ -232,10 +257,11 @@ export namespace UserEnvVar {
|
|
|
232
257
|
return result;
|
|
233
258
|
}
|
|
234
259
|
|
|
235
|
-
|
|
260
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
261
|
+
export function splitRepositoryPattern(repositoryPattern: string): string[] {
|
|
236
262
|
const patterns = repositoryPattern.split('/');
|
|
237
|
-
const repoPattern = patterns.
|
|
238
|
-
const ownerPattern = patterns
|
|
263
|
+
const repoPattern = patterns.slice(1).join('/')
|
|
264
|
+
const ownerPattern = patterns[0];
|
|
239
265
|
return [ownerPattern, repoPattern];
|
|
240
266
|
}
|
|
241
267
|
}
|
|
@@ -366,11 +392,16 @@ export interface PendingGithubEvent {
|
|
|
366
392
|
export interface Snapshot {
|
|
367
393
|
id: string;
|
|
368
394
|
creationTime: string;
|
|
395
|
+
availableTime?: string;
|
|
369
396
|
originalWorkspaceId: string;
|
|
370
397
|
bucketId: string;
|
|
371
398
|
layoutData?: string;
|
|
399
|
+
state: SnapshotState;
|
|
400
|
+
message?: string;
|
|
372
401
|
}
|
|
373
402
|
|
|
403
|
+
export type SnapshotState = 'pending' | 'available' | 'error';
|
|
404
|
+
|
|
374
405
|
export interface LayoutData {
|
|
375
406
|
workspaceId: string;
|
|
376
407
|
lastUpdatedTime: string;
|
|
@@ -383,6 +414,7 @@ export interface Workspace {
|
|
|
383
414
|
contextURL: string;
|
|
384
415
|
description: string;
|
|
385
416
|
ownerId: string;
|
|
417
|
+
projectId?: string;
|
|
386
418
|
context: WorkspaceContext;
|
|
387
419
|
config: WorkspaceConfig;
|
|
388
420
|
|
|
@@ -484,41 +516,36 @@ export namespace Workspace {
|
|
|
484
516
|
}
|
|
485
517
|
}
|
|
486
518
|
|
|
487
|
-
export interface
|
|
488
|
-
|
|
519
|
+
export interface GuessGitTokenScopesParams {
|
|
520
|
+
host: string
|
|
521
|
+
repoUrl: string
|
|
522
|
+
gitCommand: string
|
|
523
|
+
currentToken: GitToken
|
|
489
524
|
}
|
|
490
525
|
|
|
491
|
-
export interface
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
export interface InstallPluginsParams {
|
|
498
|
-
pluginIds: string[]
|
|
526
|
+
export interface GitToken {
|
|
527
|
+
token: string
|
|
528
|
+
user: string
|
|
529
|
+
scopes: string[]
|
|
499
530
|
}
|
|
500
531
|
|
|
501
|
-
export interface
|
|
502
|
-
|
|
532
|
+
export interface GuessedGitTokenScopes {
|
|
533
|
+
message?: string
|
|
534
|
+
scopes?: string[]
|
|
503
535
|
}
|
|
504
536
|
|
|
505
|
-
export
|
|
506
|
-
|
|
507
|
-
export interface ResolvedPlugins {
|
|
508
|
-
[pluginId: string]: ResolvedPlugin | undefined
|
|
537
|
+
export interface VSCodeConfig {
|
|
538
|
+
extensions?: string[];
|
|
509
539
|
}
|
|
510
540
|
|
|
511
|
-
export interface
|
|
512
|
-
fullPluginName: string;
|
|
541
|
+
export interface RepositoryCloneInformation {
|
|
513
542
|
url: string;
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export interface VSCodeConfig {
|
|
518
|
-
extensions?: string[];
|
|
543
|
+
checkoutLocation?: string;
|
|
519
544
|
}
|
|
520
545
|
|
|
521
546
|
export interface WorkspaceConfig {
|
|
547
|
+
mainConfiguration?: string;
|
|
548
|
+
additionalRepositories?: RepositoryCloneInformation[];
|
|
522
549
|
image?: ImageConfig;
|
|
523
550
|
ports?: PortConfig[];
|
|
524
551
|
tasks?: TaskConfig[];
|
|
@@ -527,16 +554,21 @@ export interface WorkspaceConfig {
|
|
|
527
554
|
gitConfig?: { [config: string]: string };
|
|
528
555
|
github?: GithubAppConfig;
|
|
529
556
|
vscode?: VSCodeConfig;
|
|
530
|
-
|
|
557
|
+
|
|
558
|
+
/** deprecated. Enabled by default **/
|
|
559
|
+
experimentalNetwork?: boolean;
|
|
560
|
+
|
|
531
561
|
/**
|
|
532
562
|
* Where the config object originates from.
|
|
533
|
-
*
|
|
563
|
+
*
|
|
534
564
|
* repo - from the repository
|
|
565
|
+
* project-db - from the "Project" stored in the database
|
|
535
566
|
* definitly-gp - from github.com/gitpod-io/definitely-gp
|
|
536
567
|
* derived - computed based on analyzing the repository
|
|
568
|
+
* additional-content - config comes from additional content, usually provided through the project's configuration
|
|
537
569
|
* default - our static catch-all default config
|
|
538
570
|
*/
|
|
539
|
-
_origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
|
|
571
|
+
_origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
|
|
540
572
|
|
|
541
573
|
/**
|
|
542
574
|
* Set of automatically infered feature flags. That's not something the user can set, but
|
|
@@ -553,7 +585,7 @@ export interface GithubAppPrebuildConfig {
|
|
|
553
585
|
branches?: boolean
|
|
554
586
|
pullRequests?: boolean
|
|
555
587
|
pullRequestsFromForks?: boolean
|
|
556
|
-
addCheck?: boolean
|
|
588
|
+
addCheck?: boolean | 'prevent-merge-on-error'
|
|
557
589
|
addBadge?: boolean
|
|
558
590
|
addLabel?: boolean | string
|
|
559
591
|
addComment?: boolean
|
|
@@ -566,16 +598,13 @@ export namespace GithubAppPrebuildConfig {
|
|
|
566
598
|
|
|
567
599
|
export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
|
|
568
600
|
export interface WorkspaceImageSourceDocker {
|
|
569
|
-
// TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
|
|
570
|
-
// We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
|
|
571
|
-
dockerFileHash: string
|
|
572
|
-
dockerFileSource: Commit
|
|
573
601
|
dockerFilePath: string
|
|
602
|
+
dockerFileHash: string
|
|
603
|
+
dockerFileSource?: Commit
|
|
574
604
|
}
|
|
575
605
|
export namespace WorkspaceImageSourceDocker {
|
|
576
606
|
export function is(obj: object): obj is WorkspaceImageSourceDocker {
|
|
577
607
|
return 'dockerFileHash' in obj
|
|
578
|
-
&& 'dockerFileSource' in obj
|
|
579
608
|
&& 'dockerFilePath' in obj;
|
|
580
609
|
}
|
|
581
610
|
}
|
|
@@ -594,16 +623,20 @@ export type PrebuiltWorkspaceState
|
|
|
594
623
|
= "queued"
|
|
595
624
|
// the workspace prebuild is currently running (i.e. there's a workspace pod deployed)
|
|
596
625
|
| "building"
|
|
597
|
-
// the prebuild
|
|
626
|
+
// the prebuild was aborted
|
|
598
627
|
| "aborted"
|
|
599
628
|
// the prebuild timed out
|
|
600
629
|
| "timeout"
|
|
601
|
-
// the prebuild has finished and a snapshot is available
|
|
602
|
-
| "available"
|
|
630
|
+
// the prebuild has finished (even if a headless task failed) and a snapshot is available
|
|
631
|
+
| "available"
|
|
632
|
+
// the prebuild (headless workspace) failed due to some system error
|
|
633
|
+
| "failed";
|
|
603
634
|
|
|
604
635
|
export interface PrebuiltWorkspace {
|
|
605
636
|
id: string;
|
|
606
637
|
cloneURL: string;
|
|
638
|
+
branch?: string;
|
|
639
|
+
projectId?: string;
|
|
607
640
|
commit: string;
|
|
608
641
|
buildWorkspaceId: string;
|
|
609
642
|
creationTime: string;
|
|
@@ -614,7 +647,7 @@ export interface PrebuiltWorkspace {
|
|
|
614
647
|
|
|
615
648
|
export namespace PrebuiltWorkspace {
|
|
616
649
|
export function isDone(pws: PrebuiltWorkspace) {
|
|
617
|
-
return pws.state === "available" || pws.state === "timeout" ||
|
|
650
|
+
return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
|
|
618
651
|
}
|
|
619
652
|
|
|
620
653
|
export function isAvailable(pws: PrebuiltWorkspace) {
|
|
@@ -633,6 +666,10 @@ export interface PrebuiltWorkspaceUpdatable {
|
|
|
633
666
|
repo: string;
|
|
634
667
|
isResolved: boolean;
|
|
635
668
|
installationId: string;
|
|
669
|
+
/**
|
|
670
|
+
* the commitSHA of the commit that triggered the prebuild
|
|
671
|
+
*/
|
|
672
|
+
commitSHA?: string;
|
|
636
673
|
issue?: string;
|
|
637
674
|
contextUrl?: string;
|
|
638
675
|
}
|
|
@@ -650,6 +687,8 @@ export interface PortConfig {
|
|
|
650
687
|
port: number;
|
|
651
688
|
onOpen?: PortOnOpen;
|
|
652
689
|
visibility?: PortVisibility;
|
|
690
|
+
description?: string;
|
|
691
|
+
name?: string;
|
|
653
692
|
}
|
|
654
693
|
export namespace PortConfig {
|
|
655
694
|
export function is(config: any): config is PortConfig {
|
|
@@ -673,7 +712,7 @@ export interface TaskConfig {
|
|
|
673
712
|
init?: string;
|
|
674
713
|
prebuild?: string;
|
|
675
714
|
command?: string;
|
|
676
|
-
env?: { [env: string]:
|
|
715
|
+
env?: { [env: string]: any };
|
|
677
716
|
openIn?: 'bottom' | 'main' | 'left' | 'right';
|
|
678
717
|
openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
|
|
679
718
|
}
|
|
@@ -737,8 +776,10 @@ export namespace ExternalImageConfigFile {
|
|
|
737
776
|
|
|
738
777
|
export interface WorkspaceContext {
|
|
739
778
|
title: string;
|
|
779
|
+
/** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */
|
|
740
780
|
normalizedContextURL?: string;
|
|
741
781
|
forceCreateNewWorkspace?: boolean;
|
|
782
|
+
forceImageBuild?: boolean;
|
|
742
783
|
}
|
|
743
784
|
|
|
744
785
|
export namespace WorkspaceContext {
|
|
@@ -758,20 +799,42 @@ export namespace WithSnapshot {
|
|
|
758
799
|
}
|
|
759
800
|
}
|
|
760
801
|
|
|
761
|
-
export interface WithPrebuild {
|
|
762
|
-
snapshotBucketId: string;
|
|
802
|
+
export interface WithPrebuild extends WithSnapshot {
|
|
763
803
|
prebuildWorkspaceId: string;
|
|
764
804
|
wasPrebuilt: true;
|
|
765
805
|
}
|
|
766
806
|
export namespace WithPrebuild {
|
|
767
807
|
export function is(context: any): context is WithPrebuild {
|
|
768
808
|
return context
|
|
769
|
-
&&
|
|
809
|
+
&& WithSnapshot.is(context)
|
|
770
810
|
&& 'prebuildWorkspaceId' in context
|
|
771
811
|
&& 'wasPrebuilt' in context;
|
|
772
812
|
}
|
|
773
813
|
}
|
|
774
814
|
|
|
815
|
+
/**
|
|
816
|
+
* WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
|
|
817
|
+
* and fall back to the built-in configuration.
|
|
818
|
+
*/
|
|
819
|
+
export interface WithDefaultConfig {
|
|
820
|
+
withDefaultConfig: true;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
export namespace WithDefaultConfig {
|
|
824
|
+
export function is(context: any): context is WithDefaultConfig {
|
|
825
|
+
return context
|
|
826
|
+
&& 'withDefaultConfig' in context
|
|
827
|
+
&& context.withDefaultConfig;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
|
|
831
|
+
return {
|
|
832
|
+
...ctx,
|
|
833
|
+
withDefaultConfig: true
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
775
838
|
export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
|
|
776
839
|
snapshotId: string;
|
|
777
840
|
}
|
|
@@ -786,6 +849,13 @@ export namespace SnapshotContext {
|
|
|
786
849
|
|
|
787
850
|
export interface StartPrebuildContext extends WorkspaceContext {
|
|
788
851
|
actual: WorkspaceContext;
|
|
852
|
+
commitHistory?: string[];
|
|
853
|
+
additionalRepositoryCommitHistories?: {
|
|
854
|
+
cloneUrl: string;
|
|
855
|
+
commitHistory: string[];
|
|
856
|
+
}[];
|
|
857
|
+
project?: Project;
|
|
858
|
+
branch?: string;
|
|
789
859
|
}
|
|
790
860
|
|
|
791
861
|
export namespace StartPrebuildContext {
|
|
@@ -809,8 +879,20 @@ export namespace PrebuiltWorkspaceContext {
|
|
|
809
879
|
}
|
|
810
880
|
}
|
|
811
881
|
|
|
882
|
+
export interface WithReferrerContext extends WorkspaceContext {
|
|
883
|
+
referrer: string
|
|
884
|
+
referrerIde?: string
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export namespace WithReferrerContext {
|
|
888
|
+
export function is(context: any): context is WithReferrerContext {
|
|
889
|
+
return context
|
|
890
|
+
&& 'referrer' in context;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
812
894
|
export interface WithEnvvarsContext extends WorkspaceContext {
|
|
813
|
-
envvars:
|
|
895
|
+
envvars: EnvVarWithValue[];
|
|
814
896
|
}
|
|
815
897
|
|
|
816
898
|
export namespace WithEnvvarsContext {
|
|
@@ -855,9 +937,62 @@ export interface Commit {
|
|
|
855
937
|
refType?: RefType
|
|
856
938
|
}
|
|
857
939
|
|
|
858
|
-
export interface
|
|
940
|
+
export interface AdditionalContentContext extends WorkspaceContext {
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* utf-8 encoded contents that will be copied on top of the workspace's filesystem
|
|
944
|
+
*/
|
|
945
|
+
additionalFiles: {[filePath: string]: string};
|
|
946
|
+
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
export namespace AdditionalContentContext {
|
|
950
|
+
export function is(ctx: any): ctx is AdditionalContentContext {
|
|
951
|
+
return 'additionalFiles' in ctx;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
|
|
955
|
+
return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
|
|
859
960
|
/** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
|
|
860
961
|
cloneUrl?: string
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* The clone and checkout information for additional repositories in case of multi-repo projects.
|
|
965
|
+
*/
|
|
966
|
+
additionalRepositoryCheckoutInfo?: GitCheckoutInfo[];
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
export namespace CommitContext {
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Creates a hash for all the commits of the CommitContext and all sub-repo commit infos.
|
|
973
|
+
* The hash is max 255 chars long.
|
|
974
|
+
* @param commitContext
|
|
975
|
+
* @returns hash for commitcontext
|
|
976
|
+
*/
|
|
977
|
+
export function computeHash(commitContext: CommitContext): string {
|
|
978
|
+
// for single commits we use the revision to be backward compatible.
|
|
979
|
+
if (!commitContext.additionalRepositoryCheckoutInfo || commitContext.additionalRepositoryCheckoutInfo.length === 0) {
|
|
980
|
+
return commitContext.revision;
|
|
981
|
+
}
|
|
982
|
+
const hasher = createHash('sha256');
|
|
983
|
+
hasher.update(commitContext.revision);
|
|
984
|
+
for (const info of commitContext.additionalRepositoryCheckoutInfo) {
|
|
985
|
+
hasher.update(info.revision);
|
|
986
|
+
}
|
|
987
|
+
return hasher.digest('hex');
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
export interface GitCheckoutInfo extends Commit {
|
|
993
|
+
checkoutLocation?: string;
|
|
994
|
+
upstreamRemoteURI?: string;
|
|
995
|
+
localBranch?: string;
|
|
861
996
|
}
|
|
862
997
|
|
|
863
998
|
export namespace CommitContext {
|
|
@@ -930,6 +1065,19 @@ export interface Repository {
|
|
|
930
1065
|
parent: Repository
|
|
931
1066
|
}
|
|
932
1067
|
}
|
|
1068
|
+
export interface Branch {
|
|
1069
|
+
name: string;
|
|
1070
|
+
commit: CommitInfo;
|
|
1071
|
+
htmlUrl: string;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
export interface CommitInfo {
|
|
1075
|
+
author: string;
|
|
1076
|
+
sha: string;
|
|
1077
|
+
commitMessage: string;
|
|
1078
|
+
authorAvatarUrl?: string;
|
|
1079
|
+
authorDate?: string;
|
|
1080
|
+
}
|
|
933
1081
|
|
|
934
1082
|
export namespace Repository {
|
|
935
1083
|
export function fullRepoName(repo: Repository): string {
|
|
@@ -957,6 +1105,12 @@ export interface WorkspaceInfo {
|
|
|
957
1105
|
latestInstance?: WorkspaceInstance
|
|
958
1106
|
}
|
|
959
1107
|
|
|
1108
|
+
export namespace WorkspaceInfo {
|
|
1109
|
+
export function lastActiveISODate(info: WorkspaceInfo): string {
|
|
1110
|
+
return info.latestInstance?.creationTime || info.workspace.creationTime;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
960
1114
|
export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
|
|
961
1115
|
|
|
962
1116
|
export interface WorkspaceCreationResult {
|
|
@@ -966,6 +1120,7 @@ export interface WorkspaceCreationResult {
|
|
|
966
1120
|
runningWorkspacePrebuild?: {
|
|
967
1121
|
prebuildID: string
|
|
968
1122
|
workspaceID: string
|
|
1123
|
+
instanceID: string
|
|
969
1124
|
starting: RunningWorkspacePrebuildStarting
|
|
970
1125
|
sameCluster: boolean
|
|
971
1126
|
}
|
|
@@ -1037,6 +1192,8 @@ export interface AuthProviderEntry {
|
|
|
1037
1192
|
readonly status: AuthProviderEntry.Status;
|
|
1038
1193
|
|
|
1039
1194
|
readonly oauth: OAuth2Config;
|
|
1195
|
+
/** A random string that is to change whenever oauth changes (enforced on DB level) */
|
|
1196
|
+
readonly oauthRevision?: string;
|
|
1040
1197
|
}
|
|
1041
1198
|
|
|
1042
1199
|
export interface OAuth2Config {
|
|
@@ -1056,40 +1213,16 @@ export interface OAuth2Config {
|
|
|
1056
1213
|
export namespace AuthProviderEntry {
|
|
1057
1214
|
export type Type = "GitHub" | "GitLab" | string;
|
|
1058
1215
|
export type Status = "pending" | "verified";
|
|
1059
|
-
export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"
|
|
1216
|
+
export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
|
|
1060
1217
|
export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
readonly showProductivityTips: boolean;
|
|
1070
|
-
readonly redirectUrlIfNotAuthenticated?: string;
|
|
1071
|
-
readonly redirectUrlAfterLogout?: string;
|
|
1072
|
-
readonly homepage: string;
|
|
1073
|
-
readonly ide?: {
|
|
1074
|
-
readonly logo: string;
|
|
1075
|
-
readonly showReleaseNotes: boolean;
|
|
1076
|
-
readonly helpMenu: Branding.Link[];
|
|
1077
|
-
}
|
|
1078
|
-
readonly links: {
|
|
1079
|
-
readonly header: Branding.Link[];
|
|
1080
|
-
readonly footer: Branding.Link[];
|
|
1081
|
-
readonly social: Branding.SocialLink[];
|
|
1082
|
-
readonly legal: Branding.Link[];
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
export namespace Branding {
|
|
1086
|
-
export interface Link {
|
|
1087
|
-
readonly name: string;
|
|
1088
|
-
readonly url: string;
|
|
1089
|
-
}
|
|
1090
|
-
export interface SocialLink {
|
|
1091
|
-
readonly type: string;
|
|
1092
|
-
readonly url: string;
|
|
1218
|
+
export function redact(entry: AuthProviderEntry): AuthProviderEntry {
|
|
1219
|
+
return {
|
|
1220
|
+
...entry,
|
|
1221
|
+
oauth: {
|
|
1222
|
+
...entry.oauth,
|
|
1223
|
+
clientSecret: "redacted"
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1093
1226
|
}
|
|
1094
1227
|
}
|
|
1095
1228
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 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
|
+
import { suite, test } from "mocha-typescript"
|
|
8
|
+
import * as chai from "chai"
|
|
9
|
+
import { SnapshotUrl } from ".";
|
|
10
|
+
|
|
11
|
+
const expect = chai.expect
|
|
12
|
+
|
|
13
|
+
@suite class TestSnapshotUrlParser {
|
|
14
|
+
|
|
15
|
+
@test public testPositive() {
|
|
16
|
+
const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
|
|
17
|
+
|
|
18
|
+
expect(actual).to.deep.equal(<SnapshotUrl>{
|
|
19
|
+
bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
|
|
20
|
+
filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
|
|
21
|
+
fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
|
|
@@ -0,0 +1,27 @@
|
|
|
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 interface SnapshotUrl {
|
|
8
|
+
bucketId: string;
|
|
9
|
+
fullPath: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}
|
|
12
|
+
export namespace SnapshotUrl {
|
|
13
|
+
export function parse(url: string): SnapshotUrl {
|
|
14
|
+
const parts = url.split("@");
|
|
15
|
+
if (parts.length !== 2) {
|
|
16
|
+
throw new Error(`cannot parse snapshot URL: ${url}`);
|
|
17
|
+
}
|
|
18
|
+
const [fullPath, bucketId] = parts;
|
|
19
|
+
|
|
20
|
+
const pathParts = fullPath.split("/");
|
|
21
|
+
if (pathParts.length < 1) {
|
|
22
|
+
throw new Error(`cannot parse snapshot URL: ${url}`);
|
|
23
|
+
}
|
|
24
|
+
const filename = pathParts[pathParts.length - 1];
|
|
25
|
+
return { bucketId, fullPath, filename };
|
|
26
|
+
}
|
|
27
|
+
}
|