-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michal Vala <[email protected]>
- Loading branch information
Showing
57 changed files
with
3,468 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/PreviewUrl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2012-2018 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 org.eclipse.che.api.core.model.workspace.devfile; | ||
|
||
/** | ||
* Preview url is optional parameter of {@link Command}. It is used to construct proper | ||
* service+ingress/route and to compose valid path to the application. Typical use-case for | ||
* applications that doesn't have UI on root path. Preview url also partially replaces endpoint, | ||
* that is not needed to expose the application. | ||
*/ | ||
public interface PreviewUrl { | ||
|
||
/** | ||
* {@code port} specifies where application, that is executed by command, listens. It is used to | ||
* create service+ingress/route pair to make application accessible. | ||
* | ||
* @return applications's listen port | ||
*/ | ||
int getPort(); | ||
|
||
/** | ||
* Specifies path and/or query parameters that should be opened after command execution. | ||
* | ||
* @return path and/or query params to open or {@code null} when not defined | ||
*/ | ||
String getPath(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...workspace/infrastructure/kubernetes/provision/KubernetesPreviewUrlCommandProvisioner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2012-2018 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 org.eclipse.che.workspace.infrastructure.kubernetes.provision; | ||
|
||
import io.fabric8.kubernetes.api.model.Service; | ||
import io.fabric8.kubernetes.api.model.extensions.Ingress; | ||
import io.fabric8.kubernetes.api.model.extensions.IngressRule; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import javax.inject.Singleton; | ||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException; | ||
import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment; | ||
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesNamespace; | ||
import org.eclipse.che.workspace.infrastructure.kubernetes.util.Ingresses; | ||
|
||
/** | ||
* Extends {@link PreviewUrlCommandProvisioner} where needed. For Kubernetes, we work with {@link | ||
* Ingress}es and {@link KubernetesNamespace}. | ||
*/ | ||
@Singleton | ||
public class KubernetesPreviewUrlCommandProvisioner | ||
extends PreviewUrlCommandProvisioner<KubernetesEnvironment, Ingress> { | ||
|
||
@Override | ||
protected List<Ingress> loadExposureObjects(KubernetesNamespace namespace) | ||
throws InfrastructureException { | ||
return namespace.ingresses().get(); | ||
} | ||
|
||
@Override | ||
protected Optional<String> findHostForServicePort( | ||
List<Ingress> ingresses, Service service, int port) { | ||
return Ingresses.findIngressRuleForServicePort(ingresses, service, port) | ||
.map(IngressRule::getHost); | ||
} | ||
} |
Oops, something went wrong.