Skip to content

Commit 53ae1ec

Browse files
committed
Add dependentProjects to the Devfile/DevWorkspace spec
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]>
1 parent e05a235 commit 53ae1ec

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

pkg/apis/workspaces/v1alpha2/devworkspacetemplate_spec.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ type DevWorkspaceTemplateSpecContent struct {
7979
// +devfile:toplevellist
8080
StarterProjects []StarterProject `json:"starterProjects,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
8181

82+
// Additional projects related to the main project in the devfile, contianing names and sources locations
83+
// +optional
84+
// +patchMergeKey=name
85+
// +patchStrategy=merge
86+
// +devfile:overrides:include:omitInPlugin=true,description=Overrides of dependentProjects encapsulated in a parent devfile.
87+
// +devfile:toplevellist
88+
DependentProjects []Project `json:"dependentProjects,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
89+
8290
// Predefined, ready-to-use, devworkspace-related commands
8391
// +optional
8492
// +patchMergeKey=id

pkg/validation/variables/test-fixtures/all/devfile-bad-output.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ starterProjects:
2525
- name: starterproject2
2626
zip:
2727
location: "{{tag}}"
28+
dependentProjects:
29+
- name: dependentproject1
30+
clonePath: "{{path}}"
31+
git:
32+
checkoutFrom:
33+
revision: "{{tag}}"
34+
remotes:
35+
"{{dir}}": "{{version1}}/dev/null-/dev/null"
36+
"{{version}}": "test"
37+
- name: dependentproject2
38+
zip:
39+
location: "{{tag}}"
2840
components:
2941
- name: component1
3042
container:

pkg/validation/variables/test-fixtures/all/devfile-bad.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ starterProjects:
2525
- name: starterproject2
2626
zip:
2727
location: "{{tag}}"
28+
dependentProjects:
29+
- name: dependentproject1
30+
clonePath: "{{path}}"
31+
git:
32+
checkoutFrom:
33+
revision: "{{tag}}"
34+
remotes:
35+
"{{dir}}": "{{version1}}{{devnull}}-{{devnull}}"
36+
"{{version}}": "test"
37+
- name: dependentproject2
38+
zip:
39+
location: "{{tag}}"
2840
components:
2941
- name: component1
3042
container:

pkg/validation/variables/variables.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ type VariableWarning struct {
3939

4040
// StarterProjects stores a map of starter project names to the invalid variable references
4141
StarterProjects map[string][]string
42+
43+
// DependentProjects stores a map of dependent project names to invalid variable references
44+
DependentProjects map[string][]string
4245
}
4346

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

5962
// Validate the starter projects and replace for global variable
6063
variableWarning.StarterProjects = ValidateAndReplaceForStarterProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.StarterProjects)
64+
65+
// Validate the starter projects and replace for global variable
66+
variableWarning.DependentProjects = ValidateAndReplaceForProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.DependentProjects)
6167
}
6268

6369
return variableWarning

pkg/validation/variables/variables_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func TestValidateGlobalVariableBasic(t *testing.T) {
6565
"starterproject1": {"desc", "dir", "tag"},
6666
"starterproject2": {"tag"},
6767
},
68+
DependentProjects: map[string][]string{
69+
"project1": {"dir", "path", "tag", "version", "version1"},
70+
"project2": {"tag"},
71+
},
6872
},
6973
},
7074
}

0 commit comments

Comments
 (0)