feat: support workspace defaults (#1395)
* feat: support workspace defaults Signed-off-by: Oleksii Orel <oorel@redhat.com>pull/1410/head
parent
da066faf08
commit
3830ac4e28
2
Makefile
2
Makefile
|
|
@ -658,7 +658,7 @@ download-opm: ## Download opm tool
|
|||
|
||||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
|
||||
download-controller-gen: ## Download controller-gen tool
|
||||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1)
|
||||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0)
|
||||
|
||||
KUSTOMIZE = $(shell pwd)/bin/kustomize
|
||||
download-kustomize: ## Download kustomize tool
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import (
|
|||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
||||
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
|
||||
chev1 "github.com/eclipse-che/che-operator/api/v1"
|
||||
chev2 "github.com/eclipse-che/che-operator/api/v2"
|
||||
|
|
@ -333,6 +334,12 @@ func TestConvertFrom(t *testing.T) {
|
|||
Plugins: []string{"Plugins_1", "Plugins_2"},
|
||||
},
|
||||
},
|
||||
DefaultEditor: "DefaultEditor",
|
||||
DefaultComponents: []devfile.Component{
|
||||
{
|
||||
Name: "universal-developer-image",
|
||||
},
|
||||
},
|
||||
NodeSelector: map[string]string{"a": "b", "c": "d"},
|
||||
Tolerations: []corev1.Toleration{{
|
||||
Key: "Key",
|
||||
|
|
@ -449,6 +456,8 @@ func TestConvertFrom(t *testing.T) {
|
|||
assert.Equal(t, checlusterv1.Spec.Server.SingleHostGatewayConfigSidecarImage, "ConfigSidecarImage")
|
||||
assert.Equal(t, checlusterv1.Spec.Server.SingleHostGatewayImage, "GatewayImage")
|
||||
assert.Equal(t, checlusterv1.Spec.Server.WorkspaceNamespaceDefault, "WorkspaceNamespaceName")
|
||||
assert.Equal(t, checlusterv1.Spec.Server.WorkspaceDefaultEditor, "DefaultEditor")
|
||||
assert.Equal(t, checlusterv1.Spec.Server.WorkspaceDefaultComponents, []devfile.Component{{Name: "universal-developer-image"}})
|
||||
assert.Equal(t, checlusterv1.Spec.Server.WorkspacePodNodeSelector, map[string]string{"a": "b", "c": "d"})
|
||||
assert.Equal(t, checlusterv1.Spec.Server.WorkspacePodTolerations, []corev1.Toleration{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import (
|
|||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
||||
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
|
||||
chev1 "github.com/eclipse-che/che-operator/api/v1"
|
||||
chev2 "github.com/eclipse-che/che-operator/api/v2"
|
||||
|
|
@ -161,21 +162,27 @@ func TestConvertTo(t *testing.T) {
|
|||
CheClusterRoles: "CheClusterRoles_1,CheClusterRoles_2",
|
||||
CheWorkspaceClusterRole: "CheWorkspaceClusterRole",
|
||||
WorkspaceNamespaceDefault: "WorkspaceNamespaceDefault",
|
||||
ServerTrustStoreConfigMapName: "ServerTrustStoreConfigMapName",
|
||||
GitSelfSignedCert: true,
|
||||
DashboardImage: "DashboardImage",
|
||||
DashboardImagePullPolicy: "Always",
|
||||
DashboardMemoryLimit: "200Mi",
|
||||
DashboardMemoryRequest: "100Mi",
|
||||
DashboardCpuLimit: "2",
|
||||
DashboardCpuRequest: "1",
|
||||
DevfileRegistryImage: "DevfileRegistryImage",
|
||||
DevfileRegistryPullPolicy: "Always",
|
||||
DevfileRegistryMemoryLimit: "200Mi",
|
||||
DevfileRegistryMemoryRequest: "100Mi",
|
||||
DevfileRegistryCpuLimit: "2",
|
||||
DevfileRegistryCpuRequest: "1",
|
||||
ExternalDevfileRegistry: true,
|
||||
WorkspaceDefaultEditor: "WorkspaceDefaultEditor",
|
||||
WorkspaceDefaultComponents: []devfile.Component{
|
||||
{
|
||||
Name: "universal-developer-image",
|
||||
},
|
||||
},
|
||||
ServerTrustStoreConfigMapName: "ServerTrustStoreConfigMapName",
|
||||
GitSelfSignedCert: true,
|
||||
DashboardImage: "DashboardImage",
|
||||
DashboardImagePullPolicy: "Always",
|
||||
DashboardMemoryLimit: "200Mi",
|
||||
DashboardMemoryRequest: "100Mi",
|
||||
DashboardCpuLimit: "2",
|
||||
DashboardCpuRequest: "1",
|
||||
DevfileRegistryImage: "DevfileRegistryImage",
|
||||
DevfileRegistryPullPolicy: "Always",
|
||||
DevfileRegistryMemoryLimit: "200Mi",
|
||||
DevfileRegistryMemoryRequest: "100Mi",
|
||||
DevfileRegistryCpuLimit: "2",
|
||||
DevfileRegistryCpuRequest: "1",
|
||||
ExternalDevfileRegistry: true,
|
||||
ExternalDevfileRegistries: []chev1.ExternalDevfileRegistries{
|
||||
{
|
||||
Url: "ExternalDevfileRegistries_1",
|
||||
|
|
@ -330,6 +337,8 @@ func TestConvertTo(t *testing.T) {
|
|||
assert.Equal(t, checlusterv2.Spec.Components.CheServer.Proxy.Port, "ProxyPort")
|
||||
assert.Equal(t, checlusterv2.Spec.Components.CheServer.Proxy.Url, "ProxyURL")
|
||||
assert.Equal(t, checlusterv2.Spec.DevEnvironments.DefaultNamespace.Template, "WorkspaceNamespaceDefault")
|
||||
assert.Equal(t, checlusterv2.Spec.DevEnvironments.DefaultEditor, "WorkspaceDefaultEditor")
|
||||
assert.Equal(t, checlusterv2.Spec.DevEnvironments.DefaultComponents, []devfile.Component{{Name: "universal-developer-image"}})
|
||||
assert.Equal(t, checlusterv2.Spec.DevEnvironments.NodeSelector, map[string]string{"a": "b", "c": "d"})
|
||||
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Tolerations, []corev1.Toleration{{
|
||||
Key: "Key",
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ func (dst *CheCluster) convertFrom_Server(src *chev2.CheCluster) error {
|
|||
})
|
||||
}
|
||||
|
||||
dst.Spec.Server.WorkspaceDefaultEditor = src.Spec.DevEnvironments.DefaultEditor
|
||||
dst.Spec.Server.WorkspaceDefaultComponents = src.Spec.DevEnvironments.DefaultComponents
|
||||
|
||||
if len(src.Spec.Components.CheServer.Deployment.Containers) != 0 {
|
||||
cheServerImageAndTag := strings.Split(src.Spec.Components.CheServer.Deployment.Containers[0].Image, ":")
|
||||
dst.Spec.Server.CheImage = strings.Join(cheServerImageAndTag[0:len(cheServerImageAndTag)-1], ":")
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ func (src *CheCluster) convertTo_DevEnvironments(dst *chev2.CheCluster) error {
|
|||
})
|
||||
}
|
||||
|
||||
dst.Spec.DevEnvironments.DefaultEditor = src.Spec.Server.WorkspaceDefaultEditor
|
||||
dst.Spec.DevEnvironments.DefaultComponents = src.Spec.Server.WorkspaceDefaultComponents
|
||||
|
||||
if err := src.convertTo_Workspaces_Storage(dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"strings"
|
||||
|
||||
chev1alpha1 "github.com/che-incubator/kubernetes-image-puller-operator/api/v1alpha1"
|
||||
devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
|
@ -356,6 +357,15 @@ type CheClusterSpecServer struct {
|
|||
WorkspacePodNodeSelector map[string]string `json:"workspacePodNodeSelector,omitempty"`
|
||||
// The pod tolerations put on the workspace pods to limit where the workspace pods can run.
|
||||
WorkspacePodTolerations []corev1.Toleration `json:"workspacePodTolerations,omitempty"`
|
||||
// The default editor to workspace create with. It could be a plugin ID or a URI.
|
||||
// The plugin ID must have `publisher/plugin/version`.
|
||||
// The URI must start from `http`.
|
||||
// +optional
|
||||
WorkspaceDefaultEditor string `json:"workspaceDefaultEditor,omitempty"`
|
||||
// Default components applied to DevWorkspaces.
|
||||
// These default components are meant to be used when a Devfile does not contain any components.
|
||||
// +optional
|
||||
WorkspaceDefaultComponents []devfile.Component `json:"workspaceDefaultComponents,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
@ -286,6 +287,13 @@ func (in *CheClusterSpecServer) DeepCopyInto(out *CheClusterSpecServer) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.WorkspaceDefaultComponents != nil {
|
||||
in, out := &in.WorkspaceDefaultComponents, &out.WorkspaceDefaultComponents
|
||||
*out = make([]v1alpha2.Component, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CheClusterSpecServer.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
imagepullerv1alpha1 "github.com/che-incubator/kubernetes-image-puller-operator/api/v1alpha1"
|
||||
devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
|
@ -80,6 +81,15 @@ type CheClusterDevEnvironments struct {
|
|||
// Trusted certificate settings.
|
||||
// +optional
|
||||
TrustedCerts TrustedCerts `json:"trustedCerts,omitempty"`
|
||||
// The default editor to workspace create with. It could be a plugin ID or a URI.
|
||||
// The plugin ID must have `publisher/plugin/version` format.
|
||||
// The URI must start from `http://` or `https://`.
|
||||
// +optional
|
||||
DefaultEditor string `json:"defaultEditor,omitempty"`
|
||||
// Default components applied to DevWorkspaces.
|
||||
// These default components are meant to be used when a Devfile, that does not contain any components.
|
||||
// +optional
|
||||
DefaultComponents []devfile.Component `json:"defaultComponents,omitempty"`
|
||||
}
|
||||
|
||||
// Che components configuration.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package v2
|
||||
|
||||
import (
|
||||
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
|
@ -129,6 +130,13 @@ func (in *CheClusterDevEnvironments) DeepCopyInto(out *CheClusterDevEnvironments
|
|||
}
|
||||
out.DefaultNamespace = in.DefaultNamespace
|
||||
out.TrustedCerts = in.TrustedCerts
|
||||
if in.DefaultComponents != nil {
|
||||
in, out := &in.DefaultComponents, &out.DefaultComponents
|
||||
*out = make([]v1alpha2.Component, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CheClusterDevEnvironments.
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ metadata:
|
|||
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
|
||||
repository: https://github.com/eclipse-che/che-operator
|
||||
support: Eclipse Foundation
|
||||
name: eclipse-che-preview-openshift.v7.50.0-606.next
|
||||
name: eclipse-che-preview-openshift.v7.50.0-611.next
|
||||
namespace: placeholder
|
||||
spec:
|
||||
apiservicedefinitions: {}
|
||||
|
|
@ -1387,7 +1387,7 @@ spec:
|
|||
maturity: stable
|
||||
provider:
|
||||
name: Eclipse Foundation
|
||||
version: 7.50.0-606.next
|
||||
version: 7.50.0-611.next
|
||||
webhookdefinitions:
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue