Skip to content

Commit 0ea0ca4

Browse files
Merge pull request #2764 from spadgett/edit-hostname
Automatic merge from submit-queue. Bug 1540783 - Keep hostname updates in route editor
2 parents 850c534 + a6b3801 commit 0ea0ca4

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

app/scripts/controllers/edit/route.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ angular.module('openshiftConsole')
5151
var routesVersion = APIService.getPreferredVersion('routes');
5252
var servicesVersion = APIService.getPreferredVersion('services');
5353

54+
var host;
5455

5556
ProjectsService
5657
.get($routeParams.project)
@@ -77,7 +78,7 @@ angular.module('openshiftConsole')
7778
}
7879

7980
route = angular.copy(original);
80-
var host = _.get(route, 'spec.host');
81+
host = _.get(route, 'spec.host');
8182
var isWildcard = _.get(route, 'spec.wildcardPolicy') === 'Subdomain';
8283
if (isWildcard) {
8384
// Display the route as a wildcard.
@@ -126,6 +127,13 @@ angular.module('openshiftConsole')
126127
_.set(updated, 'spec.to.weight', weight);
127128
}
128129

130+
var updatedHost = $scope.routing.host;
131+
if (host !== updatedHost) {
132+
if (updatedHost.startsWith('*.')) {
133+
updatedHost = 'wildcard' + updatedHost.substring(1);
134+
}
135+
updated.spec.host = updatedHost;
136+
}
129137
updated.spec.path = $scope.routing.path;
130138

131139
var targetPort = $scope.routing.targetPort;

app/scripts/directives/oscRouting.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ angular.module("openshiftConsole")
7171
return !canISetCustomHost();
7272
};
7373

74-
scope.disableWildcards = Constants.DISABLE_WILDCARD_ROUTES;
74+
// Wildcard policy can't be modified for existing routes.
75+
scope.disableWildcards =
76+
Constants.DISABLE_WILDCARD_ROUTES ||
77+
(scope.existingRoute && scope.route.wildcardPolicy !== 'Subdomain');
7578

7679
// Certificate updates also require custom host.
7780
scope.areCertificateInputsReadOnly = function() {

dist/scripts/scripts.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -7805,43 +7805,41 @@ var m = function() {
78057805
t.path(r.routeURL);
78067806
};
78077807
r.cancel = m;
7808-
var p = a.getPreferredVersion("routes"), f = a.getPreferredVersion("services");
7808+
var p, f = a.getPreferredVersion("routes"), g = a.getPreferredVersion("services");
78097809
l.get(n.project).then(_.spread(function(t, a) {
78107810
if (r.project = t, o.canI("routes", "update", n.project)) {
7811-
var l, g = e("orderByDisplayName"), v = function() {
7811+
var l, v = e("orderByDisplayName"), h = function() {
78127812
s.toErrorPage('Editing routes with non-service targets is unsupported. You can edit the route with the "Edit YAML" action instead.');
78137813
};
7814-
i.get(p, r.routeName, a).then(function(e) {
7815-
if ("Service" === e.spec.to.kind) {
7816-
l = angular.copy(e);
7817-
var t = _.get(l, "spec.host");
7818-
"Subdomain" === _.get(l, "spec.wildcardPolicy") && (t = "*." + u.getSubdomain(l)), r.routing = {
7819-
host: t,
7814+
i.get(f, r.routeName, a).then(function(e) {
7815+
"Service" === e.spec.to.kind ? (l = angular.copy(e), p = _.get(l, "spec.host"), "Subdomain" === _.get(l, "spec.wildcardPolicy") && (p = "*." + u.getSubdomain(l)), r.routing = {
7816+
host: p,
78207817
wildcardPolicy: _.get(l, "spec.wildcardPolicy"),
78217818
path: _.get(l, "spec.path"),
78227819
targetPort: _.get(l, "spec.port.targetPort"),
78237820
tls: angular.copy(_.get(l, "spec.tls"))
7824-
}, i.list(f, a).then(function(e) {
7821+
}, i.list(g, a).then(function(e) {
78257822
r.loading = !1;
78267823
var t = e.by("metadata.name");
78277824
r.routing.to = l.spec.to, r.routing.alternateServices = [], _.each(_.get(l, "spec.alternateBackends"), function(e) {
7828-
if ("Service" !== e.kind) return v(), !1;
7825+
if ("Service" !== e.kind) return h(), !1;
78297826
r.routing.alternateServices.push(e);
7830-
}), r.services = g(t);
7831-
});
7832-
} else v();
7827+
}), r.services = v(t);
7828+
})) : h();
78337829
}, function() {
78347830
s.toErrorPage("Could not load route " + r.routeName + ".");
78357831
});
7836-
var h = function() {
7832+
var y = function() {
78377833
var e = angular.copy(l), t = _.get(r, "routing.to.name");
78387834
_.set(e, "spec.to.name", t);
78397835
var n = _.get(r, "routing.to.weight");
7840-
isNaN(n) || _.set(e, "spec.to.weight", n), e.spec.path = r.routing.path;
7841-
var a = r.routing.targetPort;
7842-
a ? _.set(e, "spec.port.targetPort", a) : delete e.spec.port, _.get(r, "routing.tls.termination") ? (e.spec.tls = r.routing.tls, "passthrough" === e.spec.tls.termination && (delete e.spec.path, delete e.spec.tls.certificate, delete e.spec.tls.key, delete e.spec.tls.caCertificate), "reencrypt" !== e.spec.tls.termination && delete e.spec.tls.destinationCACertificate) : delete e.spec.tls;
7843-
var o = _.get(r, "routing.alternateServices", []);
7844-
return _.isEmpty(o) ? delete e.spec.alternateBackends : e.spec.alternateBackends = _.map(o, function(e) {
7836+
isNaN(n) || _.set(e, "spec.to.weight", n);
7837+
var a = r.routing.host;
7838+
p !== a && (a.startsWith("*.") && (a = "wildcard" + a.substring(1)), e.spec.host = a), e.spec.path = r.routing.path;
7839+
var o = r.routing.targetPort;
7840+
o ? _.set(e, "spec.port.targetPort", o) : delete e.spec.port, _.get(r, "routing.tls.termination") ? (e.spec.tls = r.routing.tls, "passthrough" === e.spec.tls.termination && (delete e.spec.path, delete e.spec.tls.certificate, delete e.spec.tls.key, delete e.spec.tls.caCertificate), "reencrypt" !== e.spec.tls.termination && delete e.spec.tls.destinationCACertificate) : delete e.spec.tls;
7841+
var i = _.get(r, "routing.alternateServices", []);
7842+
return _.isEmpty(i) ? delete e.spec.alternateBackends : e.spec.alternateBackends = _.map(i, function(e) {
78457843
return {
78467844
kind: "Service",
78477845
name: e.name,
@@ -7852,8 +7850,8 @@ weight: e.weight
78527850
r.updateRoute = function() {
78537851
if (r.form.$valid) {
78547852
d(), r.disableInputs = !0;
7855-
var t = h();
7856-
i.update(p, r.routeName, t, a).then(function() {
7853+
var t = y();
7854+
i.update(f, r.routeName, t, a).then(function() {
78577855
c.addNotification({
78587856
type: "success",
78597857
message: "Route " + r.routeName + " was successfully updated."
@@ -10046,7 +10044,7 @@ return r.existingRoute ? r.canIUpdateCustomHosts : r.canICreateCustomHosts;
1004610044
};
1004710045
r.isHostnameReadOnly = function() {
1004810046
return !c();
10049-
}, r.disableWildcards = t.DISABLE_WILDCARD_ROUTES, r.areCertificateInputsReadOnly = function() {
10047+
}, r.disableWildcards = t.DISABLE_WILDCARD_ROUTES || r.existingRoute && "Subdomain" !== r.route.wildcardPolicy, r.areCertificateInputsReadOnly = function() {
1005010048
return !r.canICreateCustomHosts;
1005110049
}, r.areCertificateInputsDisabled = function() {
1005210050
var e = _.get(r, "route.tls.termination");

0 commit comments

Comments
 (0)