Skip to content

Commit 541e880

Browse files
committed
Fixup cloning our special SHA
1 parent d0f46be commit 541e880

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

components/server/src/workspace/context-parser-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export class ContextParser {
132132
try {
133133
// Note: we only care about repo related stuff in this function.
134134
// Fields like `config.image` will not be exposed, so we don't pass organizationId here
135-
let config = await this.configProvider.fetchConfig({ span }, user, context);
136135
let mainRepoContext: WorkspaceContext | undefined;
137136
if (config.config.mainConfiguration) {
138137
mainRepoContext = await this.internalHandleWithoutPrefix(
@@ -194,6 +193,9 @@ export class ContextParser {
194193
if (ExternalImageConfigFile.is(config.config.image)) {
195194
if (config.config.image.externalSource.revision === ImageFileRevisionMissing) {
196195
context.warnings.push("The Dockerfile specified in the .gitpod.yml file was not found.");
196+
197+
// we let the image builder try cloning the context's revision
198+
config.config.image.externalSource.revision = context.revision;
197199
}
198200
}
199201

components/server/src/workspace/workspace-factory.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import {
2121
WithSnapshot,
2222
Workspace,
2323
WorkspaceContext,
24+
WorkspaceImageSourceDocker,
2425
} from "@gitpod/gitpod-protocol";
2526
import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
2627
import { generateWorkspaceID } from "@gitpod/gitpod-protocol/lib/util/generate-workspace-id";
2728
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
2829
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing";
2930
import { inject, injectable } from "inversify";
30-
import { RepoURL } from "../repohost";
31+
import { ImageFileRevisionMissing, RepoURL } from "../repohost";
3132
import { ConfigProvider } from "./config-provider";
3233
import { ImageSourceProvider } from "./image-source-provider";
3334
import { increasePrebuildsStartedCounter } from "../prometheus-metrics";
@@ -328,6 +329,10 @@ export class WorkspaceFactory {
328329
if (config._origin === "derived" && literalConfig) {
329330
(context as any as AdditionalContentContext).additionalFiles = { ...literalConfig };
330331
}
332+
if (WorkspaceImageSourceDocker.is(imageSource) && imageSource.dockerFileHash === ImageFileRevisionMissing) {
333+
// we let the workspace create here and let it fail to build the image
334+
imageSource.dockerFileHash = context.revision;
335+
}
331336

332337
let projectId: string | undefined;
333338
// associate with a project, if the current user is a team member

components/server/src/workspace/workspace-starter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ import { IDESettingsVersion } from "@gitpod/gitpod-protocol/lib/ide-protocol";
140140
import { getFeatureFlagEnableExperimentalJBTB } from "../util/featureflags";
141141
import { OrganizationService } from "../orgs/organization-service";
142142
import { ProjectsService } from "../projects/projects-service";
143+
import { ImageFileRevisionMissing } from "../repohost";
143144

144145
export interface StartWorkspaceOptions extends Omit<GitpodServer.StartWorkspaceOptions, "ideSettings"> {
145146
excludeFeatureFlags?: NamedWorkspaceFeatureFlag[];
@@ -275,6 +276,13 @@ export class WorkspaceStarter {
275276
workspace.context as CommitContext,
276277
workspace.config,
277278
);
279+
if (
280+
WorkspaceImageSourceDocker.is(imageSource) &&
281+
imageSource.dockerFileHash === ImageFileRevisionMissing
282+
) {
283+
// we let the workspace create here and let it fail to build the image
284+
imageSource.dockerFileHash = (workspace.context as CommitContext).revision;
285+
}
278286
log.debug("Found workspace without imageSource, generated one", { imageSource });
279287

280288
workspace.imageSource = imageSource;

0 commit comments

Comments
 (0)