Skip to content

Commit 88b2d90

Browse files
committed
[image-builder, et. al] Return the public workspace URL for all imagebuilds (incl. extra headers to access said URL) and store it in workspace
1 parent a82a23f commit 88b2d90

File tree

17 files changed

+547
-38
lines changed

17 files changed

+547
-38
lines changed

components/gitpod-db/src/typeorm/entity/db-workspace.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { PrimaryColumn, Column, Entity, Index } from "typeorm";
88

9-
import { Workspace, WorkspaceConfig, WorkspaceContext, WorkspaceImageSource, WorkspaceType, WorkspaceSoftDeletion } from "@gitpod/gitpod-protocol";
9+
import { Workspace, WorkspaceConfig, WorkspaceContext, WorkspaceImageSource, WorkspaceType, WorkspaceSoftDeletion, ImageBuildInfo } from "@gitpod/gitpod-protocol";
1010
import { TypeORM } from "../typeorm";
1111
import { Transformer } from "../transformer";
1212

@@ -105,4 +105,7 @@ export class DBWorkspace implements Workspace {
105105
})
106106
@Index('ind_basedOnSnapshotId')
107107
basedOnSnapshotId?: string;
108+
109+
@Column("simple-json", { nullable: true })
110+
imageBuildInfo?: ImageBuildInfo;
108111
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
import {MigrationInterface, QueryRunner} from "typeorm";
8+
import { columnExists } from "./helper/helper";
9+
10+
export class ImageBuildInfo1643295551434 implements MigrationInterface {
11+
12+
public async up(queryRunner: QueryRunner): Promise<void> {
13+
if (!(await columnExists(queryRunner, "d_b_workspace", "imageBuildInfo"))) {
14+
await queryRunner.query("ALTER TABLE d_b_workspace ADD COLUMN `imageBuildInfo` text NULL");
15+
}
16+
}
17+
18+
public async down(queryRunner: QueryRunner): Promise<void> {
19+
}
20+
21+
}

components/gitpod-protocol/src/protocol.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,29 @@ export interface Workspace {
463463
basedOnPrebuildId?: string;
464464

465465
basedOnSnapshotId?: string;
466+
467+
/**
468+
* Contains information about the image build, if there was any
469+
*/
470+
imageBuildInfo?: ImageBuildInfo;
466471
}
467472

468473
export type WorkspaceSoftDeletion = "user" | "gc";
469474

470475
export type WorkspaceType = "regular" | "prebuild" | "probe";
471476

477+
export interface ImageBuildInfo {
478+
log?: ImageBuildLogInfo,
479+
}
480+
481+
/**
482+
* Holds information about how to access logs for this an image build
483+
*/
484+
export interface ImageBuildLogInfo {
485+
url: string,
486+
headers: { [key: string]: string },
487+
}
488+
472489
export namespace Workspace {
473490

474491
export function getFullRepositoryName(ws: Workspace): string | undefined {

components/image-builder-api/go/imgbuilder.pb.go

Lines changed: 113 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/image-builder-api/go/imgbuilder_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/image-builder-api/go/mock/mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/image-builder-api/imgbuilder.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,10 @@ message BuildInfo {
128128
BuildStatus status = 2;
129129
int64 started_at = 3;
130130
string build_id = 5;
131+
LogInfo log_info = 6;
132+
}
133+
134+
message LogInfo {
135+
string url = 1;
136+
map<string, string> headers = 2;
131137
}

components/image-builder-api/typescript/src/imgbuilder_grpc_pb.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
33
* Licensed under the GNU Affero General Public License (AGPL).
44
* See License-AGPL.txt in the project root for license information.
55
*/

components/image-builder-api/typescript/src/imgbuilder_grpc_pb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
33
* Licensed under the GNU Affero General Public License (AGPL).
44
* See License-AGPL.txt in the project root for license information.
55
*/

components/image-builder-api/typescript/src/imgbuilder_pb.d.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
33
* Licensed under the GNU Affero General Public License (AGPL).
44
* See License-AGPL.txt in the project root for license information.
55
*/
@@ -456,6 +456,11 @@ export class BuildInfo extends jspb.Message {
456456
getBuildId(): string;
457457
setBuildId(value: string): BuildInfo;
458458

459+
hasLogInfo(): boolean;
460+
clearLogInfo(): void;
461+
getLogInfo(): LogInfo | undefined;
462+
setLogInfo(value?: LogInfo): BuildInfo;
463+
459464
serializeBinary(): Uint8Array;
460465
toObject(includeInstance?: boolean): BuildInfo.AsObject;
461466
static toObject(includeInstance: boolean, msg: BuildInfo): BuildInfo.AsObject;
@@ -473,6 +478,32 @@ export namespace BuildInfo {
473478
status: BuildStatus,
474479
startedAt: number,
475480
buildId: string,
481+
logInfo?: LogInfo.AsObject,
482+
}
483+
}
484+
485+
export class LogInfo extends jspb.Message {
486+
getUrl(): string;
487+
setUrl(value: string): LogInfo;
488+
489+
getHeadersMap(): jspb.Map<string, string>;
490+
clearHeadersMap(): void;
491+
492+
serializeBinary(): Uint8Array;
493+
toObject(includeInstance?: boolean): LogInfo.AsObject;
494+
static toObject(includeInstance: boolean, msg: LogInfo): LogInfo.AsObject;
495+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
496+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
497+
static serializeBinaryToWriter(message: LogInfo, writer: jspb.BinaryWriter): void;
498+
static deserializeBinary(bytes: Uint8Array): LogInfo;
499+
static deserializeBinaryFromReader(message: LogInfo, reader: jspb.BinaryReader): LogInfo;
500+
}
501+
502+
export namespace LogInfo {
503+
export type AsObject = {
504+
url: string,
505+
506+
headersMap: Array<[string, string]>,
476507
}
477508
}
478509

0 commit comments

Comments
 (0)