From 9bc16a06eeeaedfdd316a22861162ba88ea6ea36 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Wed, 3 Feb 2021 14:59:29 -0500 Subject: [PATCH 1/9] Add support for plugins specified by ID in "internal" registry Signed-off-by: Angel Misevski --- internal/images/image.go | 21 +++++- pkg/library/flatten/flatten.go | 26 +++++++- .../flatten/internal_registry/registry.go | 64 +++++++++++++++++++ 3 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 pkg/library/flatten/internal_registry/registry.go diff --git a/internal/images/image.go b/internal/images/image.go index 5d89d479a..5ca5d7f8c 100644 --- a/internal/images/image.go +++ b/internal/images/image.go @@ -25,6 +25,7 @@ import ( "os" "regexp" + devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" logf "sigs.k8s.io/controller-runtime/pkg/log" ) @@ -40,7 +41,7 @@ const ( pvcCleanupJobImageEnvVar = "RELATED_IMAGE_pvc_cleanup_job" ) -// GetWebTerminalToolingImage returns the image reference for the webhook server image. Returns +// GetWebhookServerImage returns the image reference for the webhook server image. Returns // the empty string if environment variable RELATED_IMAGE_devworkspace_webhook_server is not defined func GetWebhookServerImage() string { val, ok := os.LookupEnv(webhookServerImageEnvVar) @@ -96,6 +97,24 @@ func GetPVCCleanupJobImage() string { return val } +// FillPluginEnvVars replaces plugin devworkspaceTemplate .spec.components[].container.image environment +// variables of the form ${RELATED_IMAGE_*} with values from environment variables with the same name. +// +// Returns error if any referenced environment variable is undefined. +func FillPluginEnvVars(pluginDWT *devworkspace.DevWorkspaceTemplate) (*devworkspace.DevWorkspaceTemplate, error) { + for idx, component := range pluginDWT.Spec.Components { + if component.Container == nil { + continue + } + img, err := getImageForEnvVar(component.Container.Image) + if err != nil { + return nil, err + } + pluginDWT.Spec.Components[idx].Container.Image = img + } + return pluginDWT, nil +} + func isImageEnvVar(query string) bool { return envRegexp.MatchString(query) } diff --git a/pkg/library/flatten/flatten.go b/pkg/library/flatten/flatten.go index 328677b86..f07119516 100644 --- a/pkg/library/flatten/flatten.go +++ b/pkg/library/flatten/flatten.go @@ -16,6 +16,8 @@ import ( "context" "fmt" + registry "github.com/devfile/devworkspace-operator/pkg/library/flatten/internal_registry" + devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" "github.com/devfile/api/pkg/utils/overriding" "k8s.io/apimachinery/pkg/api/errors" @@ -121,9 +123,9 @@ func resolvePluginComponent( } resolvedPlugin, pluginMeta, err = resolvePluginComponentByKubernetesReference(name, plugin, tooling) case plugin.Uri != "": - err = fmt.Errorf("failed to resolve plugin %s: only plugins specified by kubernetes reference are supported", name) + err = fmt.Errorf("failed to resolve plugin %s: only plugins specified by kubernetes reference or id are supported", name) case plugin.Id != "": - err = fmt.Errorf("failed to resolve plugin %s: only plugins specified by kubernetes reference are supported", name) + resolvedPlugin, pluginMeta, err = resolvePluginComponentById(name, plugin, tooling) default: err = fmt.Errorf("plugin %s does not define any resources", name) } @@ -171,3 +173,23 @@ func resolvePluginComponentByKubernetesReference( } return &dwTemplate.Spec, dwTemplate.Labels, nil } + +func resolvePluginComponentById( + name string, + plugin *devworkspace.PluginComponent, + _ ResolverTools) (resolvedPlugin *devworkspace.DevWorkspaceTemplateSpec, pluginLabels map[string]string, err error) { + + // Check internal registry for plugins that do not specify a registry + if plugin.RegistryUrl == "" { + if !registry.IsInInternalRegistry(plugin.Id) { + return nil, nil, fmt.Errorf("plugin for component %s does not specify a registry and is not present in internal registry", name) + } + pluginDWT, err := registry.ReadPluginFromInternalRegistry(plugin.Id) + if err != nil { + return nil, nil, fmt.Errorf("failed to read plugin for component %s from internal registry: %w", name, err) + } + return &pluginDWT.Spec, pluginDWT.Labels, nil + } + + return nil, nil, fmt.Errorf("non-internal plugins not supported") +} diff --git a/pkg/library/flatten/internal_registry/registry.go b/pkg/library/flatten/internal_registry/registry.go new file mode 100644 index 000000000..6c39e4499 --- /dev/null +++ b/pkg/library/flatten/internal_registry/registry.go @@ -0,0 +1,64 @@ +// +// Copyright (c) 2019-2020 Red Hat, Inc. +// This program and the accompanying materials are made +// available under the terms of the Eclipse Public License 2.0 +// which is available at https://www.eclipse.org/legal/epl-2.0/ +// +// SPDX-License-Identifier: EPL-2.0 +// +// Contributors: +// Red Hat, Inc. - initial API and implementation +// + +package registry + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + + devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" + "github.com/devfile/devworkspace-operator/internal/images" + "sigs.k8s.io/yaml" + + logf "sigs.k8s.io/controller-runtime/pkg/log" +) + +const ( + // RegistryDirectory is the directory where the YAML files for the internal registry exist + RegistryDirectory = "internal-registry/" +) + +var log = logf.Log.WithName("registry") + +func getPluginPath(pluginID string) string { + return filepath.Join(RegistryDirectory, pluginID, "devworkspacetemplate.yaml") +} + +// IsInInternalRegistry checks if pluginID is in the internal registry +func IsInInternalRegistry(pluginID string) bool { + if _, err := os.Stat(getPluginPath(pluginID)); err != nil { + if os.IsNotExist(err) { + log.Info(fmt.Sprintf("Could not find %s in the internal registry", pluginID)) + } + return false + } + return true +} + +func ReadPluginFromInternalRegistry(pluginID string) (*devworkspace.DevWorkspaceTemplate, error) { + yamlBytes, err := ioutil.ReadFile(getPluginPath(pluginID)) + if err != nil { + return nil, err + } + plugin := &devworkspace.DevWorkspaceTemplate{} + if err := yaml.Unmarshal(yamlBytes, plugin); err != nil { + return nil, err + } + resolvedPlugin, err := images.FillPluginEnvVars(plugin) + if err != nil { + return nil, err + } + return resolvedPlugin, nil +} From 3f0a82aad755d4feb2983a59f3573439d1fa8275 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Wed, 3 Feb 2021 15:36:14 -0500 Subject: [PATCH 2/9] Update internal registry to use DevWorkspaceTemplates Signed-off-by: Angel Misevski --- .../nightly/devworkspacetemplate.yaml | 26 +++++++++++++ .../eclipse/cloud-shell/nightly/meta.yaml | 37 ------------------ .../4.5.0/devworkspacetemplate.yaml | 27 +++++++++++++ .../web-terminal-dev/4.5.0/meta.yaml | 38 ------------------- .../nightly/devworkspacetemplate.yaml | 27 +++++++++++++ .../web-terminal-dev/nightly/meta.yaml | 38 ------------------- .../4.5.0/devworkspacetemplate.yaml | 28 ++++++++++++++ .../web-terminal/4.5.0/meta.yaml | 37 ------------------ .../nightly/devworkspacetemplate.yaml | 28 ++++++++++++++ .../web-terminal/nightly/meta.yaml | 37 ------------------ 10 files changed, 136 insertions(+), 187 deletions(-) create mode 100644 internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml delete mode 100644 internal-registry/eclipse/cloud-shell/nightly/meta.yaml create mode 100644 internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml delete mode 100644 internal-registry/redhat-developer/web-terminal-dev/4.5.0/meta.yaml create mode 100644 internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml delete mode 100644 internal-registry/redhat-developer/web-terminal-dev/nightly/meta.yaml create mode 100644 internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml delete mode 100644 internal-registry/redhat-developer/web-terminal/4.5.0/meta.yaml create mode 100644 internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml delete mode 100644 internal-registry/redhat-developer/web-terminal/nightly/meta.yaml diff --git a/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml b/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml new file mode 100644 index 000000000..22560c35b --- /dev/null +++ b/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml @@ -0,0 +1,26 @@ +kind: DevWorkspaceTemplate +apiVersion: workspace.devfile.io/v1alpha2 +metadata: + name: cloud-shell +spec: + components: + - name: web-terminal + container: + image: "${RELATED_IMAGE_plugin_eclipse_cloud_shell_nightly}" + mountSources: false + command: ["/go/bin/che-machine-exec", + "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", + "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", + "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--use-bearer-token", + "--static", "/cloud-shell"] + endpoints: + - name: cloud-shell + exposure: public + targetPort: 4444 + protocol: http + secure: true + path: /static/ + attributes: + type: ide + cookiesAuthEnabled: "true" diff --git a/internal-registry/eclipse/cloud-shell/nightly/meta.yaml b/internal-registry/eclipse/cloud-shell/nightly/meta.yaml deleted file mode 100644 index 3d361078f..000000000 --- a/internal-registry/eclipse/cloud-shell/nightly/meta.yaml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: v2 -publisher: eclipse -name: cloud-shell -version: nightly -type: Che Editor -displayName: Cloud Shell Editor -title: Cloud Shell Editor -description: Cloud Shell provides an ability to use terminal widget like an editor. - Requires OpenShift token to be propagated with requests. It's currently supported - only by openshift-oauth routing. -icon: https://www.eclipse.org/che/images/logo-eclipseche.svg -repository: https://github.com/eclipse/che-machine-exec/ -firstPublicationDate: "2020-01-29" -category: Other -spec: - endpoints: - - name: cloud-shell - public: true - targetPort: 4444 - attributes: - protocol: http - type: ide - path: /static/ - discoverable: false - secure: true - cookiesAuthEnabled: true - containers: - - name: che-machine-exec - image: "${RELATED_IMAGE_plugin_eclipse_cloud_shell_nightly}" - ports: - - exposedPort: 4444 - command: ["/go/bin/che-machine-exec", - "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", - "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", - "--use-bearer-token", - "--static", "/cloud-shell"] diff --git a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml new file mode 100644 index 000000000..667a3d93b --- /dev/null +++ b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml @@ -0,0 +1,27 @@ +kind: DevWorkspaceTemplate +apiVersion: workspace.devfile.io/v1alpha2 +metadata: + name: web-terminal-dev +spec: + components: + - name: web-terminal + container: + image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_dev_4_5_0}" + command: ["/go/bin/che-machine-exec", + "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", + "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", + "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--use-bearer-token"] + endpoints: + - name: web-terminal + targetPort: 4444 + secure: true + exposure: internal + protocol: http + attributes: + type: ide + cookiesAuthEnabled: "true" + mountSources: false + env: + - name: USE_BEARER_TOKEN + value: "true" diff --git a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/meta.yaml b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/meta.yaml deleted file mode 100644 index d4c921ccd..000000000 --- a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/meta.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: v2 -publisher: redhat-developer -name: web-terminal-dev -version: 4.5.0 -type: Che Editor -displayName: Web Terminal -title: Web Terminal -description: Web provides the ability to start a terminal inside - the OpenShift Console. The development version does not run with TLS enabled and - is intended for development purposes only. -icon: null -repository: https://github.com/eclipse/che-machine-exec/ -firstPublicationDate: "2020-06-01" -category: Other -spec: - endpoints: - - name: web-terminal - public: true - targetPort: 4444 - attributes: - protocol: http - type: ide - discoverable: false - secure: true - cookiesAuthEnabled: true - containers: - - name: web-terminal - image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_dev_4_5_0}" - command: ["/go/bin/che-machine-exec", - "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", - "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", - "--use-bearer-token"] - ports: - - exposedPort: 4444 - env: - - name: USE_BEARER_TOKEN - value: true diff --git a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml new file mode 100644 index 000000000..9c9335b96 --- /dev/null +++ b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml @@ -0,0 +1,27 @@ +kind: DevWorkspaceTemplate +apiVersion: workspace.devfile.io/v1alpha2 +metadata: + name: web-terminal-dev +spec: + components: + - name: web-terminal + container: + image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_dev_nightly}" + command: ["/go/bin/che-machine-exec", + "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", + "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", + "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--use-bearer-token"] + endpoints: + - name: web-terminal + targetPort: 4444 + secure: true + exposure: internal + protocol: http + attributes: + type: ide + cookiesAuthEnabled: "true" + mountSources: false + env: + - name: USE_BEARER_TOKEN + value: "true" diff --git a/internal-registry/redhat-developer/web-terminal-dev/nightly/meta.yaml b/internal-registry/redhat-developer/web-terminal-dev/nightly/meta.yaml deleted file mode 100644 index 22c3fd77f..000000000 --- a/internal-registry/redhat-developer/web-terminal-dev/nightly/meta.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: v2 -publisher: redhat-developer -name: web-terminal-dev -version: nightly -type: Che Editor -displayName: Web Terminal -title: Web Terminal -description: Web provides the ability to start a terminal inside - the OpenShift Console. The development version does not run with TLS enabled and - is intended for development purposes only. -icon: null -repository: https://github.com/eclipse/che-machine-exec/ -firstPublicationDate: "2020-06-01" -category: Other -spec: - endpoints: - - name: web-terminal - public: true - targetPort: 4444 - attributes: - protocol: http - type: ide - discoverable: false - secure: true - cookiesAuthEnabled: true - containers: - - name: web-terminal - image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_dev_nightly}" - command: ["/go/bin/che-machine-exec", - "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", - "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", - "--use-bearer-token"] - ports: - - exposedPort: 4444 - env: - - name: USE_BEARER_TOKEN - value: true diff --git a/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml new file mode 100644 index 000000000..21a4697f0 --- /dev/null +++ b/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml @@ -0,0 +1,28 @@ +kind: DevWorkspaceTemplate +apiVersion: workspace.devfile.io/v1alpha2 +metadata: + name: web-terminal +spec: + components: + - name: web-terminal + container: + image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_4_5_0}" + command: ["/go/bin/che-machine-exec", + "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", + "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", + "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--use-bearer-token", + "--use-tls"] + endpoints: + - name: web-terminal + targetPort: 4444 + secure: true + exposure: internal + protocol: http + attributes: + type: ide + cookiesAuthEnabled: "true" + mountSources: false + env: + - name: USE_BEARER_TOKEN + value: "true" diff --git a/internal-registry/redhat-developer/web-terminal/4.5.0/meta.yaml b/internal-registry/redhat-developer/web-terminal/4.5.0/meta.yaml deleted file mode 100644 index c3746f692..000000000 --- a/internal-registry/redhat-developer/web-terminal/4.5.0/meta.yaml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: v2 -publisher: redhat-developer -name: web-terminal -version: 4.5.0 -type: Che Editor -displayName: Web Terminal -title: Web Terminal -description: Web Terminal provides the ability to start a terminal inside the OpenShift Console. -icon: null -repository: https://github.com/eclipse/che-machine-exec/ -firstPublicationDate: "2020-05-13" -category: Other -spec: - endpoints: - - name: web-terminal - public: true - targetPort: 4444 - attributes: - protocol: http - type: ide - discoverable: false - secure: true - cookiesAuthEnabled: true - containers: - - name: web-terminal - image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_4_5_0}" - command: ["/go/bin/che-machine-exec", - "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", - "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", - "--use-bearer-token", - "--use-tls"] - ports: - - exposedPort: 4444 - env: - - name: USE_BEARER_TOKEN - value: true diff --git a/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml new file mode 100644 index 000000000..f46df38b8 --- /dev/null +++ b/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml @@ -0,0 +1,28 @@ +kind: DevWorkspaceTemplate +apiVersion: workspace.devfile.io/v1alpha2 +metadata: + name: web-terminal +spec: + components: + - name: web-terminal + container: + image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_nightly}" + command: ["/go/bin/che-machine-exec", + "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", + "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", + "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--use-bearer-token", + "--use-tls"] + endpoints: + - name: web-terminal + targetPort: 4444 + secure: true + exposure: internal + protocol: http + attributes: + type: ide + cookiesAuthEnabled: "true" + mountSources: false + env: + - name: USE_BEARER_TOKEN + value: "true" diff --git a/internal-registry/redhat-developer/web-terminal/nightly/meta.yaml b/internal-registry/redhat-developer/web-terminal/nightly/meta.yaml deleted file mode 100644 index e356934a7..000000000 --- a/internal-registry/redhat-developer/web-terminal/nightly/meta.yaml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: v2 -publisher: redhat-developer -name: web-terminal -version: nightly -type: Che Editor -displayName: Web Terminal -title: Web Terminal -description: Web Terminal provides the ability to start a terminal inside the OpenShift Console. -icon: null -repository: https://github.com/eclipse/che-machine-exec/ -firstPublicationDate: "2020-05-13" -category: Other -spec: - endpoints: - - name: web-terminal - public: true - targetPort: 4444 - attributes: - protocol: http - type: ide - discoverable: false - secure: true - cookiesAuthEnabled: true - containers: - - name: web-terminal - image: "${RELATED_IMAGE_plugin_redhat_developer_web_terminal_nightly}" - command: ["/go/bin/che-machine-exec", - "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", - "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", - "--use-bearer-token", - "--use-tls"] - ports: - - exposedPort: 4444 - env: - - name: USE_BEARER_TOKEN - value: true From f7fb164f7aef47ba1041205e0524e4b2207a4857 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Wed, 3 Feb 2021 19:01:39 -0500 Subject: [PATCH 3/9] Set web-terminal-dev endpoint exposure to public --- .../web-terminal-dev/4.5.0/devworkspacetemplate.yaml | 2 +- .../web-terminal-dev/nightly/devworkspacetemplate.yaml | 2 +- samples/flattened_web-terminal-dev.yaml | 2 +- samples/plugins/web-terminal-dev.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml index 667a3d93b..6950e284e 100644 --- a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml @@ -16,7 +16,7 @@ spec: - name: web-terminal targetPort: 4444 secure: true - exposure: internal + exposure: public protocol: http attributes: type: ide diff --git a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml index 9c9335b96..174e91acc 100644 --- a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml @@ -16,7 +16,7 @@ spec: - name: web-terminal targetPort: 4444 secure: true - exposure: internal + exposure: public protocol: http attributes: type: ide diff --git a/samples/flattened_web-terminal-dev.yaml b/samples/flattened_web-terminal-dev.yaml index ad097825a..04094e33c 100644 --- a/samples/flattened_web-terminal-dev.yaml +++ b/samples/flattened_web-terminal-dev.yaml @@ -35,7 +35,7 @@ spec: - name: web-terminal targetPort: 4444 secure: true - exposure: internal + exposure: public protocol: http attributes: type: ide diff --git a/samples/plugins/web-terminal-dev.yaml b/samples/plugins/web-terminal-dev.yaml index f796e696b..bbd37e816 100644 --- a/samples/plugins/web-terminal-dev.yaml +++ b/samples/plugins/web-terminal-dev.yaml @@ -17,7 +17,7 @@ spec: - name: web-terminal targetPort: 4444 secure: true - exposure: internal + exposure: public protocol: http attributes: type: ide From 095e0b26eae1b7ffcf9fe418197b5fbfc0ca5bcb Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Thu, 4 Feb 2021 15:42:42 -0500 Subject: [PATCH 4/9] Add defaulting for container component in Web Terminals Re-implement defaulting functionality for web terminal devworkspaces; applies a default container component to the DevWorkspace if a) it imports the web-terminal plugin, and b) the DevWorkspace does not contain any container components The default container can be configured via the property devworkspace.default_dockerimage.redhat-developer.web-terminal if left empty, a default container is provisioned. Signed-off-by: Angel Misevski --- .../workspace/devworkspace_controller.go | 1 - pkg/config/cmd_terminal.go | 18 ++--- pkg/library/flatten/flatten.go | 7 ++ .../flatten/web_terminal/web_terminal.go | 71 +++++++++++++++++++ 4 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 pkg/library/flatten/web_terminal/web_terminal.go diff --git a/controllers/workspace/devworkspace_controller.go b/controllers/workspace/devworkspace_controller.go index 69c2a5ef7..bab73acf4 100644 --- a/controllers/workspace/devworkspace_controller.go +++ b/controllers/workspace/devworkspace_controller.go @@ -175,7 +175,6 @@ func (r *DevWorkspaceReconciler) Reconcile(req ctrl.Request) (reconcileResult ct timing.SetTime(timingInfo, timing.ComponentsCreated) // TODO#185 : Temporarily do devfile flattening in main reconcile loop; this should be moved to a subcontroller. - // TODO#185 : Implement defaulting container component for Web Terminals for compatibility flattenHelpers := flatten.ResolverTools{ InstanceNamespace: workspace.Namespace, Context: ctx, diff --git a/pkg/config/cmd_terminal.go b/pkg/config/cmd_terminal.go index ee64ff028..c1361307d 100644 --- a/pkg/config/cmd_terminal.go +++ b/pkg/config/cmd_terminal.go @@ -30,8 +30,9 @@ const ( ) func (wc *ControllerConfig) GetDefaultTerminalDockerimage() (*devworkspace.Component, error) { - defaultDockerimageYaml := wc.GetProperty(defaultTerminalDockerimageProperty) - if defaultDockerimageYaml == nil { + mountSources := false + defaultContainerYaml := wc.GetProperty(defaultTerminalDockerimageProperty) + if defaultContainerYaml == nil { webTerminalImage := images.GetWebTerminalToolingImage() if webTerminalImage == "" { return nil, fmt.Errorf("cannot determine default image for web terminal: environment variable is unset") @@ -40,9 +41,10 @@ func (wc *ControllerConfig) GetDefaultTerminalDockerimage() (*devworkspace.Compo defaultTerminalDockerimage.Name = "dev" defaultTerminalDockerimage.Container = &devworkspace.ContainerComponent{ Container: devworkspace.Container{ - Image: webTerminalImage, - Args: []string{"tail", "-f", "/dev/null"}, - MemoryLimit: "256Mi", + Image: webTerminalImage, + Args: []string{"tail", "-f", "/dev/null"}, + MemoryLimit: "256Mi", + MountSources: &mountSources, Env: []devworkspace.EnvVar{ { Name: "PS1", @@ -57,11 +59,11 @@ func (wc *ControllerConfig) GetDefaultTerminalDockerimage() (*devworkspace.Compo return defaultTerminalDockerimage, nil } - var dockerimage devworkspace.Component - if err := yaml.Unmarshal([]byte(*defaultDockerimageYaml), &dockerimage); err != nil { + var defaultContainer devworkspace.Component + if err := yaml.Unmarshal([]byte(*defaultContainerYaml), &defaultContainer); err != nil { return nil, fmt.Errorf( "%s is configured with invalid container component. Error: %s", defaultTerminalDockerimageProperty, err) } - return &dockerimage, nil + return &defaultContainer, nil } diff --git a/pkg/library/flatten/flatten.go b/pkg/library/flatten/flatten.go index f07119516..786aaa430 100644 --- a/pkg/library/flatten/flatten.go +++ b/pkg/library/flatten/flatten.go @@ -16,6 +16,8 @@ import ( "context" "fmt" + "github.com/devfile/devworkspace-operator/pkg/library/flatten/web_terminal" + registry "github.com/devfile/devworkspace-operator/pkg/library/flatten/internal_registry" devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" @@ -51,6 +53,11 @@ func (t tempOverrides) GetToplevelLists() devworkspace.TopLevelLists { // - Implement flattening for DevWorkspace parents // - Implement plugin references by ID and URI func ResolveDevWorkspace(workspace devworkspace.DevWorkspaceTemplateSpec, tooling ResolverTools) (*devworkspace.DevWorkspaceTemplateSpec, error) { + // Web terminals get default container components if they do not specify one + if err := web_terminal.AddDefaultContainerIfNeeded(&workspace); err != nil { + return nil, err + } + resolutionCtx := &resolutionContextTree{} resolvedDW, err := recursiveResolve(workspace, tooling, resolutionCtx) if err != nil { diff --git a/pkg/library/flatten/web_terminal/web_terminal.go b/pkg/library/flatten/web_terminal/web_terminal.go new file mode 100644 index 000000000..4fa495007 --- /dev/null +++ b/pkg/library/flatten/web_terminal/web_terminal.go @@ -0,0 +1,71 @@ +// +// Copyright (c) 2019-2021 Red Hat, Inc. +// This program and the accompanying materials are made +// available under the terms of the Eclipse Public License 2.0 +// which is available at https://www.eclipse.org/legal/epl-2.0/ +// +// SPDX-License-Identifier: EPL-2.0 +// +// Contributors: +// Red Hat, Inc. - initial API and implementation +// + +package web_terminal + +import ( + "fmt" + "strings" + + devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" + "github.com/devfile/devworkspace-operator/pkg/config" +) + +const webTerminalPluginName = "web-terminal" + +var webTerminalPublishers = []string{ + "redhat-developer/web-terminal/", + "redhat-developer/web-terminal-dev/", +} + +func IsWebTerminalDevWorkspace(workspace *devworkspace.DevWorkspaceTemplateSpec) bool { + for _, component := range workspace.Components { + if component.Plugin != nil && pluginIsWebTerminal(component.Plugin) { + return true + } + } + return false +} + +func AddDefaultContainerIfNeeded(workspace *devworkspace.DevWorkspaceTemplateSpec) error { + if !IsWebTerminalDevWorkspace(workspace) || hasContainerComponent(workspace) { + return nil + } + defaultComponent, err := config.ControllerCfg.GetDefaultTerminalDockerimage() + if err != nil { + return fmt.Errorf("failed to get default container component for web terminal: %w", err) + } + workspace.Components = append(workspace.Components, *defaultComponent) + return nil +} + +func pluginIsWebTerminal(plugin *devworkspace.PluginComponent) bool { + // Check that ID matches web terminal publishers + for _, publisher := range webTerminalPublishers { + if strings.HasPrefix(plugin.Id, publisher) { + return true + } + } + if plugin.Kubernetes != nil && plugin.Kubernetes.Name == webTerminalPluginName { + return true + } + return false +} + +func hasContainerComponent(workspace *devworkspace.DevWorkspaceTemplateSpec) bool { + for _, component := range workspace.Components { + if component.Container != nil { + return true + } + } + return false +} From 16252c7f7ccb560fc779165a821ed3dc0b4c7bd1 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Thu, 4 Feb 2021 16:55:03 -0500 Subject: [PATCH 5/9] Add test cases for internal-registry and default web terminal container Signed-off-by: Angel Misevski --- .../workspace/devworkspace_controller.go | 3 + pkg/library/flatten/flatten.go | 12 ++- pkg/library/flatten/flatten_test.go | 84 +++++++++++++++++-- .../flatten/internal_registry/registry.go | 16 +++- .../defaulting-web-terminal-component.yaml | 34 ++++++++ ...or_failed-read-from-internal-registry.yaml | 14 ++++ ...l-and-plugin-not-in-internal-registry.yaml | 11 +++ .../plugin-in-internal-registry.yaml | 28 +++++++ .../{ => k8s-ref}/already-flattened.yaml | 0 .../{ => k8s-ref}/error_bad-plugin-merge.yaml | 0 .../error_conflicting-merge.yaml | 0 .../error_error-when-retrieving-plugin.yaml | 0 .../{ => k8s-ref}/error_has-parent.yaml | 0 .../{ => k8s-ref}/error_plugin-not-found.yaml | 0 .../error_plugin-references-self.yml | 0 .../error_plugins-have-cycle.yml | 0 .../{ => k8s-ref}/nodejs-workspace.yaml | 0 .../web-terminal-with-plugin.yaml | 0 18 files changed, 186 insertions(+), 16 deletions(-) create mode 100644 pkg/library/flatten/testdata/internal-registry/defaulting-web-terminal-component.yaml create mode 100644 pkg/library/flatten/testdata/internal-registry/error_failed-read-from-internal-registry.yaml create mode 100644 pkg/library/flatten/testdata/internal-registry/error_no-registryurl-and-plugin-not-in-internal-registry.yaml create mode 100644 pkg/library/flatten/testdata/internal-registry/plugin-in-internal-registry.yaml rename pkg/library/flatten/testdata/{ => k8s-ref}/already-flattened.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_bad-plugin-merge.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_conflicting-merge.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_error-when-retrieving-plugin.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_has-parent.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_plugin-not-found.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_plugin-references-self.yml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/error_plugins-have-cycle.yml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/nodejs-workspace.yaml (100%) rename pkg/library/flatten/testdata/{ => k8s-ref}/web-terminal-with-plugin.yaml (100%) diff --git a/controllers/workspace/devworkspace_controller.go b/controllers/workspace/devworkspace_controller.go index bab73acf4..65b837381 100644 --- a/controllers/workspace/devworkspace_controller.go +++ b/controllers/workspace/devworkspace_controller.go @@ -19,6 +19,8 @@ import ( "strings" "time" + registry "github.com/devfile/devworkspace-operator/pkg/library/flatten/internal_registry" + "github.com/devfile/devworkspace-operator/pkg/library/flatten" containerlib "github.com/devfile/devworkspace-operator/pkg/library/container" @@ -179,6 +181,7 @@ func (r *DevWorkspaceReconciler) Reconcile(req ctrl.Request) (reconcileResult ct InstanceNamespace: workspace.Namespace, Context: ctx, K8sClient: r.Client, + InternalRegistry: ®istry.InternalRegistryImpl{}, } flattenedWorkspace, err := flatten.ResolveDevWorkspace(workspace.Spec.Template, flattenHelpers) if err != nil { diff --git a/pkg/library/flatten/flatten.go b/pkg/library/flatten/flatten.go index 786aaa430..184295c18 100644 --- a/pkg/library/flatten/flatten.go +++ b/pkg/library/flatten/flatten.go @@ -31,6 +31,7 @@ type ResolverTools struct { InstanceNamespace string Context context.Context K8sClient client.Client + InternalRegistry registry.InternalRegistry } // TODO: temp workaround for panic in devfile/api when using plugin overrides. See: https://github.com/devfile/api/issues/296 @@ -184,14 +185,17 @@ func resolvePluginComponentByKubernetesReference( func resolvePluginComponentById( name string, plugin *devworkspace.PluginComponent, - _ ResolverTools) (resolvedPlugin *devworkspace.DevWorkspaceTemplateSpec, pluginLabels map[string]string, err error) { + tools ResolverTools) (resolvedPlugin *devworkspace.DevWorkspaceTemplateSpec, pluginLabels map[string]string, err error) { // Check internal registry for plugins that do not specify a registry if plugin.RegistryUrl == "" { - if !registry.IsInInternalRegistry(plugin.Id) { - return nil, nil, fmt.Errorf("plugin for component %s does not specify a registry and is not present in internal registry", name) + if tools.InternalRegistry == nil { + return nil, nil, fmt.Errorf("plugin %s does not specify a registryUrl and no internal registry is configured", name) } - pluginDWT, err := registry.ReadPluginFromInternalRegistry(plugin.Id) + if !tools.InternalRegistry.IsInInternalRegistry(plugin.Id) { + return nil, nil, fmt.Errorf("plugin for component %s does not specify a registry and is not present in the internal registry", name) + } + pluginDWT, err := tools.InternalRegistry.ReadPluginFromInternalRegistry(plugin.Id) if err != nil { return nil, nil, fmt.Errorf("failed to read plugin for component %s from internal registry: %w", name, err) } diff --git a/pkg/library/flatten/flatten_test.go b/pkg/library/flatten/flatten_test.go index 1f87f6649..88a2e02ed 100644 --- a/pkg/library/flatten/flatten_test.go +++ b/pkg/library/flatten/flatten_test.go @@ -21,6 +21,9 @@ import ( "strings" "testing" + "github.com/devfile/devworkspace-operator/pkg/config" + corev1 "k8s.io/api/core/v1" + "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/assert" @@ -44,6 +47,21 @@ var workspaceTemplateDiffOpts = cmp.Options{ cmpopts.IgnoreFields(devworkspace.WorkspaceEvents{}, "PostStart", "PreStop", "PostStop"), } +var testControllerCfg = &corev1.ConfigMap{ + Data: map[string]string{ + "devworkspace.default_dockerimage.redhat-developer.web-terminal": ` +name: default-web-terminal-tooling +container: + name: default-web-terminal-tooling-container + image: test-image +`, + }, +} + +func setupControllerCfg() { + config.SetupConfigForTesting(testControllerCfg) +} + type testCase struct { Name string `json:"name"` Input testInput `json:"input"` @@ -93,9 +111,29 @@ func (client *fakeK8sClient) Get(_ context.Context, namespacedName client.Object return fmt.Errorf("test does not define an entry for plugin %s", namespacedName.Name) } -func loadTestCaseOrPanic(t *testing.T, testFilename string) testCase { - testPath := filepath.Join("./testdata", testFilename) - bytes, err := ioutil.ReadFile(testPath) +type fakeInternalRegistry struct { + Plugins map[string]devworkspace.DevWorkspaceTemplate + Errors map[string]testPluginError +} + +func (reg *fakeInternalRegistry) IsInInternalRegistry(pluginID string) bool { + _, pluginOk := reg.Plugins[pluginID] + _, errOk := reg.Errors[pluginID] + return pluginOk || errOk +} + +func (reg *fakeInternalRegistry) ReadPluginFromInternalRegistry(pluginID string) (*devworkspace.DevWorkspaceTemplate, error) { + if plugin, ok := reg.Plugins[pluginID]; ok { + return &plugin, nil + } + if err, ok := reg.Errors[pluginID]; ok { + return nil, errors.New(err.Message) + } + return nil, fmt.Errorf("test does not define entry for plugin %s", pluginID) +} + +func loadTestCaseOrPanic(t *testing.T, testFilepath string) testCase { + bytes, err := ioutil.ReadFile(testFilepath) if err != nil { t.Fatal(err) } @@ -107,8 +145,8 @@ func loadTestCaseOrPanic(t *testing.T, testFilename string) testCase { return test } -func loadAllTestsOrPanic(t *testing.T) []testCase { - files, err := ioutil.ReadDir("./testdata") +func loadAllTestsOrPanic(t *testing.T, fromDir string) []testCase { + files, err := ioutil.ReadDir(fromDir) if err != nil { t.Fatal(err) } @@ -117,13 +155,13 @@ func loadAllTestsOrPanic(t *testing.T) []testCase { if file.IsDir() { continue } - tests = append(tests, loadTestCaseOrPanic(t, file.Name())) + tests = append(tests, loadTestCaseOrPanic(t, filepath.Join(fromDir, file.Name()))) } return tests } -func TestResolveDevWorkspace(t *testing.T) { - tests := loadAllTestsOrPanic(t) +func TestResolveDevWorkspaceKubernetesReference(t *testing.T) { + tests := loadAllTestsOrPanic(t, "testdata/k8s-ref") for _, tt := range tests { t.Run(tt.Name, func(t *testing.T) { // sanity check: input defines components @@ -150,3 +188,33 @@ func TestResolveDevWorkspace(t *testing.T) { }) } } + +func TestResolveDevWorkspaceInternalRegistry(t *testing.T) { + tests := loadAllTestsOrPanic(t, "testdata/internal-registry") + setupControllerCfg() + for _, tt := range tests { + t.Run(tt.Name, func(t *testing.T) { + // sanity check: input defines components + assert.True(t, len(tt.Input.Workspace.Components) > 0, "Test case defines workspace with no components") + testRegistry := &fakeInternalRegistry{ + Plugins: tt.Input.Plugins, + Errors: tt.Input.Errors, + } + testResolverTools := ResolverTools{ + Context: context.Background(), + InternalRegistry: testRegistry, + } + outputWorkspace, err := ResolveDevWorkspace(tt.Input.Workspace, testResolverTools) + if tt.Output.ErrRegexp != nil && assert.Error(t, err) { + assert.Regexp(t, *tt.Output.ErrRegexp, err.Error(), "Error message should match") + } else { + if !assert.NoError(t, err, "Should not return error") { + return + } + assert.Truef(t, cmp.Equal(tt.Output.Workspace, outputWorkspace, workspaceTemplateDiffOpts), + "Workspace should match expected output:\n%s", + cmp.Diff(tt.Output.Workspace, outputWorkspace, workspaceTemplateDiffOpts)) + } + }) + } +} diff --git a/pkg/library/flatten/internal_registry/registry.go b/pkg/library/flatten/internal_registry/registry.go index 6c39e4499..74f36c993 100644 --- a/pkg/library/flatten/internal_registry/registry.go +++ b/pkg/library/flatten/internal_registry/registry.go @@ -32,12 +32,16 @@ const ( var log = logf.Log.WithName("registry") -func getPluginPath(pluginID string) string { - return filepath.Join(RegistryDirectory, pluginID, "devworkspacetemplate.yaml") +// InternalRegistry is an abstraction over internal registry functions to allow for easier testing +type InternalRegistry interface { + IsInInternalRegistry(pluginID string) bool + ReadPluginFromInternalRegistry(pluginID string) (*devworkspace.DevWorkspaceTemplate, error) } +type InternalRegistryImpl struct{} + // IsInInternalRegistry checks if pluginID is in the internal registry -func IsInInternalRegistry(pluginID string) bool { +func (_ *InternalRegistryImpl) IsInInternalRegistry(pluginID string) bool { if _, err := os.Stat(getPluginPath(pluginID)); err != nil { if os.IsNotExist(err) { log.Info(fmt.Sprintf("Could not find %s in the internal registry", pluginID)) @@ -47,7 +51,7 @@ func IsInInternalRegistry(pluginID string) bool { return true } -func ReadPluginFromInternalRegistry(pluginID string) (*devworkspace.DevWorkspaceTemplate, error) { +func (_ *InternalRegistryImpl) ReadPluginFromInternalRegistry(pluginID string) (*devworkspace.DevWorkspaceTemplate, error) { yamlBytes, err := ioutil.ReadFile(getPluginPath(pluginID)) if err != nil { return nil, err @@ -62,3 +66,7 @@ func ReadPluginFromInternalRegistry(pluginID string) (*devworkspace.DevWorkspace } return resolvedPlugin, nil } + +func getPluginPath(pluginID string) string { + return filepath.Join(RegistryDirectory, pluginID, "devworkspacetemplate.yaml") +} diff --git a/pkg/library/flatten/testdata/internal-registry/defaulting-web-terminal-component.yaml b/pkg/library/flatten/testdata/internal-registry/defaulting-web-terminal-component.yaml new file mode 100644 index 000000000..6ee68c4af --- /dev/null +++ b/pkg/library/flatten/testdata/internal-registry/defaulting-web-terminal-component.yaml @@ -0,0 +1,34 @@ +name: "Defaulting web-terminal container component" + +input: + workspace: + components: + - name: web-terminal + plugin: + id: redhat-developer/web-terminal/4.5.0 + + plugins: + redhat-developer/web-terminal/4.5.0: + kind: DevWorkspaceTemplate + apiVersion: workspace.devfile.io/v1alpha2 + metadata: + name: web-terminal-plugin + spec: + components: + - name: web-terminal-plugin + container: + name: test-container + image: test-image + +output: + workspace: + components: + - name: web-terminal-plugin + container: + name: test-container + image: test-image + # Note the default container is defined in the test config + - name: default-web-terminal-tooling + container: + name: default-web-terminal-tooling-container + image: test-image diff --git a/pkg/library/flatten/testdata/internal-registry/error_failed-read-from-internal-registry.yaml b/pkg/library/flatten/testdata/internal-registry/error_failed-read-from-internal-registry.yaml new file mode 100644 index 000000000..22c0a4da6 --- /dev/null +++ b/pkg/library/flatten/testdata/internal-registry/error_failed-read-from-internal-registry.yaml @@ -0,0 +1,14 @@ +name: "plugin can't be read from internal registry" + +input: + workspace: + components: + - name: test-plugin + plugin: + id: my/test/plugin + errors: + my/test/plugin: + message: "plugin not found" + +output: + errRegexp: "failed to read plugin for component test-plugin from internal registry" diff --git a/pkg/library/flatten/testdata/internal-registry/error_no-registryurl-and-plugin-not-in-internal-registry.yaml b/pkg/library/flatten/testdata/internal-registry/error_no-registryurl-and-plugin-not-in-internal-registry.yaml new file mode 100644 index 000000000..75bb50d90 --- /dev/null +++ b/pkg/library/flatten/testdata/internal-registry/error_no-registryurl-and-plugin-not-in-internal-registry.yaml @@ -0,0 +1,11 @@ +name: "plugin doesn't specify registryURL and isn't in the internal registry" + +input: + workspace: + components: + - name: test-plugin + plugin: + id: my/test/plugin + +output: + errRegexp: "plugin for component test-plugin does not specify a registry and is not present in the internal registry" diff --git a/pkg/library/flatten/testdata/internal-registry/plugin-in-internal-registry.yaml b/pkg/library/flatten/testdata/internal-registry/plugin-in-internal-registry.yaml new file mode 100644 index 000000000..36e9e299e --- /dev/null +++ b/pkg/library/flatten/testdata/internal-registry/plugin-in-internal-registry.yaml @@ -0,0 +1,28 @@ +name: "DevWorkspace references plugin from internal registry" + +input: + workspace: + components: + - name: test-plugin + plugin: + id: my/test/plugin + plugins: + my/test/plugin: + kind: DevWorkspaceTemplate + apiVersion: workspace.devfile.io/v1alpha2 + metadata: + name: plugin-a + spec: + components: + - name: plugin-a + container: + name: test-container + image: test-image + +output: + workspace: + components: + - name: plugin-a + container: + name: test-container + image: test-image diff --git a/pkg/library/flatten/testdata/already-flattened.yaml b/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml similarity index 100% rename from pkg/library/flatten/testdata/already-flattened.yaml rename to pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml diff --git a/pkg/library/flatten/testdata/error_bad-plugin-merge.yaml b/pkg/library/flatten/testdata/k8s-ref/error_bad-plugin-merge.yaml similarity index 100% rename from pkg/library/flatten/testdata/error_bad-plugin-merge.yaml rename to pkg/library/flatten/testdata/k8s-ref/error_bad-plugin-merge.yaml diff --git a/pkg/library/flatten/testdata/error_conflicting-merge.yaml b/pkg/library/flatten/testdata/k8s-ref/error_conflicting-merge.yaml similarity index 100% rename from pkg/library/flatten/testdata/error_conflicting-merge.yaml rename to pkg/library/flatten/testdata/k8s-ref/error_conflicting-merge.yaml diff --git a/pkg/library/flatten/testdata/error_error-when-retrieving-plugin.yaml b/pkg/library/flatten/testdata/k8s-ref/error_error-when-retrieving-plugin.yaml similarity index 100% rename from pkg/library/flatten/testdata/error_error-when-retrieving-plugin.yaml rename to pkg/library/flatten/testdata/k8s-ref/error_error-when-retrieving-plugin.yaml diff --git a/pkg/library/flatten/testdata/error_has-parent.yaml b/pkg/library/flatten/testdata/k8s-ref/error_has-parent.yaml similarity index 100% rename from pkg/library/flatten/testdata/error_has-parent.yaml rename to pkg/library/flatten/testdata/k8s-ref/error_has-parent.yaml diff --git a/pkg/library/flatten/testdata/error_plugin-not-found.yaml b/pkg/library/flatten/testdata/k8s-ref/error_plugin-not-found.yaml similarity index 100% rename from pkg/library/flatten/testdata/error_plugin-not-found.yaml rename to pkg/library/flatten/testdata/k8s-ref/error_plugin-not-found.yaml diff --git a/pkg/library/flatten/testdata/error_plugin-references-self.yml b/pkg/library/flatten/testdata/k8s-ref/error_plugin-references-self.yml similarity index 100% rename from pkg/library/flatten/testdata/error_plugin-references-self.yml rename to pkg/library/flatten/testdata/k8s-ref/error_plugin-references-self.yml diff --git a/pkg/library/flatten/testdata/error_plugins-have-cycle.yml b/pkg/library/flatten/testdata/k8s-ref/error_plugins-have-cycle.yml similarity index 100% rename from pkg/library/flatten/testdata/error_plugins-have-cycle.yml rename to pkg/library/flatten/testdata/k8s-ref/error_plugins-have-cycle.yml diff --git a/pkg/library/flatten/testdata/nodejs-workspace.yaml b/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml similarity index 100% rename from pkg/library/flatten/testdata/nodejs-workspace.yaml rename to pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml diff --git a/pkg/library/flatten/testdata/web-terminal-with-plugin.yaml b/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml similarity index 100% rename from pkg/library/flatten/testdata/web-terminal-with-plugin.yaml rename to pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml From f137f2e9fae6729b0ff33af5518de4050c048191 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Thu, 4 Feb 2021 17:00:33 -0500 Subject: [PATCH 6/9] Re-enable default web terminal devworkspace in e2e test Signed-off-by: Angel Misevski --- test/e2e/pkg/tests/devworkspaces_tests.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/pkg/tests/devworkspaces_tests.go b/test/e2e/pkg/tests/devworkspaces_tests.go index 3bdc07318..9c7afd16a 100644 --- a/test/e2e/pkg/tests/devworkspaces_tests.go +++ b/test/e2e/pkg/tests/devworkspaces_tests.go @@ -40,8 +40,7 @@ var _ = ginkgo.Describe("[Create OpenShift Web Terminal Workspace]", func() { }) ginkgo.It("Add OpenShift web terminal to cluster and wait running status", func() { - // TODO#185 : Temporarily use pre-flattened devworkspace until flattening is re-implemented - commandResult, err := config.DevK8sClient.OcApplyWorkspace(config.WorkspaceNamespace, "samples/flattened_web-terminal.yaml") + commandResult, err := config.DevK8sClient.OcApplyWorkspace(config.WorkspaceNamespace, "samples/web-terminal.yaml") if err != nil { ginkgo.Fail(fmt.Sprintf("Failed to create OpenShift web terminal workspace: %s %s", err.Error(), commandResult)) return From 5b05ab598fecc3550ec634e81e107b80d2a39258 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Fri, 5 Feb 2021 12:19:57 -0500 Subject: [PATCH 7/9] Use DEVWORKSPACE_ID instead of CHE_WORKSPACE_ID in all samples Signed-off-by: Angel Misevski --- .../eclipse/cloud-shell/nightly/devworkspacetemplate.yaml | 2 +- .../web-terminal-dev/4.5.0/devworkspacetemplate.yaml | 2 +- .../web-terminal-dev/nightly/devworkspacetemplate.yaml | 2 +- .../web-terminal/4.5.0/devworkspacetemplate.yaml | 2 +- .../web-terminal/nightly/devworkspacetemplate.yaml | 2 +- pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml | 4 ++-- pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml | 4 ++-- .../flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml | 4 ++-- samples/flattened_theia-next.yaml | 2 +- samples/flattened_theia-nodejs.yaml | 2 +- samples/flattened_web-terminal-dev.yaml | 2 +- samples/flattened_web-terminal.yaml | 2 +- samples/plugins/machine-exec.yaml | 2 +- samples/plugins/web-terminal-dev.yaml | 2 +- samples/plugins/web-terminal.yaml | 2 +- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml b/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml index 22560c35b..d182a0190 100644 --- a/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml +++ b/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml @@ -11,7 +11,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--static", "/cloud-shell"] endpoints: diff --git a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml index 6950e284e..66c4a55e4 100644 --- a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml @@ -10,7 +10,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token"] endpoints: - name: web-terminal diff --git a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml index 174e91acc..9b4a11640 100644 --- a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml @@ -10,7 +10,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token"] endpoints: - name: web-terminal diff --git a/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml index 21a4697f0..84d3d1cda 100644 --- a/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml @@ -10,7 +10,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: diff --git a/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml index f46df38b8..d0f6f979c 100644 --- a/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml @@ -10,7 +10,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: diff --git a/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml b/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml index b4eaedf85..4f0aa8e66 100644 --- a/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml +++ b/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml @@ -19,7 +19,7 @@ input: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: @@ -54,7 +54,7 @@ output: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: diff --git a/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml b/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml index 33269095c..42d7a4bb2 100644 --- a/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml +++ b/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml @@ -227,7 +227,7 @@ input: - '--url' - '0.0.0.0:4444' - '--pod-selector' - - controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID) + - controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID) endpoints: - name: "che-mach-exec" exposure: public @@ -408,7 +408,7 @@ output: - '--url' - '0.0.0.0:4444' - '--pod-selector' - - controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID) + - controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID) endpoints: - name: "che-mach-exec" exposure: public diff --git a/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml b/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml index a914b642a..f40529fce 100644 --- a/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml +++ b/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml @@ -32,7 +32,7 @@ input: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: @@ -65,7 +65,7 @@ output: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: diff --git a/samples/flattened_theia-next.yaml b/samples/flattened_theia-next.yaml index f2637e6cf..43b970281 100644 --- a/samples/flattened_theia-next.yaml +++ b/samples/flattened_theia-next.yaml @@ -24,7 +24,7 @@ spec: - '--url' - '0.0.0.0:4444' - '--pod-selector' - - controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID) + - controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID) endpoints: - name: "che-mach-exec" exposure: public diff --git a/samples/flattened_theia-nodejs.yaml b/samples/flattened_theia-nodejs.yaml index 51a344382..2d8376e87 100644 --- a/samples/flattened_theia-nodejs.yaml +++ b/samples/flattened_theia-nodejs.yaml @@ -139,7 +139,7 @@ spec: - '--url' - '0.0.0.0:4444' - '--pod-selector' - - controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID) + - controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID) endpoints: - name: "che-mach-exec" exposure: public diff --git a/samples/flattened_web-terminal-dev.yaml b/samples/flattened_web-terminal-dev.yaml index 04094e33c..e01fe47d4 100644 --- a/samples/flattened_web-terminal-dev.yaml +++ b/samples/flattened_web-terminal-dev.yaml @@ -29,7 +29,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token"] endpoints: - name: web-terminal diff --git a/samples/flattened_web-terminal.yaml b/samples/flattened_web-terminal.yaml index 00e8db551..bec4f4ff0 100644 --- a/samples/flattened_web-terminal.yaml +++ b/samples/flattened_web-terminal.yaml @@ -29,7 +29,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: diff --git a/samples/plugins/machine-exec.yaml b/samples/plugins/machine-exec.yaml index 53ca3b432..25082f135 100644 --- a/samples/plugins/machine-exec.yaml +++ b/samples/plugins/machine-exec.yaml @@ -16,7 +16,7 @@ spec: - '--url' - '0.0.0.0:4444' - '--pod-selector' - - controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID) + - controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID) endpoints: - name: "che-mach-exec" exposure: public diff --git a/samples/plugins/web-terminal-dev.yaml b/samples/plugins/web-terminal-dev.yaml index bbd37e816..94fdb2646 100644 --- a/samples/plugins/web-terminal-dev.yaml +++ b/samples/plugins/web-terminal-dev.yaml @@ -11,7 +11,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token"] endpoints: - name: web-terminal diff --git a/samples/plugins/web-terminal.yaml b/samples/plugins/web-terminal.yaml index c17879e21..993669d92 100644 --- a/samples/plugins/web-terminal.yaml +++ b/samples/plugins/web-terminal.yaml @@ -11,7 +11,7 @@ spec: command: ["/go/bin/che-machine-exec", "--authenticated-user-id", "$(DEVWORKSPACE_CREATOR)", "--idle-timeout", "$(DEVWORKSPACE_IDLE_TIMEOUT)", - "--pod-selector", "controller.devfile.io/workspace_id=$(CHE_WORKSPACE_ID)", + "--pod-selector", "controller.devfile.io/workspace_id=$(DEVWORKSPACE_ID)", "--use-bearer-token", "--use-tls"] endpoints: From 4d4c82a303bb742a00fcd8de16972cea553ed6cf Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Fri, 5 Feb 2021 12:21:12 -0500 Subject: [PATCH 8/9] Remove cookiesAuthEnabled attribute from all endpoints Signed-off-by: Angel Misevski --- .../eclipse/cloud-shell/nightly/devworkspacetemplate.yaml | 1 - .../web-terminal-dev/4.5.0/devworkspacetemplate.yaml | 1 - .../web-terminal-dev/nightly/devworkspacetemplate.yaml | 1 - .../web-terminal/4.5.0/devworkspacetemplate.yaml | 1 - .../web-terminal/nightly/devworkspacetemplate.yaml | 1 - pkg/library/container/testdata/converts-all-fields.yaml | 2 -- pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml | 2 -- pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml | 6 ------ .../flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml | 2 -- samples/flattened_theia-next.yaml | 3 --- samples/flattened_theia-nodejs.yaml | 3 --- samples/flattened_web-terminal-dev.yaml | 1 - samples/flattened_web-terminal.yaml | 1 - samples/plugins/machine-exec.yaml | 1 - samples/plugins/theia-next.yaml | 2 -- samples/plugins/web-terminal-dev.yaml | 1 - samples/plugins/web-terminal.yaml | 1 - 17 files changed, 30 deletions(-) diff --git a/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml b/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml index d182a0190..b60698d08 100644 --- a/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml +++ b/internal-registry/eclipse/cloud-shell/nightly/devworkspacetemplate.yaml @@ -23,4 +23,3 @@ spec: path: /static/ attributes: type: ide - cookiesAuthEnabled: "true" diff --git a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml index 66c4a55e4..8979785a2 100644 --- a/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal-dev/4.5.0/devworkspacetemplate.yaml @@ -20,7 +20,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" mountSources: false env: - name: USE_BEARER_TOKEN diff --git a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml index 9b4a11640..95112d948 100644 --- a/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal-dev/nightly/devworkspacetemplate.yaml @@ -20,7 +20,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" mountSources: false env: - name: USE_BEARER_TOKEN diff --git a/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml index 84d3d1cda..2e52bb97c 100644 --- a/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal/4.5.0/devworkspacetemplate.yaml @@ -21,7 +21,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" mountSources: false env: - name: USE_BEARER_TOKEN diff --git a/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml b/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml index d0f6f979c..cf1d0c933 100644 --- a/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml +++ b/internal-registry/redhat-developer/web-terminal/nightly/devworkspacetemplate.yaml @@ -21,7 +21,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" mountSources: false env: - name: USE_BEARER_TOKEN diff --git a/pkg/library/container/testdata/converts-all-fields.yaml b/pkg/library/container/testdata/converts-all-fields.yaml index f528af194..1579bc766 100644 --- a/pkg/library/container/testdata/converts-all-fields.yaml +++ b/pkg/library/container/testdata/converts-all-fields.yaml @@ -20,14 +20,12 @@ input: protocol: wss attributes: type: ide - cookiesAuthEnabled: "true" - name: "test-endpoint-2" exposure: public targetPort: 8080 secure: true protocol: http attributes: - cookiesAuthEnabled: "true" volumeMounts: - name: "test-volume1" path: "/test-volume1-path" diff --git a/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml b/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml index 4f0aa8e66..b5f1968eb 100644 --- a/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml +++ b/pkg/library/flatten/testdata/k8s-ref/already-flattened.yaml @@ -30,7 +30,6 @@ input: type: ide discoverable: "false" secure: "true" - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" @@ -65,7 +64,6 @@ output: type: ide discoverable: "false" secure: "true" - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" diff --git a/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml b/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml index 42d7a4bb2..03734d115 100644 --- a/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml +++ b/pkg/library/flatten/testdata/k8s-ref/nodejs-workspace.yaml @@ -165,7 +165,6 @@ input: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" - name: "webviews" exposure: public targetPort: 3100 @@ -173,7 +172,6 @@ input: secure: true attributes: type: webview - cookiesAuthEnabled: "true" unique: "true" - name: "theia-dev" exposure: public @@ -236,7 +234,6 @@ input: secure: true attributes: type: terminal - cookiesAuthEnabled: "true" vscode-typescript: kind: DevWorkspaceTemplate @@ -317,7 +314,6 @@ output: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" - name: "webviews" exposure: public targetPort: 3100 @@ -325,7 +321,6 @@ output: secure: true attributes: type: webview - cookiesAuthEnabled: "true" unique: "true" - name: "theia-dev" exposure: public @@ -417,7 +412,6 @@ output: secure: true attributes: type: terminal - cookiesAuthEnabled: "true" - name: sidecar-typescript attributes: "app.kubernetes.io/part-of": che-theia.eclipse.org diff --git a/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml b/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml index f40529fce..03b2f5ea5 100644 --- a/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml +++ b/pkg/library/flatten/testdata/k8s-ref/web-terminal-with-plugin.yaml @@ -43,7 +43,6 @@ input: type: ide discoverable: "false" secure: "true" - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" @@ -76,7 +75,6 @@ output: type: ide discoverable: "false" secure: "true" - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" diff --git a/samples/flattened_theia-next.yaml b/samples/flattened_theia-next.yaml index 43b970281..ea46a0985 100644 --- a/samples/flattened_theia-next.yaml +++ b/samples/flattened_theia-next.yaml @@ -33,7 +33,6 @@ spec: secure: true attributes: type: terminal - cookiesAuthEnabled: "true" ### END Contributions from machine-exec plugin ### ### BEGIN Contributions from Theia plugin ### - name: plugins @@ -115,7 +114,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" - name: "webviews" exposure: public targetPort: 3100 @@ -123,7 +121,6 @@ spec: secure: true attributes: type: webview - cookiesAuthEnabled: "true" unique: "true" - name: "theia-dev" exposure: public diff --git a/samples/flattened_theia-nodejs.yaml b/samples/flattened_theia-nodejs.yaml index 2d8376e87..ebc247e23 100644 --- a/samples/flattened_theia-nodejs.yaml +++ b/samples/flattened_theia-nodejs.yaml @@ -48,7 +48,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" - name: "webviews" exposure: public targetPort: 3100 @@ -56,7 +55,6 @@ spec: secure: true attributes: type: webview - cookiesAuthEnabled: "true" unique: "true" - name: "theia-dev" exposure: public @@ -148,7 +146,6 @@ spec: secure: true attributes: type: terminal - cookiesAuthEnabled: "true" - name: vscode-typescript attributes: "app.kubernetes.io/part-of": che-theia.eclipse.org diff --git a/samples/flattened_web-terminal-dev.yaml b/samples/flattened_web-terminal-dev.yaml index e01fe47d4..6788ec0c6 100644 --- a/samples/flattened_web-terminal-dev.yaml +++ b/samples/flattened_web-terminal-dev.yaml @@ -39,7 +39,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" diff --git a/samples/flattened_web-terminal.yaml b/samples/flattened_web-terminal.yaml index bec4f4ff0..a95661c1b 100644 --- a/samples/flattened_web-terminal.yaml +++ b/samples/flattened_web-terminal.yaml @@ -40,7 +40,6 @@ spec: exposure: internal attributes: type: ide - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" diff --git a/samples/plugins/machine-exec.yaml b/samples/plugins/machine-exec.yaml index 25082f135..3e8263a1e 100644 --- a/samples/plugins/machine-exec.yaml +++ b/samples/plugins/machine-exec.yaml @@ -25,4 +25,3 @@ spec: secure: true attributes: type: terminal - cookiesAuthEnabled: "true" diff --git a/samples/plugins/theia-next.yaml b/samples/plugins/theia-next.yaml index d56eb09c9..bb6b7197c 100644 --- a/samples/plugins/theia-next.yaml +++ b/samples/plugins/theia-next.yaml @@ -52,7 +52,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" - name: "webviews" exposure: public targetPort: 3100 @@ -60,7 +59,6 @@ spec: secure: true attributes: type: webview - cookiesAuthEnabled: "true" unique: "true" - name: "theia-dev" exposure: public diff --git a/samples/plugins/web-terminal-dev.yaml b/samples/plugins/web-terminal-dev.yaml index 94fdb2646..ae7a8eb4b 100644 --- a/samples/plugins/web-terminal-dev.yaml +++ b/samples/plugins/web-terminal-dev.yaml @@ -21,7 +21,6 @@ spec: protocol: http attributes: type: ide - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" diff --git a/samples/plugins/web-terminal.yaml b/samples/plugins/web-terminal.yaml index 993669d92..22cbd7731 100644 --- a/samples/plugins/web-terminal.yaml +++ b/samples/plugins/web-terminal.yaml @@ -22,7 +22,6 @@ spec: exposure: internal attributes: type: ide - cookiesAuthEnabled: "true" env: - name: USE_BEARER_TOKEN value: "true" From 70f961e092cb87e461fe504e6920110011aef3a6 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Mon, 8 Feb 2021 20:31:03 -0500 Subject: [PATCH 9/9] Re-add copying internal registry into container image Signed-off-by: Angel Misevski --- build/Dockerfile | 1 + build/rhel.Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/build/Dockerfile b/build/Dockerfile index 0ed6de630..f91bd5df6 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -31,6 +31,7 @@ FROM registry.access.redhat.com/ubi8-minimal:8.2-349 WORKDIR / COPY --from=builder /devworkspace-operator/_output/bin/devworkspace-controller /usr/local/bin/devworkspace-controller COPY --from=builder /devworkspace-operator/_output/bin/webhook-server /usr/local/bin/webhook-server +COPY --from=builder /devworkspace-operator/internal-registry internal-registry ENV USER_UID=1001 \ USER_NAME=devworkspace-controller diff --git a/build/rhel.Dockerfile b/build/rhel.Dockerfile index 749800ebc..daf3ded87 100644 --- a/build/rhel.Dockerfile +++ b/build/rhel.Dockerfile @@ -35,6 +35,7 @@ FROM registry.access.redhat.com/ubi8-minimal:8.2-349 WORKDIR / COPY --from=builder /devworkspace-operator/_output/bin/devworkspace-controller /usr/local/bin/devworkspace-controller COPY --from=builder /devworkspace-operator/_output/bin/webhook-server /usr/local/bin/webhook-server +COPY --from=builder /devworkspace-operator/internal-registry internal-registry USER nonroot:nonroot