Skip to content

Commit

Permalink
fixup! Fix: include starter projects for $PROJECT_SOURCE path selection
Browse files Browse the repository at this point in the history
  • Loading branch information
AObuchow committed Oct 17, 2023
1 parent f5365ac commit 5d50c82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 58 deletions.
6 changes: 2 additions & 4 deletions pkg/library/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ func GetKubeContainersFromDevfile(workspace *dw.DevWorkspaceTemplateSpec, securi
if err != nil {
return nil, err
}
err = handleMountSources(k8sContainer, component.Container, workspace)
if err != nil {
if err := handleMountSources(k8sContainer, component.Container, workspace); err != nil {
return nil, err
}
if overrides.NeedsContainerOverride(&component) {
Expand All @@ -91,8 +90,7 @@ func GetKubeContainersFromDevfile(workspace *dw.DevWorkspaceTemplateSpec, securi
if err != nil {
return nil, err
}
err = handleMountSources(k8sContainer, initComponent.Container, workspace)
if err != nil {
if err := handleMountSources(k8sContainer, initComponent.Container, workspace); err != nil {
return nil, err
}
if overrides.NeedsContainerOverride(&initComponent) {
Expand Down
31 changes: 13 additions & 18 deletions pkg/library/container/mountSources.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,23 @@ func handleMountSources(k8sContainer *corev1.Container, devfileContainer *dw.Con
//
// 2. If the workspace has a starter project that is selected, its name will be used as the project source path.
//
// 3. If the workspace has at least one starter project, but none are selected,
// the name of the first starter project will be used as the project source path.
//
// 4. Otherwise, the returned project source path will be an empty string.
// 3. Otherwise, the returned project source path will be an empty string.
func getProjectSourcePath(workspace *dw.DevWorkspaceTemplateSpec) (string, error) {
projects := projectslib.GetAllProjects(workspace)
projects := workspace.Projects
// If there are any projects, return the first one's clone path
if len(projects) > 0 {
selectedStarterProject, err := projectslib.GetStarterProject(workspace)
if err != nil {
return "", err
}
// Only use the selected starterProject if we have no regular projects
if selectedStarterProject != nil && len(workspace.Projects) == 0 {
return selectedStarterProject.Name, nil
}
return projectslib.GetClonePath(&projects[0]), nil
}

firstProject := projects[0]
if firstProject.ClonePath != "" {
return firstProject.ClonePath, nil
}
return firstProject.Name, nil
// No projects, check if we have a selected starter project
selectedStarterProject, err := projectslib.GetStarterProject(workspace)
if err != nil {
return "", err
} else if selectedStarterProject != nil {
// Starter projects do not allow specifying a clone path, so use the name
return selectedStarterProject.Name, nil
}

return "", nil
}

Expand Down
36 changes: 0 additions & 36 deletions pkg/library/projects/util.go

This file was deleted.

0 comments on commit 5d50c82

Please sign in to comment.