Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize workspaces with additional file content #4428

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
557 changes: 417 additions & 140 deletions components/content-service-api/go/initializer.pb.go

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions components/content-service-api/initializer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,35 @@ message WorkspaceInitializer {
GitInitializer git = 2;
SnapshotInitializer snapshot = 3;
PrebuildInitializer prebuild = 4;
CompositeInitializer composite = 5;
FileDownloadInitializer download = 6;
}
}

// CompositeInitializer uses a collection of initializer to produce workspace content.
// All initializer are executed in the order they're provided.
message CompositeInitializer {
repeated WorkspaceInitializer initializer = 1;
}

// FileDownloadInitializer downloads files and uses them as workspace content.
message FileDownloadInitializer {
message FileInfo {
string url = 1;
// file_path is relative to the target_location, e.g. if target_location is in `/workspace/myrepo`
// a file_path of `foobar/file` would produce a file in `/workspace/myrepo/foobar/file`.
// file_path must include the filename. The FileDownloadInitializer will create any parent directories
// necessary to place the file.
string file_path = 2;
// digest is a hash of the file content in the OCI digest format (see https://github.com/opencontainers/image-spec/blob/master/descriptor.md#digests).
// This information is used to compute subsequent
// content versions, and to validate the file content was downloaded correctly.
string digest = 3;
}
repeated FileInfo files = 1;
string target_location = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beware that all initializer are executed relative to a target location themselves, i.e. all paths in an initializer are always relative to that location.

The comment in line 30 implies that target_location can be absolute, when in reality it cannot.

}

message EmptyInitializer { }

message GitInitializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ export class WorkspaceInitializer extends jspb.Message {
getPrebuild(): PrebuildInitializer | undefined;
setPrebuild(value?: PrebuildInitializer): WorkspaceInitializer;

hasComposite(): boolean;
clearComposite(): void;
getComposite(): CompositeInitializer | undefined;
setComposite(value?: CompositeInitializer): WorkspaceInitializer;

hasDownload(): boolean;
clearDownload(): void;
getDownload(): FileDownloadInitializer | undefined;
setDownload(value?: FileDownloadInitializer): WorkspaceInitializer;

getSpecCase(): WorkspaceInitializer.SpecCase;

serializeBinary(): Uint8Array;
Expand All @@ -52,6 +62,8 @@ export namespace WorkspaceInitializer {
git?: GitInitializer.AsObject,
snapshot?: SnapshotInitializer.AsObject,
prebuild?: PrebuildInitializer.AsObject,
composite?: CompositeInitializer.AsObject,
download?: FileDownloadInitializer.AsObject,
}

export enum SpecCase {
Expand All @@ -60,6 +72,83 @@ export namespace WorkspaceInitializer {
GIT = 2,
SNAPSHOT = 3,
PREBUILD = 4,
COMPOSITE = 5,
DOWNLOAD = 6,
}

}

export class CompositeInitializer extends jspb.Message {
clearInitializerList(): void;
getInitializerList(): Array<WorkspaceInitializer>;
setInitializerList(value: Array<WorkspaceInitializer>): CompositeInitializer;
addInitializer(value?: WorkspaceInitializer, index?: number): WorkspaceInitializer;

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

export namespace CompositeInitializer {
export type AsObject = {
initializerList: Array<WorkspaceInitializer.AsObject>,
}
}

export class FileDownloadInitializer extends jspb.Message {
clearFilesList(): void;
getFilesList(): Array<FileDownloadInitializer.FileInfo>;
setFilesList(value: Array<FileDownloadInitializer.FileInfo>): FileDownloadInitializer;
addFiles(value?: FileDownloadInitializer.FileInfo, index?: number): FileDownloadInitializer.FileInfo;
getTargetLocation(): string;
setTargetLocation(value: string): FileDownloadInitializer;

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

export namespace FileDownloadInitializer {
export type AsObject = {
filesList: Array<FileDownloadInitializer.FileInfo.AsObject>,
targetLocation: string,
}


export class FileInfo extends jspb.Message {
getUrl(): string;
setUrl(value: string): FileInfo;
getFilePath(): string;
setFilePath(value: string): FileInfo;
getDigest(): string;
setDigest(value: string): FileInfo;

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

export namespace FileInfo {
export type AsObject = {
url: string,
filePath: string,
digest: string,
}
}

}
Expand Down
Loading