Skip to content

Commit

Permalink
[image-builder, et. al] Return the public workspace URL for all image…
Browse files Browse the repository at this point in the history
…builds (incl. extra headers to access said URL) and store it in workspace
  • Loading branch information
geropl committed Feb 1, 2022
1 parent a82a23f commit ecf1113
Show file tree
Hide file tree
Showing 17 changed files with 549 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

import { WorkspaceInstance, WorkspaceInstanceStatus, WorkspaceInstancePhase, WorkspaceInstanceConfiguration } from "@gitpod/gitpod-protocol";
import { WorkspaceInstance, WorkspaceInstanceStatus, WorkspaceInstancePhase, WorkspaceInstanceConfiguration, ImageBuildInfo } from "@gitpod/gitpod-protocol";
import { TypeORM } from "../typeorm";
import { Transformer } from "../transformer";

Expand Down Expand Up @@ -87,4 +87,6 @@ export class DBWorkspaceInstance implements WorkspaceInstance {
})
configuration?: WorkspaceInstanceConfiguration;

@Column("simple-json", { nullable: true })
imageBuildInfo?: ImageBuildInfo;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import {MigrationInterface, QueryRunner} from "typeorm";
import { columnExists } from "./helper/helper";

export class ImageBuildInfo1643724132624 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
if (!(await columnExists(queryRunner, "d_b_workspace_instance", "imageBuildInfo"))) {
await queryRunner.query("ALTER TABLE d_b_workspace_instance ADD COLUMN `imageBuildInfo` text NULL");
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
}

}
20 changes: 20 additions & 0 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export interface WorkspaceInstance {

// instance is hard-deleted on the database and about to be collected by db-sync
readonly deleted?: boolean;

/**
* Contains information about the image build, if there was any
*/
imageBuildInfo?: ImageBuildInfo;
}

// WorkspaceInstanceStatus describes the current state of a workspace instance
Expand Down Expand Up @@ -213,3 +218,18 @@ export interface WorkspaceInstanceConfiguration {
// supervisorImage is the ref of the supervisor image this instance uses.
supervisorImage?: string;
}

/**
* Holds information about the image build (if there was one) for this WorkspaceInstance
*/
export interface ImageBuildInfo {
log?: ImageBuildLogInfo,
}

/**
* Holds information about how to access logs for this an image build
*/
export interface ImageBuildLogInfo {
url: string,
headers: { [key: string]: string },
}
135 changes: 113 additions & 22 deletions components/image-builder-api/go/imgbuilder.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/image-builder-api/go/imgbuilder_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/image-builder-api/go/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions components/image-builder-api/imgbuilder.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,10 @@ message BuildInfo {
BuildStatus status = 2;
int64 started_at = 3;
string build_id = 5;
LogInfo log_info = 6;
}

message LogInfo {
string url = 1;
map<string, string> headers = 2;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
33 changes: 32 additions & 1 deletion components/image-builder-api/typescript/src/imgbuilder_pb.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down Expand Up @@ -456,6 +456,11 @@ export class BuildInfo extends jspb.Message {
getBuildId(): string;
setBuildId(value: string): BuildInfo;

hasLogInfo(): boolean;
clearLogInfo(): void;
getLogInfo(): LogInfo | undefined;
setLogInfo(value?: LogInfo): BuildInfo;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): BuildInfo.AsObject;
static toObject(includeInstance: boolean, msg: BuildInfo): BuildInfo.AsObject;
Expand All @@ -473,6 +478,32 @@ export namespace BuildInfo {
status: BuildStatus,
startedAt: number,
buildId: string,
logInfo?: LogInfo.AsObject,
}
}

export class LogInfo extends jspb.Message {
getUrl(): string;
setUrl(value: string): LogInfo;

getHeadersMap(): jspb.Map<string, string>;
clearHeadersMap(): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LogInfo.AsObject;
static toObject(includeInstance: boolean, msg: LogInfo): LogInfo.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: LogInfo, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): LogInfo;
static deserializeBinaryFromReader(message: LogInfo, reader: jspb.BinaryReader): LogInfo;
}

export namespace LogInfo {
export type AsObject = {
url: string,

headersMap: Array<[string, string]>,
}
}

Expand Down
Loading

0 comments on commit ecf1113

Please sign in to comment.