Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ window.OPENSHIFT_CONSTANTS = {
// true indicates that deployment metrics should be disabled on the web console overview
DISABLE_OVERVIEW_METRICS: false,

// true indicates that none of the routers support wildcard subdomains and
// removes the option from the route creation form.
DISABLE_WILDCARD_ROUTES: true,

// This blacklist hides certain kinds from the "Other Resources" page because they are unpersisted, disallowed for most end users, or not supported by openshift but exist in kubernetes
AVAILABLE_KINDS_BLACKLIST: [
// These are k8s kinds that are not supported in the current release of OpenShift
Expand Down
12 changes: 10 additions & 2 deletions app/scripts/controllers/edit/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ angular.module('openshiftConsole')
AlertMessageService,
DataService,
Navigate,
ProjectsService) {
ProjectsService,
RoutesService) {
$scope.alerts = {};
$scope.renderOptions = {
hideFilterWidget: true
Expand Down Expand Up @@ -51,9 +52,16 @@ angular.module('openshiftConsole')
DataService.get("routes", $scope.routeName, context).then(
function(original) {
route = angular.copy(original);
var host = _.get(route, 'spec.host');
var isWildcard = _.get(route, 'spec.wildcardPolicy') === 'Subdomain';
if (isWildcard) {
// Display the route as a wildcard.
host = '*.' + RoutesService.getSubdomain(route);
}
$scope.routing = {
service: _.get(route, 'spec.to.name'),
host: _.get(route, 'spec.host'),
host: host,
wildcardPolicy: _.get(route, 'spec.wildcardPolicy'),
path: _.get(route, 'spec.path'),
targetPort: _.get(route, 'spec.port.targetPort'),
tls: angular.copy(_.get(route, 'spec.tls'))
Expand Down
13 changes: 12 additions & 1 deletion app/scripts/directives/oscRouting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ angular.module("openshiftConsole")
* routingDisabled:
* An expression that will disable the form (default: false)
*/
.directive("oscRouting", function() {
.directive("oscRouting", function(Constants) {
return {
require: '^form',
restrict: 'E',
Expand All @@ -50,6 +50,17 @@ angular.module("openshiftConsole")
link: function(scope, element, attrs, formCtl) {
scope.form = formCtl;

scope.disableWildcards = Constants.DISABLE_WILDCARD_ROUTES;

// Use different patterns for validating hostnames if wildcard subdomains are supported.
if (scope.disableWildcards) {
// See k8s.io/kubernetes/pkg/util/validation/validation.go
scope.hostnamePattern = /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/;
} else {
// Allow values like "*.example.com" in addition to the normal hostname regex.
scope.hostnamePattern = /^(\*(\.[a-z0-9]([-a-z0-9]*[a-z0-9]))+|[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)$/;
}

var updatePortOptions = function(service) {
if (!service) {
return;
Expand Down
14 changes: 9 additions & 5 deletions app/scripts/filters/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,8 @@ angular.module('openshiftConsole')
})
.filter('isWebRoute', function(routeHostFilter) {
return function(route){
//TODO: implement when we can tell if routes are http(s) or not web related which will drive
// links in view
// For now, only return false if the host is not defined.
return !!routeHostFilter(route);
return !!routeHostFilter(route) &&
_.get(route, 'spec.wildcardPolicy') !== 'Subdomain';
};
})
.filter('routeWebURL', function(routeHostFilter){
Expand All @@ -349,15 +347,21 @@ angular.module('openshiftConsole')
return url;
};
})
.filter('routeLabel', function(routeHostFilter, routeWebURLFilter, isWebRouteFilter) {
.filter('routeLabel', function(RoutesService, routeHostFilter, routeWebURLFilter, isWebRouteFilter) {
return function(route, host) {
if (isWebRouteFilter(route)) {
return routeWebURLFilter(route, host);
}

var label = (host || routeHostFilter(route));
if (!label) {
return '<unknown host>';
}

if (_.get(route, 'spec.wildcardPolicy') === 'Subdomain') {
label = '*.' + RoutesService.getSubdomain(route);
}

if (route.spec.path) {
label += route.spec.path;
}
Expand Down
13 changes: 10 additions & 3 deletions app/scripts/services/applicationGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,19 @@ angular.module("openshiftConsole")
to: {
kind: "Service",
name: serviceName
}
},
wildcardPolicy: 'None'
}
};

if (input.routing.host) {
route.spec.host = input.routing.host;
var host = input.routing.host;
if (host) {
if (host.startsWith('*.')) {
route.spec.wildcardPolicy = 'Subdomain';
route.spec.host = 'wildcard' + host.substring(1);
} else {
route.spec.host = host;
}
}

if (input.routing.path) {
Expand Down
15 changes: 14 additions & 1 deletion app/scripts/services/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ angular.module("openshiftConsole")
};

var addIngressWarnings = function(route, warnings) {
var wildcardPolicy = _.get(route, 'spec.wildcardPolicy');
angular.forEach(route.status.ingress, function(ingress) {
var condition = _.find(ingress.conditions, { type: "Admitted", status: "False" });
if (condition) {
Expand All @@ -72,6 +73,11 @@ angular.module("openshiftConsole")
}
warnings.push(message);
}

// This message only displays with old router images that are not aware of `wildcardPolicy`.
if (!condition && wildcardPolicy === 'Subdomain' && ingress.wildcardPolicy !== wildcardPolicy) {
warnings.push('Router "' + ingress.routerName + '" does not support wildcard subdomains. Your route will only be available at host ' + ingress.host + '.');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work for older routers (pre 1.4.0) which doesn't support wildcard subdomains.
On newer/the latest router (1.4.0) with wildcards disabled (ROUTER_ALLOW_WILDCARD_ROUTES=false or not set), status will be something like:

status:  
  ingress:  
  - conditions:  
    - lastTransitionTime: 2016-11-11T00:51:05Z  
      message: wildcard routes are not allowed  
      reason: RouteNotAdmitted  
      status: "False"  
      type: Admitted  
    host: wild.open.header.test  
    routerName: router  
    wildcardPolicy: Subdomain  

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pulled the latest router image, and I see it now. It looks like we handle the case for both older and newer router images OK.

screen shot 2016-11-11 at 8 42 10 am

}
});
};

Expand Down Expand Up @@ -123,6 +129,12 @@ angular.module("openshiftConsole")
return _.groupBy(routes, 'spec.to.name');
};

// For host "foo.example.com" return "example.com"
var getSubdomain = function(route) {
var hostname = _.get(route, 'spec.host', '');
return hostname.replace(/^[a-z0-9]([-a-z0-9]*[a-z0-9])\./, '');
};

return {
// Gets warnings about a route.
//
Expand Down Expand Up @@ -151,6 +163,7 @@ angular.module("openshiftConsole")

getServicePortForRoute: getServicePortForRoute,
getPreferredDisplayRoute: getPreferredDisplayRoute,
groupByService: groupByService
groupByService: groupByService,
getSubdomain: getSubdomain
};
});
6 changes: 0 additions & 6 deletions app/styles/_core.less
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,6 @@ label.checkbox {
right: -3px;
}

.create-route-icon,
.create-storage-icon {
padding-top: 0;
text-align: right;
}

.about,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guessing these werent being used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guessing these werent being used anywhere?

Right

.command-line {
.about-icon {
Expand Down
6 changes: 5 additions & 1 deletion app/styles/_forms.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.copy-to-clipboard input.form-control:read-only {
background-color: white;
color: @text-color;
}
}

.input-group-addon.wildcard-prefix {
padding-left: 10px;
}
7 changes: 7 additions & 0 deletions app/styles/_overview.less
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,20 @@
margin-left: 2px;
margin-right: 6px;
}
.non-web-route {
// Add extra margin to account for the missing external link icon.
margin-left: 25px;
}
@media (min-width: @screen-sm-min) {
// At wider screen widths, always 0 margin.
margin: 0;
.fa-external-link {
margin-left: 0;
margin-right: 5px;
}
.non-web-route {
margin-left: 0;
}
}
}
.app-name {
Expand Down
16 changes: 9 additions & 7 deletions app/views/browse/route.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h1>
</ul>
</div>
</h1>
<labels labels="route.metadata.labels" clickable="true" kind="routes" project-name="{{route.metadata.namespace}}" limit="3"></labels>
<labels labels="route.metadata.labels" clickable="true" kind="routes" project-name="{{route.metadata.namespace}}" limit="3"></labels>
</div>
</div>
</div><!-- /middle-header-->
Expand All @@ -59,16 +59,16 @@ <h1>
{{route | routeLabel}}
<span data-toggle="popover" data-trigger="hover" data-content="The route is not accepting traffic yet because it has not been admitted by a router." style="cursor: help; padding-left: 5px;">
<status-icon status="'Pending'" disable-animation></status-icon>
<span class="sr-only">Pending</span>
<span class="sr-only">Pending</span>
</span>
</span>
</span>
<div ng-repeat="ingress in route.status.ingress">
<span ng-if="(route | isWebRoute)">
<a href="{{route | routeWebURL : ingress.host}}" target="_blank">{{route | routeLabel : ingress.host}}</a>
</span>
<span ng-if="!(route | isWebRoute)">
{{route | routeLabel : ingress.host}}
</span>
</span>
&ndash;
<span ng-init="admittedCondition = (ingress | routeIngressCondition : 'Admitted')">
<span ng-if="!admittedCondition">admission status unknown for router '{{ingress.routerName}}'</span>
Expand All @@ -77,16 +77,18 @@ <h1>
</span>
<span ng-if="admittedCondition.status === 'False'">
rejected by router '{{ingress.routerName}}' <relative-timestamp timestamp="admittedCondition.lastTransitionTime"></relative-timestamp>
</span>
</span>
</span>
</div>
</dd>
<dt ng-if-start="route.spec.wildcardPolicy && route.spec.wildcardPolicy !== 'None' && route.spec.wildcardPolicy !== 'Subdomain'">Wildcard Policy:</dt>
<dd ng-if-end>{{route.spec.wildcardPolicy}}</dd>
<dt>Path:</dt>
<dd>
<span ng-if="route.spec.path">{{route.spec.path}}</span>
<span ng-if="!route.spec.path"><em>none</em></span>
</dd>
<dt>{{route.spec.to.kind || "Routes to"}}:</dt>
<dt>{{route.spec.to.kind || "Routes To"}}:</dt>
<dd>
<a ng-href="{{route.spec.to.name | navigateResourceURL : route.spec.to.kind : route.metadata.namespace}}">{{route.spec.to.name}}</a>
</dd>
Expand Down Expand Up @@ -143,7 +145,7 @@ <h4>Traffic</h4>
<div style="margin-bottom: 10px;">
<h4>TLS Settings</h4>
<dl class="dl-horizontal left" ng-if="route.spec.tls">
<dt>Termination type:</dt>
<dt>Termination Type:</dt>
<dd>{{route.spec.tls.termination}}</dd>
<dt ng-if-start="route.spec.tls.termination === 'edge'">Insecure Traffic:</dt>
<dd ng-if-end>{{route.spec.tls.insecureEdgeTerminationPolicy || 'None'}}</dd>
Expand Down
21 changes: 15 additions & 6 deletions app/views/directives/osc-routing.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
type="text"
name="host"
ng-model="route.host"
ng-pattern="/^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/"
ng-pattern="hostnamePattern"
ng-maxlength="253"
ng-readonly="hostReadOnly"
placeholder="www.example.com"
Expand All @@ -52,15 +52,23 @@
aria-describedby="route-host-help">
<div>
<span id="route-host-help" class="help-block">
Public hostname for the route.
<span ng-if="!hostReadOnly">If not specified, a hostname is generated.</span>
The hostname can't be changed after the route is created.
<p>
Public hostname for the route.
<span ng-if="!hostReadOnly">
If not specified, a hostname is generated.
</span>
<span ng-if="!disableWildcards">
You can use <var>*.example.com</var> with routers that support wildcard subdomains.
</span>
</p>
<p>The hostname can't be changed after the route is created.</p>
</span>
</div>
<div class="has-error" ng-show="routeForm.host.$error.pattern && routeForm.host.$touched && !routingDisabled">
<span class="help-block">
Hostname must consist of lower-case letters, numbers, periods, and
hyphens. It must start and end with a letter or number.
<span ng-if="!disableWildcards">Wildcard subdomains may start with <var>*.</var></span>
</span>
</div>
</div>
Expand Down Expand Up @@ -152,9 +160,10 @@ <h3>Alternate Services</h3>

<div class="checkbox">
<label>
<input type="checkbox" ng-model="secureRoute" id="secure-route">Secure route
<input type="checkbox" ng-model="secureRoute" aria-describedby="secure-route-help">
Secure route
</label>
<div class="help-block">
<div class="help-block" id="secure-route-help">
Routes can be secured using several TLS termination types for serving certificates.
</div>
</div>
Expand Down
48 changes: 22 additions & 26 deletions app/views/edit/route.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,31 @@
<div class="middle-container">
<div class="middle-content">
<div class="container surface-shaded">
<div class="col-md-12">
<div class="col-md-10 col-md-offset-1">
<breadcrumbs breadcrumbs="breadcrumbs"></breadcrumbs>
<alerts alerts="alerts"></alerts>
<div class="row">
<div class="col-md-10 col-md-offset-1 gutter-top">
<h1>Edit Route {{routeName}}</h1>
<div ng-if="loading">
Loading...
</div>
<form name="form">
<fieldset ng-disabled="disableInputs" ng-if="!loading">
<osc-routing
model="routing"
services="services"
show-name-input="false"
host-read-only="true">
</osc-routing>
<div class="button-group gutter-top gutter-bottom">
<button type="submit"
class="btn btn-primary btn-lg"
ng-click="updateRoute()"
ng-disabled="form.$invalid || disableInputs"
value="">Save</button>
<a class="btn btn-default btn-lg" ng-href="{{routeURL}}">Cancel</a>
</div>
</fieldset>
</form>
</div>
<h1>Edit Route {{routeName}}</h1>
<div ng-if="loading">
Loading...
</div>
<form name="form">
<fieldset ng-disabled="disableInputs" ng-if="!loading">
<osc-routing
model="routing"
services="services"
show-name-input="false"
host-read-only="true">
</osc-routing>
<div class="button-group gutter-top gutter-bottom">
<button type="submit"
class="btn btn-primary btn-lg"
ng-click="updateRoute()"
ng-disabled="form.$invalid || disableInputs"
value="">Save</button>
<a class="btn btn-default btn-lg" ng-href="{{routeURL}}">Cancel</a>
</div>
</fieldset>
</form>
</div>
</div>
</div><!-- /middle-content -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/overview/_service-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h3 class="route-title truncate">
</span>
<a ng-if="displayRoute | isWebRoute" target="_blank"
ng-href="{{displayRoute | routeWebURL}}">{{displayRoute | routeLabel}}</a>
<span ng-if="displayRoute && !(displayRoute | isWebRoute)">{{displayRoute | routeLabel}}</span>
<span ng-if="displayRoute && !(displayRoute | isWebRoute)" class="non-web-route">{{displayRoute | routeLabel}}</span>
<span ng-if="routeWarningsByService[service.metadata.name] && routesByService[service.metadata.name].length === 1">
<route-warnings warnings="routeWarningsByService[service.metadata.name]"></route-warnings>
</span>
Expand Down
Loading