Skip to content

Commit

Permalink
Add the WorkspaceExposure support
Browse files Browse the repository at this point in the history
Signed-off-by: David Festal <dfestal@redhat.com>
  • Loading branch information
davidfestal committed Dec 3, 2019
1 parent ead14e9 commit 94aa959
Show file tree
Hide file tree
Showing 33 changed files with 1,173 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import org.eclipse.che.api.workspace.server.devfile.exception.DevfileException;
import org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException;
import org.eclipse.che.api.workspace.server.devfile.validator.DevfileIntegrityValidator;
import org.eclipse.che.api.workspace.server.dto.DtoServerImpls.RuntimeDtoImpl;
import org.eclipse.che.api.workspace.server.DtoConverter;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl;
import org.eclipse.che.api.workspace.shared.dto.RuntimeDto;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
import org.eclipse.che.dto.server.DtoFactory;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -114,8 +117,13 @@ public WorkspaceDto getWorkspace(String workspaceId) {
try {
Map<String, Object> workspaceCustomResource = retrieveWorkspaceCustomResource();
if (workspaceCustomResource != null) {
Map<String, Object> workspaceAnnotations = asMap(asMap(workspaceCustomResource.get("metadata")).get("annotations"));
runtimeAnnotation = (String) workspaceAnnotations.get("org.eclipse.che.workspace/runtime");
Map<String, Object> status = asMap(workspaceCustomResource.get("status"));
if (status != null) {
Map<String, Object> additionalFields = asMap(status.get("additionalFields"));
if (additionalFields != null) {
runtimeAnnotation = (String) additionalFields.get("org.eclipse.che.workspace/runtime");
}
}
devfileYaml = readDevfileFromWorkspaceCustomResource(workspaceCustomResource);
}
} catch (ApiException e) {
Expand Down Expand Up @@ -177,9 +185,9 @@ DevfileImpl parseDevFile(String devfileYaml) throws JsonProcessingException, IOE
return devfileObj;
}

Runtime parseRuntime(String runtimeJson) throws JsonProcessingException, IOException {
RuntimeDto parseRuntime(String runtimeJson) throws JsonProcessingException, IOException {
LOGGER.info("Runtime content for workspace {}: {}", workspaceName, runtimeJson);
Runtime runtimeObj = jsonObjectMapper.treeToValue(yamlObjectMapper.readTree(runtimeJson), Runtime.class);
RuntimeDto runtimeObj = DtoFactory.getInstance().createDtoFromJson(runtimeJson, RuntimeDto.class);
return runtimeObj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.oracle.svm.core.annotate.AutomaticFeature;

import org.eclipse.che.api.workspace.server.devfile.PreferencesDeserializer;
import org.eclipse.che.api.workspace.server.dto.DtoServerImpls.WorkspaceDtoImpl;
import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeReflection;
Expand All @@ -24,7 +23,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
System.out.println("Eclipse Che compatibility layer for GraalVM native image generation");

registerFully(DevfileImpl.class);
registerFully(WorkspaceDtoImpl.class);
registerFully(org.eclipse.che.api.workspace.server.dto.DtoServerImpls.class);
registerFully(org.eclipse.che.api.core.server.dto.DtoServerImpls.class);
registerFully(PreferencesDeserializer.class);
}

Expand Down
13 changes: 13 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"github.com/che-incubator/che-workspace-crd-operator/pkg/controller/registry"
"context"
"flag"
"fmt"
Expand Down Expand Up @@ -106,6 +107,16 @@ func main() {
os.Exit(1)
}

log.Info("Expose Plugin Registry Port.")

// Create Service object to expose the embedded plugin registry.
_, err = registry.ExposeRegistryPort(ctx, 8080)
if err != nil {
log.Info(err.Error())
}

log.Info("Setting up Controllers.")

// Setup all Controllers
if err := controller.AddToManager(mgr); err != nil {
log.Error(err, "")
Expand All @@ -118,6 +129,8 @@ func main() {
os.Exit(1)
}

log.Info("Expose Metrics Port.")

// Create Service object to expose the metrics port.
_, err = metrics.ExposeMetricsPort(ctx, metricsPort)
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions deploy/crds/workspace_v1alpha1_workspace_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ kind: CustomResourceDefinition
metadata:
name: workspaces.workspace.che.eclipse.org
spec:
additionalPrinterColumns:
- JSONPath: .status.workspaceId
name: Id
type: string
- JSONPath: .spec.started
name: Enabled
type: boolean
- JSONPath: .status.phase
name: Status
type: string
- JSONPath: .status.ideUrl
name: Url
type: string
group: workspace.che.eclipse.org
names:
kind: Workspace
Expand Down Expand Up @@ -237,6 +250,11 @@ spec:
type: object
status:
properties:
additionalFields:
additionalProperties:
type: string
description: AdditionalInfo
type: object
conditions:
description: Condition keeps track of all cluster conditions, if they
exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ spec:
apiservicedefinitions: {}
customresourcedefinitions:
owned:
- kind: WorkspaceExposure
name: workspaceexposures.workspace.che.eclipse.org
version: v1alpha1
description: |
Defines how Eclipse Che 7 workspace will be made available
to the external network.
displayName: Che Workspace Exposure
- kind: Workspace
name: workspaces.workspace.che.eclipse.org
version: v1alpha1
Expand All @@ -153,7 +160,7 @@ spec:
displayName: Started
path: started
x-descriptors:
- 'urn:alm:descriptor:com.tectonic.ui:booleanSwitch'
- 'urn:alm:descriptor:com.tectonic.ui:booleanSwitch'
statusDescriptors:
- description: Workspace Status
displayName: Status
Expand Down Expand Up @@ -227,14 +234,24 @@ spec:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: che-workspace-crd-operator
image: quay.io/che-incubator/che-workspace-crd-controller:latest
image: quay.io/che-incubator/che-workspace-crd-controller:7.1.0
imagePullPolicy: Always
name: che-workspace-crd-operator
resources: {}
ports:
- containerPort: 8383
name: metrics
terminationMessagePolicy: FallbackToLogsOnError
- image: quay.io/che-incubator/che-workspace-crd-plugin-registry:7.1.0-offline
imagePullPolicy: Always
name: che-plugin-registry
ports:
- containerPort: 8080
resources:
limits:
memory: 256Mi
requests:
memory: 16Mi
serviceAccountName: che-workspace-crd-operator
clusterpermissions:
- rules:
Expand Down
65 changes: 36 additions & 29 deletions deploy/flatten/workspace_v1alpha1_workspace_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ kind: CustomResourceDefinition
metadata:
name: workspaces.workspace.che.eclipse.org
spec:
additionalPrinterColumns:
- JSONPath: .status.workspaceId
name: Id
type: string
- JSONPath: .spec.started
name: Enabled
type: boolean
- JSONPath: .status.phase
name: Status
type: string
- JSONPath: .status.ideUrl
name: Url
type: string
group: workspace.che.eclipse.org
names:
kind: Workspace
Expand Down Expand Up @@ -48,6 +61,14 @@ spec:
component:
description: The actual action command-line string
type: string
reference:
description: Working directory where the command should
be executed
type: string
referenceContent:
description: Working directory where the command should
be executed
type: string
type:
description: Describes component to which given action
relates
Expand All @@ -56,7 +77,6 @@ spec:
description: Describes action type
type: string
required:
- component
- type
type: object
type: array
Expand All @@ -79,6 +99,12 @@ spec:
locations
items:
properties:
alias:
description: Describes whether projects sources should be
mount to the component. `CHE_PROJECTS_ROOT`; environment
variable should contains a path where projects sources are
mount
type: string
args:
description: The command to run in the dockerimage component
instead of the default one provided in the image. Defaults
Expand All @@ -95,27 +121,8 @@ spec:
items:
properties:
attributes:
properties:
discoverable:
description: 'Identifies server as secure or non-secure.
Requests to secure servers will be authenticated
and must contain machine token - default: false'
type: boolean
path:
description: Defines protocol that should be used
for communication with endpoint. Is used for endpoint
URL evaluation"
type: string
protocol:
description: 'Identifies endpoint as accessible
by its name. - default: false'
type: string
public:
type: boolean
secure:
description: 'Identifies endpoint as workspace internally
or externally accessible - default: true'
type: boolean
additionalProperties:
type: string
type: object
name:
type: string
Expand Down Expand Up @@ -160,12 +167,6 @@ spec:
can also use the; power-of-two equivalents: Ei, Pi, Ti,
Gi, Mi, Ki'
type: boolean
name:
description: Describes whether projects sources should be
mount to the component. `CHE_PROJECTS_ROOT`; environment
variable should contains a path where projects sources are
mount
type: string
reference:
description: Specifies the docker image that should be used
for component
Expand Down Expand Up @@ -200,7 +201,6 @@ spec:
type: object
type: array
required:
- name
- type
type: object
type: array
Expand Down Expand Up @@ -240,6 +240,8 @@ spec:
required:
- components
type: object
exposureClass:
type: string
started:
type: boolean
required:
Expand All @@ -248,6 +250,11 @@ spec:
type: object
status:
properties:
additionalFields:
additionalProperties:
type: string
description: AdditionalInfo
type: object
conditions:
description: Condition keeps track of all cluster conditions, if they
exist.
Expand Down
Loading

0 comments on commit 94aa959

Please sign in to comment.