From 5d26e515d13539b97d938530c3ea9fb3f41bc382 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Tue, 8 Aug 2023 15:36:16 -0400 Subject: [PATCH] Add dependentProjects to v1alpha1 spec as well and update conversion Signed-off-by: Angel Misevski --- ...pace.devfile.io_devworkspaces.v1beta1.yaml | 124 ++++++++++++++++++ crds/workspace.devfile.io_devworkspaces.yaml | 124 ++++++++++++++++++ ...file.io_devworkspacetemplates.v1beta1.yaml | 117 +++++++++++++++++ ...pace.devfile.io_devworkspacetemplates.yaml | 117 +++++++++++++++++ pkg/apis/workspaces/v1alpha1/conversion.go | 18 +++ .../v1alpha1/devworkspacetemplate_spec.go | 4 + .../v1alpha1/zz_generated.deepcopy.go | 7 + 7 files changed, 511 insertions(+) diff --git a/crds/workspace.devfile.io_devworkspaces.v1beta1.yaml b/crds/workspace.devfile.io_devworkspaces.v1beta1.yaml index 719c7cdbd..9f7e6d132 100644 --- a/crds/workspace.devfile.io_devworkspaces.v1beta1.yaml +++ b/crds/workspace.devfile.io_devworkspaces.v1beta1.yaml @@ -1743,6 +1743,130 @@ spec: type: object type: object type: array + dependentProjects: + description: Additional projects related to the main project in + the devfile, contianing names and sources locations + items: + oneOf: + - required: + - git + - required: + - github + - required: + - zip + - required: + - custom + properties: + clonePath: + description: Path relative to the root of the projects to + which this project should be cloned into. This is a unix-style + relative path (i.e. uses forward slashes). The path is + invalid if it is absolute or tries to escape the project + root through the usage of '..'. If not specified, defaults + to the project name. + type: string + custom: + description: Project's Custom source + properties: + embeddedResource: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + projectSourceClass: + type: string + required: + - embeddedResource + - projectSourceClass + type: object + git: + description: Project's Git source + properties: + checkoutFrom: + description: Defines from what the project should be + checked out. Required if there are more than one remote + configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should + be branch name, tag or commit id. Default branch + is used if missing or specified revision is not + found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote + configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + github: + description: Project's GitHub source + properties: + checkoutFrom: + description: Defines from what the project should be + checked out. Required if there are more than one remote + configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should + be branch name, tag or commit id. Default branch + is used if missing or specified revision is not + found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote + configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + name: + description: Project name + type: string + sourceType: + description: Type of project source + enum: + - Git + - Github + - Zip + - Custom + type: string + zip: + description: Project's Zip source + properties: + location: + description: Zip project's source location address. + Should be file path of the archive, e.g. file://$FILE_PATH + type: string + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + required: + - name + type: object + type: array events: description: Bindings of commands to events. Each command is referred-to by its name. diff --git a/crds/workspace.devfile.io_devworkspaces.yaml b/crds/workspace.devfile.io_devworkspaces.yaml index e1a31be5a..a2a5e7631 100644 --- a/crds/workspace.devfile.io_devworkspaces.yaml +++ b/crds/workspace.devfile.io_devworkspaces.yaml @@ -1739,6 +1739,130 @@ spec: type: object type: object type: array + dependentProjects: + description: Additional projects related to the main project in + the devfile, contianing names and sources locations + items: + oneOf: + - required: + - git + - required: + - github + - required: + - zip + - required: + - custom + properties: + clonePath: + description: Path relative to the root of the projects to + which this project should be cloned into. This is a unix-style + relative path (i.e. uses forward slashes). The path is + invalid if it is absolute or tries to escape the project + root through the usage of '..'. If not specified, defaults + to the project name. + type: string + custom: + description: Project's Custom source + properties: + embeddedResource: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + projectSourceClass: + type: string + required: + - embeddedResource + - projectSourceClass + type: object + git: + description: Project's Git source + properties: + checkoutFrom: + description: Defines from what the project should be + checked out. Required if there are more than one remote + configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should + be branch name, tag or commit id. Default branch + is used if missing or specified revision is not + found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote + configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + github: + description: Project's GitHub source + properties: + checkoutFrom: + description: Defines from what the project should be + checked out. Required if there are more than one remote + configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should + be branch name, tag or commit id. Default branch + is used if missing or specified revision is not + found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote + configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + name: + description: Project name + type: string + sourceType: + description: Type of project source + enum: + - Git + - Github + - Zip + - Custom + type: string + zip: + description: Project's Zip source + properties: + location: + description: Zip project's source location address. + Should be file path of the archive, e.g. file://$FILE_PATH + type: string + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + required: + - name + type: object + type: array events: description: Bindings of commands to events. Each command is referred-to by its name. diff --git a/crds/workspace.devfile.io_devworkspacetemplates.v1beta1.yaml b/crds/workspace.devfile.io_devworkspacetemplates.v1beta1.yaml index d7d64ac3b..f65354fff 100644 --- a/crds/workspace.devfile.io_devworkspacetemplates.v1beta1.yaml +++ b/crds/workspace.devfile.io_devworkspacetemplates.v1beta1.yaml @@ -1671,6 +1671,123 @@ spec: type: object type: object type: array + dependentProjects: + description: Additional projects related to the main project in the + devfile, contianing names and sources locations + items: + oneOf: + - required: + - git + - required: + - github + - required: + - zip + - required: + - custom + properties: + clonePath: + description: Path relative to the root of the projects to which + this project should be cloned into. This is a unix-style relative + path (i.e. uses forward slashes). The path is invalid if it + is absolute or tries to escape the project root through the + usage of '..'. If not specified, defaults to the project name. + type: string + custom: + description: Project's Custom source + properties: + embeddedResource: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + projectSourceClass: + type: string + required: + - embeddedResource + - projectSourceClass + type: object + git: + description: Project's Git source + properties: + checkoutFrom: + description: Defines from what the project should be checked + out. Required if there are more than one remote configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should be + branch name, tag or commit id. Default branch is used + if missing or specified revision is not found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + github: + description: Project's GitHub source + properties: + checkoutFrom: + description: Defines from what the project should be checked + out. Required if there are more than one remote configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should be + branch name, tag or commit id. Default branch is used + if missing or specified revision is not found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + name: + description: Project name + type: string + sourceType: + description: Type of project source + enum: + - Git + - Github + - Zip + - Custom + type: string + zip: + description: Project's Zip source + properties: + location: + description: Zip project's source location address. Should + be file path of the archive, e.g. file://$FILE_PATH + type: string + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + required: + - name + type: object + type: array events: description: Bindings of commands to events. Each command is referred-to by its name. diff --git a/crds/workspace.devfile.io_devworkspacetemplates.yaml b/crds/workspace.devfile.io_devworkspacetemplates.yaml index 3e15e287c..9a400ab93 100644 --- a/crds/workspace.devfile.io_devworkspacetemplates.yaml +++ b/crds/workspace.devfile.io_devworkspacetemplates.yaml @@ -1669,6 +1669,123 @@ spec: type: object type: object type: array + dependentProjects: + description: Additional projects related to the main project in the + devfile, contianing names and sources locations + items: + oneOf: + - required: + - git + - required: + - github + - required: + - zip + - required: + - custom + properties: + clonePath: + description: Path relative to the root of the projects to which + this project should be cloned into. This is a unix-style relative + path (i.e. uses forward slashes). The path is invalid if it + is absolute or tries to escape the project root through the + usage of '..'. If not specified, defaults to the project name. + type: string + custom: + description: Project's Custom source + properties: + embeddedResource: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + projectSourceClass: + type: string + required: + - embeddedResource + - projectSourceClass + type: object + git: + description: Project's Git source + properties: + checkoutFrom: + description: Defines from what the project should be checked + out. Required if there are more than one remote configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should be + branch name, tag or commit id. Default branch is used + if missing or specified revision is not found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + github: + description: Project's GitHub source + properties: + checkoutFrom: + description: Defines from what the project should be checked + out. Required if there are more than one remote configured + properties: + remote: + description: The remote name should be used as init. + Required if there are more than one remote configured + type: string + revision: + description: The revision to checkout from. Should be + branch name, tag or commit id. Default branch is used + if missing or specified revision is not found. + type: string + type: object + remotes: + additionalProperties: + type: string + description: The remotes map which should be initialized + in the git project. Must have at least one remote configured + type: object + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + name: + description: Project name + type: string + sourceType: + description: Type of project source + enum: + - Git + - Github + - Zip + - Custom + type: string + zip: + description: Project's Zip source + properties: + location: + description: Zip project's source location address. Should + be file path of the archive, e.g. file://$FILE_PATH + type: string + sparseCheckoutDir: + description: Part of project to populate in the working + directory. + type: string + type: object + required: + - name + type: object + type: array events: description: Bindings of commands to events. Each command is referred-to by its name. diff --git a/pkg/apis/workspaces/v1alpha1/conversion.go b/pkg/apis/workspaces/v1alpha1/conversion.go index 2aa6dd9f6..989c80fb4 100644 --- a/pkg/apis/workspaces/v1alpha1/conversion.go +++ b/pkg/apis/workspaces/v1alpha1/conversion.go @@ -72,6 +72,15 @@ func convertDevWorkspaceTemplateSpecTo_v1alpha2(src *DevWorkspaceTemplateSpec, d } dest.Projects = append(dest.Projects, destProject) } + for _, srcProject := range src.DependentProjects { + srcProject := srcProject + destProject := v1alpha2.Project{} + err := convertProjectTo_v1alpha2(&srcProject, &destProject) + if err != nil { + return err + } + dest.DependentProjects = append(dest.DependentProjects, destProject) + } for _, srcStarterProject := range src.StarterProjects { srcStarterProject := srcStarterProject destStarterProject := v1alpha2.StarterProject{} @@ -126,6 +135,15 @@ func convertDevWorkspaceTemplateSpecFrom_v1alpha2(src *v1alpha2.DevWorkspaceTemp } dest.Projects = append(dest.Projects, destProject) } + for _, srcProject := range src.DependentProjects { + srcProject := srcProject + destProject := Project{} + err := convertProjectFrom_v1alpha2(&srcProject, &destProject) + if err != nil { + return err + } + dest.DependentProjects = append(dest.DependentProjects, destProject) + } for _, srcStarterProject := range src.StarterProjects { srcStarterProject := srcStarterProject destStarterProject := StarterProject{} diff --git a/pkg/apis/workspaces/v1alpha1/devworkspacetemplate_spec.go b/pkg/apis/workspaces/v1alpha1/devworkspacetemplate_spec.go index ac0c3ac5b..a92303cc5 100644 --- a/pkg/apis/workspaces/v1alpha1/devworkspacetemplate_spec.go +++ b/pkg/apis/workspaces/v1alpha1/devworkspacetemplate_spec.go @@ -25,6 +25,10 @@ type DevWorkspaceTemplateSpecContent struct { // +optional Projects []Project `json:"projects,omitempty" patchStrategy:"merge" patchMergeKey:"name"` + // Additional projects related to the main project in the devfile, contianing names and sources locations + // +optional + DependentProjects []Project `json:"dependentProjects,omitempty" patchStrategy:"merge" patchMergeKey:"name"` + // StarterProjects is a project that can be used as a starting point when bootstrapping new projects // +optional StarterProjects []StarterProject `json:"starterProjects,omitempty"` diff --git a/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go index ad58e2e33..aefc0d848 100644 --- a/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go @@ -529,6 +529,13 @@ func (in *DevWorkspaceTemplateSpecContent) DeepCopyInto(out *DevWorkspaceTemplat (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.DependentProjects != nil { + in, out := &in.DependentProjects, &out.DependentProjects + *out = make([]Project, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.StarterProjects != nil { in, out := &in.StarterProjects, &out.StarterProjects *out = make([]StarterProject, len(*in))