diff --git a/pkg/apis/workspaces/v1alpha2/devworkspacetemplate_spec.go b/pkg/apis/workspaces/v1alpha2/devworkspacetemplate_spec.go index 1d48cf7cc..c2e761285 100644 --- a/pkg/apis/workspaces/v1alpha2/devworkspacetemplate_spec.go +++ b/pkg/apis/workspaces/v1alpha2/devworkspacetemplate_spec.go @@ -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 diff --git a/pkg/validation/variables/test-fixtures/all/devfile-bad-output.yaml b/pkg/validation/variables/test-fixtures/all/devfile-bad-output.yaml index b74699647..ae6551a29 100644 --- a/pkg/validation/variables/test-fixtures/all/devfile-bad-output.yaml +++ b/pkg/validation/variables/test-fixtures/all/devfile-bad-output.yaml @@ -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: diff --git a/pkg/validation/variables/test-fixtures/all/devfile-bad.yaml b/pkg/validation/variables/test-fixtures/all/devfile-bad.yaml index 7b4c597b5..292aeac99 100644 --- a/pkg/validation/variables/test-fixtures/all/devfile-bad.yaml +++ b/pkg/validation/variables/test-fixtures/all/devfile-bad.yaml @@ -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: diff --git a/pkg/validation/variables/variables.go b/pkg/validation/variables/variables.go index b1adf413a..2b123c84d 100644 --- a/pkg/validation/variables/variables.go +++ b/pkg/validation/variables/variables.go @@ -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 @@ -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 diff --git a/pkg/validation/variables/variables_test.go b/pkg/validation/variables/variables_test.go index b1c6fa7e9..385216cae 100644 --- a/pkg/validation/variables/variables_test.go +++ b/pkg/validation/variables/variables_test.go @@ -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"}, + }, }, }, }