diff --git a/components/dashboard/src/App.tsx b/components/dashboard/src/App.tsx index 97cd81c4cddc81..4c9b88b55765d7 100644 --- a/components/dashboard/src/App.tsx +++ b/components/dashboard/src/App.tsx @@ -74,7 +74,6 @@ const TeamSettings = React.lazy(() => import(/* webpackPrefetch: true */ "./team const TeamBilling = React.lazy(() => import(/* webpackPrefetch: true */ "./teams/TeamBilling")); const TeamUsage = React.lazy(() => import(/* webpackPrefetch: true */ "./teams/TeamUsage")); const NewProject = React.lazy(() => import(/* webpackPrefetch: true */ "./projects/NewProject")); -const ConfigureProject = React.lazy(() => import(/* webpackPrefetch: true */ "./projects/ConfigureProject")); const Projects = React.lazy(() => import(/* webpackPrefetch: true */ "./projects/Projects")); const Project = React.lazy(() => import(/* webpackPrefetch: true */ "./projects/Project")); const Events = React.lazy(() => import(/* webpackPrefetch: true */ "./projects/Events")); @@ -435,9 +434,6 @@ function App() { if (resourceOrPrebuild === "settings") { return ; } - if (resourceOrPrebuild === "configure") { - return ; - } if (resourceOrPrebuild === "variables") { return ; } @@ -487,9 +483,6 @@ function App() { if (resourceOrPrebuild === "settings") { return ; } - if (resourceOrPrebuild === "configure") { - return ; - } if (resourceOrPrebuild === "variables") { return ; } diff --git a/components/dashboard/src/Menu.tsx b/components/dashboard/src/Menu.tsx index ba1f3928cfc0ff..cc941ffc84b546 100644 --- a/components/dashboard/src/Menu.tsx +++ b/components/dashboard/src/Menu.tsx @@ -75,7 +75,6 @@ export default function Menu() { // project sub-pages "prebuilds", "settings", - "configure", "variables", ].includes(resource) ) { diff --git a/components/dashboard/src/projects/ConfigureProject.tsx b/components/dashboard/src/projects/ConfigureProject.tsx deleted file mode 100644 index 174e5112e9ef14..00000000000000 --- a/components/dashboard/src/projects/ConfigureProject.tsx +++ /dev/null @@ -1,308 +0,0 @@ -/** - * Copyright (c) 2021 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 React, { Suspense, useContext, useEffect, useState } from "react"; -import { Project } from "@gitpod/gitpod-protocol"; -import TabMenuItem from "../components/TabMenuItem"; -import { getGitpodService } from "../service/service"; -import Spinner from "../icons/Spinner.svg"; -import NoAccess from "../icons/NoAccess.svg"; -import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; -import { openAuthorizeWindow } from "../provider-utils"; -import { ProjectSettingsPage } from "./ProjectSettings"; -import { ProjectContext } from "./project-context"; - -const MonacoEditor = React.lazy(() => import("../components/MonacoEditor")); - -const TASKS = { - Other: `tasks: - - init: | - echo 'TODO: build project' - command: | - echo 'TODO: start app'`, -}; - -export default function () { - const { project } = useContext(ProjectContext); - const [gitpodYml, setGitpodYml] = useState(""); - const [dockerfile, setDockerfile] = useState(""); - const [editorMessage, setEditorMessage] = useState(null); - const [selectedEditor, setSelectedEditor] = useState<".gitpod.yml" | ".gitpod.Dockerfile">(".gitpod.yml"); - const [isEditorDisabled, setIsEditorDisabled] = useState(true); - const [isDetecting, setIsDetecting] = useState(true); - const [progressMessage, setProgressMessage] = useState(""); - const [showAuthBanner, setShowAuthBanner] = useState<{ host: string; scope?: string } | undefined>(undefined); - const [buttonNewWorkspaceEnabled, setButtonNewWorkspaceEnabled] = useState(true); - - useEffect(() => { - // Disable editing while loading, or when the config comes from Git. - setIsDetecting(true); - setIsEditorDisabled(true); - setEditorMessage(null); - (async () => { - if (!project) { - setIsDetecting(false); - setEditorMessage( - , - ); - return; - } - try { - await detectProjectConfiguration(project); - } catch (error) { - if (error && error.message && error.message.includes("NotFound")) { - const host = new URL(project.cloneUrl).hostname; - const scope: string | undefined = host === "github.com" ? "repo" : undefined; - setShowAuthBanner({ host: new URL(project.cloneUrl).hostname, scope }); - } else if (error && error.code === ErrorCodes.NOT_AUTHENTICATED) { - setShowAuthBanner({ host: new URL(project.cloneUrl).hostname }); - } else { - console.error("Getting project configuration failed", error); - setIsDetecting(false); - setIsEditorDisabled(true); - setEditorMessage( - , - ); - setGitpodYml(TASKS.Other); - } - } - })(); - }, [project]); - - const detectProjectConfiguration = async (project: Project) => { - const guessedConfigStringPromise = getGitpodService().server.guessProjectConfiguration(project.id); - const repoConfigString = await getGitpodService().server.fetchProjectRepositoryConfiguration(project.id); - if (repoConfigString) { - setIsDetecting(false); - setEditorMessage( - , - ); - setGitpodYml(repoConfigString); - return; - } - if (project.config && project.config[".gitpod.yml"]) { - setIsDetecting(false); - setIsEditorDisabled(false); - setGitpodYml(project.config[".gitpod.yml"]); - return; - } - const guessedConfigString = await guessedConfigStringPromise; - setIsDetecting(false); - setIsEditorDisabled(false); - if (guessedConfigString) { - setEditorMessage( - , - ); - setGitpodYml(guessedConfigString); - return; - } - setEditorMessage( - , - ); - setGitpodYml(TASKS.Other); - }; - - const tryAuthorize = async (params: { host: string; scope?: string; onSuccess: () => void }) => { - try { - await openAuthorizeWindow({ - host: params.host, - onSuccess: params.onSuccess, - scopes: params.scope ? [params.scope] : undefined, - onError: (error) => { - console.log(error); - }, - }); - } catch (error) { - console.log(error); - } - }; - - const onConfirmShowAuthModal = async (host: string, scope?: string) => { - setShowAuthBanner(undefined); - await tryAuthorize({ - host, - scope, - onSuccess: async () => { - // update remote session - await getGitpodService().reconnect(); - - // retry fetching branches - if (project) { - detectProjectConfiguration(project); - } - }, - }); - }; - - useEffect(() => { - document.title = "Configure Project — Gitpod"; - }, []); - - const onNewWorkspace = async () => { - if (!project) { - return; - } - - setButtonNewWorkspaceEnabled(false); - - if (!isEditorDisabled) { - try { - setProgressMessage("Saving project configuration..."); - await getGitpodService().server.setProjectConfiguration(project.id, gitpodYml); - - setProgressMessage("Starting a new prebuild..."); - await getGitpodService().server.triggerPrebuild(project.id, null); - } catch (error) { - setEditorMessage( - , - ); - - setProgressMessage(""); - setButtonNewWorkspaceEnabled(true); - return; - } - } - - const redirectToNewWorkspace = () => { - // instead of `history.push` we want forcibly to redirect here in order to avoid a following redirect from `/` -> `/projects` (cf. App.tsx) - const url = new URL(window.location.toString()); - url.pathname = "/"; - url.hash = project?.cloneUrl!; - window.location.href = url.toString(); - }; - - redirectToNewWorkspace(); - return; - }; - - return ( - -
-
-
- setSelectedEditor(".gitpod.yml")} - /> - {!!dockerfile && ( - setSelectedEditor(".gitpod.Dockerfile")} - /> - )} -
- {editorMessage} - }> - {selectedEditor === ".gitpod.yml" && ( - - )} - {selectedEditor === ".gitpod.Dockerfile" && ( - - )} - - {isDetecting && ( -
- {showAuthBanner ? ( -
-
- -
- No Access -
-
- Authorize {showAuthBanner.host}{" "} - {showAuthBanner.scope ? ( - <> - and grant {showAuthBanner.scope} permission - - ) : ( - "" - )}{" "} -
to access project configuration. -
- -
-
- ) : ( - <> - - - Detecting project configuration ... - - - )} -
- )} -
-
- -
-
-
- ); -} - -function EditorMessage(props: { heading: string; message: string; type: "success" | "warning" }) { - return ( -
- - {props.heading} - - {props.message} -
- ); -} diff --git a/components/dashboard/src/projects/NewProject.tsx b/components/dashboard/src/projects/NewProject.tsx index 371e94d5c73692..e64c587422d398 100644 --- a/components/dashboard/src/projects/NewProject.tsx +++ b/components/dashboard/src/projects/NewProject.tsx @@ -39,8 +39,6 @@ export default function NewProject() { const [loaded, setLoaded] = useState(false); const [project, setProject] = useState(); - const [guessedConfigString, setGuessedConfigString] = useState(); - const [sourceOfConfig, setSourceOfConfig] = useState<"repo" | "db" | undefined>(); const [authProviders, setAuthProviders] = useState([]); const [isGitHubAppEnabled, setIsGitHubAppEnabled] = useState(); @@ -122,37 +120,6 @@ export default function NewProject() { })(); }, [teams]); - useEffect(() => { - if (selectedRepo) { - (async () => { - try { - const guessedConfigStringPromise = getGitpodService().server.guessRepositoryConfiguration( - selectedRepo.cloneUrl, - ); - const repoConfigString = await getGitpodService().server.fetchRepositoryConfiguration( - selectedRepo.cloneUrl, - ); - if (repoConfigString) { - setSourceOfConfig("repo"); - } else { - setGuessedConfigString( - (await guessedConfigStringPromise) || - `tasks: - - init: | - echo 'TODO: build project' - command: | - echo 'TODO: start app'`, - ); - setSourceOfConfig("db"); - } - } catch (error) { - console.error("Getting project configuration failed", error); - setSourceOfConfig(undefined); - } - })(); - } - }, [selectedRepo]); - useEffect(() => { if (selectedTeamOrUser && selectedRepo) { createProject(selectedTeamOrUser, selectedRepo); @@ -189,15 +156,10 @@ export default function NewProject() { }, [selectedProviderHost]); useEffect(() => { - if (project && sourceOfConfig) { - (async () => { - if (guessedConfigString && sourceOfConfig === "db") { - await getGitpodService().server.setProjectConfiguration(project.id, guessedConfigString); - } - await getGitpodService().server.triggerPrebuild(project.id, null); - })(); + if (project) { + getGitpodService().server.triggerPrebuild(project.id, null); } - }, [project, sourceOfConfig]); + }, [project]); const isGitHub = () => selectedProviderHost === "github.com"; diff --git a/components/dashboard/src/projects/ProjectSettings.tsx b/components/dashboard/src/projects/ProjectSettings.tsx index 955b634cedda2b..35cdcad6e70c54 100644 --- a/components/dashboard/src/projects/ProjectSettings.tsx +++ b/components/dashboard/src/projects/ProjectSettings.tsx @@ -22,10 +22,6 @@ export function getProjectSettingsMenu(project?: Project, team?: Team) { title: "General", link: [`/${teamOrUserSlug}/${project?.slug || project?.name}/settings`], }, - { - title: "Configuration", - link: [`/${teamOrUserSlug}/${project?.slug || project?.name}/configure`], - }, { title: "Variables", link: [`/${teamOrUserSlug}/${project?.slug || project?.name}/variables`], diff --git a/components/gitpod-db/src/typeorm/entity/db-project.ts b/components/gitpod-db/src/typeorm/entity/db-project.ts index dfa71878b58ae0..d72a1b61beddc8 100644 --- a/components/gitpod-db/src/typeorm/entity/db-project.ts +++ b/components/gitpod-db/src/typeorm/entity/db-project.ts @@ -6,7 +6,7 @@ import { Entity, Column, PrimaryColumn, Index } from "typeorm"; import { TypeORM } from "../typeorm"; -import { ProjectConfig, ProjectSettings } from "@gitpod/gitpod-protocol"; +import { ProjectSettings } from "@gitpod/gitpod-protocol"; import { Transformer } from "../transformer"; @Entity() @@ -42,9 +42,6 @@ export class DBProject { @Column() appInstallationId: string; - @Column("simple-json", { nullable: true }) - config?: ProjectConfig; - @Column("simple-json", { nullable: true }) settings?: ProjectSettings; diff --git a/components/gitpod-db/src/typeorm/migration/1662983610386-DropProjectConfig.ts b/components/gitpod-db/src/typeorm/migration/1662983610386-DropProjectConfig.ts new file mode 100644 index 00000000000000..12f17ede64704d --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1662983610386-DropProjectConfig.ts @@ -0,0 +1,25 @@ +/** + * 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"; + +const D_B_PROJECT = "d_b_project"; +const COL_CONFIG = "config"; + +export class DropProjectConfig1662983610386 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + if (await columnExists(queryRunner, D_B_PROJECT, COL_CONFIG)) { + await queryRunner.query(`ALTER TABLE ${D_B_PROJECT} DROP COLUMN ${COL_CONFIG}`); + } + } + + public async down(queryRunner: QueryRunner): Promise { + if (!(await columnExists(queryRunner, D_B_PROJECT, COL_CONFIG))) { + await queryRunner.query(`ALTER TABLE ${D_B_PROJECT} ADD COLUMN ${COL_CONFIG} text`); + } + } +} diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index b1dfbae2b916bd..f9bce61df96896 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -191,11 +191,6 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, getPrebuild(prebuildId: string): Promise; triggerPrebuild(projectId: string, branchName: string | null): Promise; cancelPrebuild(projectId: string, prebuildId: string): Promise; - fetchProjectRepositoryConfiguration(projectId: string): Promise; - guessProjectConfiguration(projectId: string): Promise; - fetchRepositoryConfiguration(cloneUrl: string): Promise; - guessRepositoryConfiguration(cloneUrl: string): Promise; - setProjectConfiguration(projectId: string, configString: string): Promise; updateProjectPartial(partialProject: PartialProject): Promise; setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise; getProjectEnvironmentVariables(projectId: string): Promise; diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 71b279d38975ec..2b44b949a4f8b9 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -823,13 +823,12 @@ export interface WorkspaceConfig { * Where the config object originates from. * * repo - from the repository - * project-db - from the "Project" stored in the database * definitly-gp - from github.com/gitpod-io/definitely-gp * derived - computed based on analyzing the repository * additional-content - config comes from additional content, usually provided through the project's configuration * default - our static catch-all default config */ - _origin?: "repo" | "project-db" | "definitely-gp" | "derived" | "additional-content" | "default"; + _origin?: "repo" | "definitely-gp" | "derived" | "additional-content" | "default"; /** * Set of automatically infered feature flags. That's not something the user can set, but diff --git a/components/gitpod-protocol/src/teams-projects-protocol.ts b/components/gitpod-protocol/src/teams-projects-protocol.ts index 1905684d799c92..a3b4a6db3b877f 100644 --- a/components/gitpod-protocol/src/teams-projects-protocol.ts +++ b/components/gitpod-protocol/src/teams-projects-protocol.ts @@ -27,7 +27,6 @@ export interface Project { teamId?: string; userId?: string; appInstallationId: string; - config?: ProjectConfig; settings?: ProjectSettings; creationTime: string; /** This is a flag that triggers the HARD DELETION of this entity */ diff --git a/components/server/src/auth/rate-limiter.ts b/components/server/src/auth/rate-limiter.ts index 554c9901fd5f2e..14e5e0d3cf9c54 100644 --- a/components/server/src/auth/rate-limiter.ts +++ b/components/server/src/auth/rate-limiter.ts @@ -116,11 +116,6 @@ const defaultFunctions: FunctionsConfig = { getProjectOverview: { group: "default", points: 1 }, triggerPrebuild: { group: "default", points: 1 }, cancelPrebuild: { group: "default", points: 1 }, - fetchProjectRepositoryConfiguration: { group: "default", points: 1 }, - guessProjectConfiguration: { group: "default", points: 1 }, - fetchRepositoryConfiguration: { group: "default", points: 1 }, - guessRepositoryConfiguration: { group: "default", points: 1 }, - setProjectConfiguration: { group: "default", points: 1 }, updateProjectPartial: { group: "default", points: 1 }, getContentBlobUploadUrl: { group: "default", points: 1 }, getContentBlobDownloadUrl: { group: "default", points: 1 }, diff --git a/components/server/src/workspace/config-provider.ts b/components/server/src/workspace/config-provider.ts index 65430fea88d6ed..487f10c9ab2ce6 100644 --- a/components/server/src/workspace/config-provider.ts +++ b/components/server/src/workspace/config-provider.ts @@ -23,7 +23,6 @@ import { WithDefaultConfig, ProjectConfig, } from "@gitpod/gitpod-protocol"; -import { ProjectDB } from "@gitpod/gitpod-db/lib"; import { GitpodFileParser } from "@gitpod/gitpod-protocol/lib/gitpod-file-parser"; import { MaybeContent } from "../repohost/file-provider"; @@ -47,7 +46,6 @@ export class ConfigProvider { @inject(GitpodFileParser) protected readonly gitpodParser: GitpodFileParser; @inject(HostContextProvider) protected readonly hostContextProvider: HostContextProvider; @inject(AuthorizationService) protected readonly authService: AuthorizationService; - @inject(ProjectDB) protected readonly projectDB: ProjectDB; @inject(Config) protected readonly config: Config; @inject(ConfigurationService) protected readonly configurationService: ConfigurationService; @@ -184,20 +182,9 @@ export class ConfigProvider { const contextRepoConfig = services.fileProvider.getGitpodFileContent(commit, user); customConfigString = await contextRepoConfig; let origin: WorkspaceConfig["_origin"] = "repo"; - if (!customConfigString) { - const projectDBConfig = this.projectDB - .findProjectByCloneUrl(commit.repository.cloneUrl) - .then((project) => project?.config); - // We haven't found a Gitpod configuration file in the context repo - check the "Project" in the DB. - const config = await projectDBConfig; - if (config) { - customConfigString = config[".gitpod.yml"]; - origin = "project-db"; - } - } if (!customConfigString) { - /* We haven't found a Gitpod configuration file in the context repo or "Project" - check definitely-gp. + /* We haven't found a Gitpod configuration file in the context repo - check definitely-gp. * * In case we had found a config file here, we'd still be checking the definitely GP repo, just to save some time. * While all those checks will be in vain, they should not leak memory either as they'll simply diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index a905a7266ae4f6..a215f8b4ab6ff5 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -2416,95 +2416,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { ); } - public async fetchRepositoryConfiguration(ctx: TraceContext, cloneUrl: string): Promise { - traceAPIParams(ctx, { cloneUrl }); - const user = this.checkUser("fetchRepositoryConfiguration"); - try { - const context = (await this.contextParser.handle(ctx, user, cloneUrl)) as CommitContext; - return await this.configurationService.fetchRepositoryConfiguration(ctx, user, context); - } catch (error) { - if (UnauthorizedError.is(error)) { - throw new ResponseError(ErrorCodes.NOT_AUTHENTICATED, "Unauthorized", error.data); - } - throw error; - } - } - - public async fetchProjectRepositoryConfiguration( - ctx: TraceContext, - projectId: string, - ): Promise { - traceAPIParams(ctx, { projectId }); - const user = this.checkUser("fetchProjectRepositoryConfiguration"); - - await this.guardProjectOperation(user, projectId, "get"); - - const project = await this.projectsService.getProject(projectId); - if (!project) { - throw new Error("Project not found"); - } - - try { - const context = (await this.contextParser.handle(ctx, user, project.cloneUrl)) as CommitContext; - return await this.configurationService.fetchRepositoryConfiguration(ctx, user, context); - } catch (error) { - if (UnauthorizedError.is(error)) { - throw new ResponseError(ErrorCodes.NOT_AUTHENTICATED, "Unauthorized", error.data); - } - throw error; - } - } - - public async guessRepositoryConfiguration(ctx: TraceContext, cloneUrl: string): Promise { - const user = this.checkUser("guessRepositoryConfiguration"); - try { - const context = (await this.contextParser.handle(ctx, user, cloneUrl)) as CommitContext; - return await this.configurationService.guessRepositoryConfiguration(ctx, user, context); - } catch (error) { - if (UnauthorizedError.is(error)) { - throw new ResponseError(ErrorCodes.NOT_AUTHENTICATED, "Unauthorized", error.data); - } - throw error; - } - } - - public async guessProjectConfiguration(ctx: TraceContext, projectId: string): Promise { - traceAPIParams(ctx, { projectId }); - const user = this.checkUser("guessProjectConfiguration"); - await this.guardProjectOperation(user, projectId, "get"); - - const project = await this.projectsService.getProject(projectId); - if (!project) { - throw new Error("Project not found"); - } - - try { - const context = (await this.contextParser.handle(ctx, user, project.cloneUrl)) as CommitContext; - return await this.configurationService.guessRepositoryConfiguration(ctx, user, context); - } catch (error) { - if (UnauthorizedError.is(error)) { - throw new ResponseError(ErrorCodes.NOT_AUTHENTICATED, "Unauthorized", error.data); - } - throw error; - } - } - - public async setProjectConfiguration(ctx: TraceContext, projectId: string, configString: string): Promise { - traceAPIParams(ctx, { projectId }); // filter configString because of size - - const user = this.checkAndBlockUser("setProjectConfiguration"); - await this.guardProjectOperation(user, projectId, "update"); - - const parseResult = this.gitpodParser.parse(configString); - if (parseResult.validationErrors) { - throw new Error(`This configuration could not be parsed: ${parseResult.validationErrors.join(", ")}`); - } - await this.projectsService.updateProjectPartial({ - id: projectId, - config: { ".gitpod.yml": configString }, - }); - } - public async updateProjectPartial(ctx: TraceContext, partialProject: PartialProject): Promise { traceAPIParams(ctx, { // censor everything irrelevant @@ -2518,7 +2429,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { await this.guardProjectOperation(user, partialProject.id, "update"); const partial: PartialProject = { id: partialProject.id }; - const allowedFields: (keyof Project)[] = ["settings"]; // Don't add 'config' here! Please use `setProjectConfiguration` instead to parse & validate configs + const allowedFields: (keyof Project)[] = ["settings"]; for (const f of allowedFields) { if (f in partialProject) { (partial[f] as any) = partialProject[f]; diff --git a/components/server/src/workspace/workspace-factory.ts b/components/server/src/workspace/workspace-factory.ts index 7777d5f54daddc..5e06d205bd1667 100644 --- a/components/server/src/workspace/workspace-factory.ts +++ b/components/server/src/workspace/workspace-factory.ts @@ -174,21 +174,11 @@ export class WorkspaceFactory { const span = TraceContext.startSpan("createForCommit", ctx); try { - // TODO(janx): We potentially fetch the same Project twice in this flow (once here, and once in `configProvider`, - // to parse a potential custom config from the Project DB). It would be cool to fetch the Project only once (and - // e.g. pass it to `configProvider.fetchConfig` here). const [{ config, literalConfig }, project] = await Promise.all([ this.configProvider.fetchConfig({ span }, user, context), this.projectDB.findProjectByCloneUrl(context.repository.cloneUrl), ]); const imageSource = await this.imageSourceProvider.getImageSource(ctx, user, context, config); - if (config._origin === "project-db") { - // If the project is configured via the Project DB, place the uncommitted configuration into the workspace, - // thus encouraging Git-based configurations. - if (project?.config) { - (context as any as AdditionalContentContext).additionalFiles = { ...project.config }; - } - } if (config._origin === "derived" && literalConfig) { (context as any as AdditionalContentContext).additionalFiles = { ...literalConfig }; } diff --git a/components/usage/pkg/db/project_test.go b/components/usage/pkg/db/project_test.go index 255fe9b73e5092..18d46151087b38 100644 --- a/components/usage/pkg/db/project_test.go +++ b/components/usage/pkg/db/project_test.go @@ -6,13 +6,14 @@ package db_test import ( "fmt" + "strings" + "testing" + "github.com/gitpod-io/gitpod/usage/pkg/db" "github.com/gitpod-io/gitpod/usage/pkg/db/dbtest" "github.com/google/uuid" "github.com/stretchr/testify/require" "gorm.io/gorm" - "strings" - "testing" ) var projectJSON = map[string]interface{}{ @@ -24,7 +25,6 @@ var projectJSON = map[string]interface{}{ "deleted": 0, "_lastModified": "2021-11-02 10:49:12.473658", "name": "gptest1-repo1-private", - "config": "{\".gitpod.yml\":\"tasks:\\n - init: |\\n echo 'TODO: build project'\\n command: |\\n echo 'TODO: start app'\"}", "markedDeleted": 1, "userId": nil, "slug": "gptest1-repo1-private", @@ -48,7 +48,7 @@ func TestProject_ReadExistingRecords(t *testing.T) { func insertRawProject(t *testing.T, conn *gorm.DB, obj map[string]interface{}) uuid.UUID { columns := []string{ - "id", "cloneUrl", "teamId", "appInstallationId", "creationTime", "deleted", "_lastModified", "name", "config", "markedDeleted", "userId", "slug", "settings", + "id", "cloneUrl", "teamId", "appInstallationId", "creationTime", "deleted", "_lastModified", "name", "markedDeleted", "userId", "slug", "settings", } statement := fmt.Sprintf(`INSERT INTO d_b_project (%s) VALUES ?;`, strings.Join(columns, ", ")) id := uuid.MustParse(obj["id"].(string))