Skip to content

Commit

Permalink
Add dependentProjects to the Devfile/DevWorkspace spec
Browse files Browse the repository at this point in the history
Add field 'dependentProjects' to the devfile API. Dependent projects
are additional projects that are related to the 'main' project in a
Devfile, allowing a devfile to specify e.g. dependencies or related
projects that are useful in development.

Signed-off-by: Angel Misevski <[email protected]>
  • Loading branch information
amisevsk committed Oct 19, 2023
1 parent e05a235 commit 53ae1ec
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/apis/workspaces/v1alpha2/devworkspacetemplate_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ type DevWorkspaceTemplateSpecContent struct {
// +devfile:toplevellist
StarterProjects []StarterProject `json:"starterProjects,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// Additional projects related to the main project in the devfile, contianing names and sources locations
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
// +devfile:overrides:include:omitInPlugin=true,description=Overrides of dependentProjects encapsulated in a parent devfile.
// +devfile:toplevellist
DependentProjects []Project `json:"dependentProjects,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// Predefined, ready-to-use, devworkspace-related commands
// +optional
// +patchMergeKey=id
Expand Down
12 changes: 12 additions & 0 deletions pkg/validation/variables/test-fixtures/all/devfile-bad-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ starterProjects:
- name: starterproject2
zip:
location: "{{tag}}"
dependentProjects:
- name: dependentproject1
clonePath: "{{path}}"
git:
checkoutFrom:
revision: "{{tag}}"
remotes:
"{{dir}}": "{{version1}}/dev/null-/dev/null"
"{{version}}": "test"
- name: dependentproject2
zip:
location: "{{tag}}"
components:
- name: component1
container:
Expand Down
12 changes: 12 additions & 0 deletions pkg/validation/variables/test-fixtures/all/devfile-bad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ starterProjects:
- name: starterproject2
zip:
location: "{{tag}}"
dependentProjects:
- name: dependentproject1
clonePath: "{{path}}"
git:
checkoutFrom:
revision: "{{tag}}"
remotes:
"{{dir}}": "{{version1}}{{devnull}}-{{devnull}}"
"{{version}}": "test"
- name: dependentproject2
zip:
location: "{{tag}}"
components:
- name: component1
container:
Expand Down
6 changes: 6 additions & 0 deletions pkg/validation/variables/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type VariableWarning struct {

// StarterProjects stores a map of starter project names to the invalid variable references
StarterProjects map[string][]string

// DependentProjects stores a map of dependent project names to invalid variable references
DependentProjects map[string][]string
}

// ValidateAndReplaceGlobalVariable validates the workspace template spec data for global variable references and replaces them with the variable value
Expand All @@ -58,6 +61,9 @@ func ValidateAndReplaceGlobalVariable(workspaceTemplateSpec *v1alpha2.DevWorkspa

// Validate the starter projects and replace for global variable
variableWarning.StarterProjects = ValidateAndReplaceForStarterProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.StarterProjects)

// Validate the starter projects and replace for global variable
variableWarning.DependentProjects = ValidateAndReplaceForProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.DependentProjects)
}

return variableWarning
Expand Down
4 changes: 4 additions & 0 deletions pkg/validation/variables/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func TestValidateGlobalVariableBasic(t *testing.T) {
"starterproject1": {"desc", "dir", "tag"},
"starterproject2": {"tag"},
},
DependentProjects: map[string][]string{
"project1": {"dir", "path", "tag", "version", "version1"},
"project2": {"tag"},
},
},
},
}
Expand Down

0 comments on commit 53ae1ec

Please sign in to comment.