diff --git a/pkg/devfile/generator/utils.go b/pkg/devfile/generator/utils.go index 8be87b3f..62ef134a 100644 --- a/pkg/devfile/generator/utils.go +++ b/pkg/devfile/generator/utils.go @@ -169,10 +169,11 @@ func addSyncRootFolder(container *corev1.Container, sourceMapping string) string func addSyncFolder(container *corev1.Container, sourceVolumePath string, projects []v1.Project) error { var syncFolder string + // if there are no projects in the devfile, source would be synced to $PROJECTS_ROOT if len(projects) == 0 { - // No projects found, set PROJECT_SOURCE to empty - syncFolder = "" + syncFolder = sourceVolumePath } else { + // if there is one or more projects in the devfile, get the first project and check its clonepath project := projects[0] syncFolder = filepath.ToSlash(filepath.Join(sourceVolumePath, project.Name)) @@ -183,6 +184,7 @@ func addSyncFolder(container *corev1.Container, sourceVolumePath string, project if strings.Contains(project.ClonePath, "..") { return fmt.Errorf("the clonePath %s in the devfile project %s cannot escape the value defined by $PROJECTS_ROOT. Please avoid using \"..\" in clonePath", project.ClonePath, project.Name) } + // If clonepath exist source would be synced to $PROJECTS_ROOT/clonePath syncFolder = filepath.ToSlash(filepath.Join(sourceVolumePath, project.ClonePath)) } }