Skip to content
Open
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
22 changes: 19 additions & 3 deletions launcher/src/code-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import * as fs from './fs-extra.js';
import { env } from 'process';
import { FlattenedDevfile, Project } from './flattened-devfile.js';
import path from 'path';

export interface Workspace {
folders: Folder[];
Expand Down Expand Up @@ -68,7 +69,8 @@ export class CodeWorkspace {
// if there is only one project, try to find the workspace file
if (!path && devfile.projects && devfile.projects.length === 1) {
const project = devfile.projects[0];
const toFind = `${env.PROJECTS_ROOT}/${project.name}/.code-workspace`;
const pathProject = project.clonePath || project.name;
const toFind = `${env.PROJECTS_ROOT}/${pathProject}/.code-workspace`;

try {
if (await this.fileExists(toFind)) {
Expand Down Expand Up @@ -152,12 +154,26 @@ export class CodeWorkspace {

let synchronized = false;

if (!env.PROJECTS_ROOT) {
console.log(' > env.PROJECTS_ROOT is not set, skip project assertion');
return false;
}

const basePath = path.resolve(env.PROJECTS_ROOT);

for (const project of projects) {
if (await fs.pathExists(`${env.PROJECTS_ROOT}/${project.name}`)) {
const pathProject = project.clonePath || project.name;
const fullPath = path.resolve(basePath, pathProject);

if (!fullPath.startsWith(basePath) || !path.isAbsolute(fullPath) || fullPath.startsWith('..')) {
console.log(`> Skipping project ${project.name}: clonePath escapes projects root`);
continue;
}
if (await fs.pathExists(fullPath)) {
if (!workspace.folders.some((folder) => folder.name === project.name)) {
workspace.folders.push({
name: project.name,
path: `${env.PROJECTS_ROOT}/${project.name}`,
path: fullPath,
});

synchronized = true;
Expand Down
1 change: 1 addition & 0 deletions launcher/src/flattened-devfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Devfile {

export interface Project {
name: string;
clonePath?: string;
git: Git;
}

Expand Down
172 changes: 172 additions & 0 deletions launcher/tests/_data/flattened.devworkspace.with-clone-path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
attributes:
controller.devfile.io/devworkspace-config:
name: devworkspace-config
namespace: dogfooding
controller.devfile.io/scc: container-build
controller.devfile.io/storage-type: per-workspace
dw.metadata.annotations:
che.eclipse.org/devfile-source: |
scm:
repo: https://github.com/che-incubator/che-code.git
revision: che-code-launcher-test
fileName: devfile.yaml
factory:
params: url=https://github.com/che-incubator/che-code/tree/che-code-launcher-test
commands:
- apply:
component: che-code-injector
attributes:
controller.devfile.io/imported-by: editor
id: init-container-command
- attributes:
controller.devfile.io/imported-by: editor
exec:
commandLine: nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt
2>&1 &
component: dev
id: init-che-code-command
- exec:
commandLine: |
yarn prepare
component: dev
group:
kind: build
workingDir: ${PROJECTS_ROOT}/che-code
id: prepare
- exec:
commandLine: |
yarn watch
component: dev
group:
isDefault: true
kind: build
workingDir: ${PROJECTS_ROOT}/che-code
id: build
- exec:
commandLine: |
yarn server
component: dev
group:
isDefault: true
kind: run
workingDir: ${PROJECTS_ROOT}/che-code
id: run
components:
- attributes:
controller.devfile.io/imported-by: editor
name: checode
volume: {}
- attributes:
controller.devfile.io/imported-by: editor
container:
command:
- /entrypoint-init-container.sh
cpuLimit: 500m
cpuRequest: 30m
env:
- name: CHE_DASHBOARD_URL
value: https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com
- name: CHE_PLUGIN_REGISTRY_URL
value: https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com/plugin-registry/v3
- name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
value: http://plugin-registry.dogfooding.svc:8080/v3
- name: CLUSTER_CONSOLE_URL
value: https://console-openshift-console.apps.che-dev.x6e0.p1.openshiftapps.com
- name: CLUSTER_CONSOLE_TITLE
value: OpenShift console
- name: OPENVSX_REGISTRY_URL
value: https://open-vsx.org
image: quay.io/vgulyy/che-code:test-che-code-launcher-2
memoryLimit: 256Mi
memoryRequest: 32Mi
sourceMapping: /projects
volumeMounts:
- name: checode
path: /checode
name: che-code-injector
- attributes:
app.kubernetes.io/component: che-code-runtime
app.kubernetes.io/part-of: che-code.eclipse.org
controller.devfile.io/merged-contributions: editor
container:
cpuLimit: "4"
endpoints:
- attributes:
controller.devfile.io/endpoint-url: https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com/vgulyy/che-code-multiroot/3100/
cookiesAuthEnabled: true
discoverable: false
type: main
urlRewriteSupported: true
exposure: public
name: che-code
protocol: https
secure: false
targetPort: 3100
- attributes:
controller.devfile.io/endpoint-url: http://vgulyy-che-code-multiroot-code-redirect-1.apps.che-dev.x6e0.p1.openshiftapps.com/
discoverable: false
urlRewriteSupported: false
exposure: public
name: code-redirect-1
protocol: http
targetPort: 13131
- attributes:
controller.devfile.io/endpoint-url: http://vgulyy-che-code-multiroot-code-redirect-2.apps.che-dev.x6e0.p1.openshiftapps.com/
discoverable: false
urlRewriteSupported: false
exposure: public
name: code-redirect-2
protocol: http
targetPort: 13132
- attributes:
controller.devfile.io/endpoint-url: http://vgulyy-che-code-multiroot-code-redirect-3.apps.che-dev.x6e0.p1.openshiftapps.com/
discoverable: false
urlRewriteSupported: false
exposure: public
name: code-redirect-3
protocol: http
targetPort: 13133
- attributes:
controller.devfile.io/endpoint-url: https://vgulyy-che-code-multiroot-dev.apps.che-dev.x6e0.p1.openshiftapps.com/
exposure: public
name: dev
protocol: http
secure: true
targetPort: 8000
env:
- name: WEBVIEW_LOCAL_RESOURCES
value: "true"
- name: CHE_DASHBOARD_URL
value: https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com
- name: CHE_PLUGIN_REGISTRY_URL
value: https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com/plugin-registry/v3
- name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
value: http://plugin-registry.dogfooding.svc:8080/v3
- name: CLUSTER_CONSOLE_URL
value: https://console-openshift-console.apps.che-dev.x6e0.p1.openshiftapps.com
- name: CLUSTER_CONSOLE_TITLE
value: OpenShift console
- name: OPENVSX_REGISTRY_URL
value: https://open-vsx.org
image: quay.io/che-incubator/che-code-dev:insiders
memoryLimit: 13Gi
memoryRequest: 320Mi
sourceMapping: /projects
volumeMounts:
- name: checode
path: /checode
name: dev
- name: projects
volume:
size: 3Gi
events:
postStart:
- init-che-code-command
preStart:
- init-container-command
projects:
- clonePath: custom/clone/path/web-nodejs-sample
git:
remotes:
url: https://github.com/che-samples/web-nodejs-sample
name: web-nodejs-sample
Loading