@@ -9177,34 +9177,31 @@ link:d.routeURL
9177
9177
title:"Edit"
9178
9178
} ], i.get(c.project).then(_.spread(function(i, k) {
9179
9179
if (d.project = i, d.breadcrumbs[0].title = a("displayName")(i), !f.canI("routes", "update", c.project)) return void h.toErrorPage("You do not have authority to update route " + c.routeName + ".", "access_denied");
9180
- var l, m = a("orderByDisplayName");
9180
+ var l, m = a("orderByDisplayName"), n = function() {
9181
+ h.toErrorPage('Editing routes with non-service targets is unsupported. You can edit the route with the "Edit YAML" action instead.');
9182
+ };
9181
9183
g.get("routes", d.routeName, k).then(function(a) {
9184
+ if ("Service" !== a.spec.to.kind) return void n();
9182
9185
l = angular.copy(a);
9183
9186
var b = _.get(l, "spec.host"), c = "Subdomain" === _.get(l, "spec.wildcardPolicy");
9184
9187
c && (b = "*." + j.getSubdomain(l)), d.routing = {
9185
- service:_.get(l, "spec.to.name"),
9186
9188
host:b,
9187
9189
wildcardPolicy:_.get(l, "spec.wildcardPolicy"),
9188
9190
path:_.get(l, "spec.path"),
9189
9191
targetPort:_.get(l, "spec.port.targetPort"),
9190
9192
tls:angular.copy(_.get(l, "spec.tls"))
9191
9193
}, g.list("services", k).then(function(a) {
9192
- var b = a.by("metadata.name"), c = _.get(l, "spec.to", {});
9193
- d.loading = !1, d.services = m(b), d.routing.to = {
9194
- service:b[c.name],
9195
- weight:c.weight
9196
- }, d.routing.alternateServices = [], _.each(_.get(l, "spec.alternateBackends"), function(a) {
9197
- return "Service" !== a.kind ? (h.toErrorPage('Editing routes with non-service targets is unsupported. You can edit the route with the "Edit YAML" action instead.'), !1) :void d.routing.alternateServices.push({
9198
- service:b[a.name],
9199
- weight:a.weight
9200
- });
9201
- });
9194
+ d.loading = !1;
9195
+ var b = a.by("metadata.name");
9196
+ d.routing.to = l.spec.to, d.routing.alternateServices = [], _.each(_.get(l, "spec.alternateBackends"), function(a) {
9197
+ return "Service" !== a.kind ? (n(), !1) :void d.routing.alternateServices.push(a);
9198
+ }), d.services = m(b);
9202
9199
});
9203
9200
}, function() {
9204
9201
h.toErrorPage("Could not load route " + d.routeName + ".");
9205
9202
});
9206
- var n = function() {
9207
- var a = angular.copy(l), b = _.get(d, "routing.to.service.metadata. name");
9203
+ var o = function() {
9204
+ var a = angular.copy(l), b = _.get(d, "routing.to.name");
9208
9205
_.set(a, "spec.to.name", b);
9209
9206
var c = _.get(d, "routing.to.weight");
9210
9207
isNaN(c) || _.set(a, "spec.to.weight", c), a.spec.path = d.routing.path;
@@ -9214,15 +9211,15 @@ var f = _.get(d, "routing.alternateServices", []);
9214
9211
return _.isEmpty(f) ? delete a.spec.alternateBackends :a.spec.alternateBackends = _.map(f, function(a) {
9215
9212
return {
9216
9213
kind:"Service",
9217
- name:_.get(a, "service.metadata. name") ,
9214
+ name:a. name,
9218
9215
weight:a.weight
9219
9216
};
9220
9217
}), a;
9221
9218
};
9222
9219
d.updateRoute = function() {
9223
9220
if (d.form.$valid) {
9224
9221
d.disableInputs = !0;
9225
- var c = n ();
9222
+ var c = o ();
9226
9223
g.update("routes", d.routeName, c, k).then(function() {
9227
9224
e.addAlert({
9228
9225
name:d.routeName,
@@ -10003,10 +10000,12 @@ title:"Create Route"
10003
10000
} ], i.get(b.project).then(_.spread(function(i, k) {
10004
10001
if (c.project = i, c.breadcrumbs[0].title = a("displayName")(i), !f.canI("routes", "create", b.project)) return void h.toErrorPage("You do not have authority to create routes in project " + b.project + ".", "access_denied");
10005
10002
var l = a("orderByDisplayName");
10006
- g.list("services", k).then(function(a) {
10007
- c.services = l(a.by("metadata.name")), c.routing.to = {}, c.routing.to.service = _.find(c.services, function(a) {
10008
- return !c.serviceName || a.metadata.name === c.serviceName;
10009
- });
10003
+ c.routing.to = {
10004
+ kind:"Service",
10005
+ name:c.serviceName,
10006
+ weight:1
10007
+ }, g.list("services", k).then(function(a) {
10008
+ c.services = l(a.by("metadata.name"));
10010
10009
}), c.copyServiceLabels = function() {
10011
10010
var a = _.get(c, "routing.to.service.metadata.labels", {}), b = j.mapEntries(j.compactEntries(c.labels)), d = _.assign(b, a);
10012
10011
c.labels = _.map(d, function(a, b) {
@@ -10018,11 +10017,11 @@ value:a
10018
10017
}, c.createRoute = function() {
10019
10018
if (c.createRouteForm.$valid) {
10020
10019
c.disableInputs = !0;
10021
- var b = c.routing.to.service.metadata. name, f = j.mapEntries(j.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), i = _.get(c, "routing.alternateServices", []);
10020
+ var b = c.routing.to.name, f = j.mapEntries(j.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), i = _.get(c, "routing.alternateServices", []);
10022
10021
_.isEmpty(i) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(i, function(a) {
10023
10022
return {
10024
10023
kind:"Service",
10025
- name:_.get(a, "service.metadata. name") ,
10024
+ name:a. name,
10026
10025
weight:a.weight
10027
10026
};
10028
10027
})), g.create("routes", null, h, k).then(function() {
@@ -11300,19 +11299,22 @@ c.routeForm.insecureTraffic.$setValidity("passthrough", a);
11300
11299
};
11301
11300
c.$watchGroup([ "route.tls.termination", "route.tls.insecureEdgeTerminationPolicy" ], g), c.nameValidation = b, c.disableWildcards ? c.hostnamePattern = b.pattern :c.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])?)*)$/, c.hostnameMaxLength = b.maxlength;
11302
11301
var h = function(a) {
11303
- a && (c.unnamedServicePort = 1 === a.spec.ports.length && !a.spec.ports[0].name, a.spec.ports.length && !c.unnamedServicePort ? c.route.portOptions = _.map(a.spec.ports, function(a) {
11302
+ if (a) {
11303
+ var b = _.get(a, "spec.ports", []);
11304
+ c.unnamedServicePort = 1 === b.length && !b[0].name, b.length && !c.unnamedServicePort ? c.route.portOptions = _.map(b, function(a) {
11304
11305
return {
11305
11306
port:a.name,
11306
11307
label:a.port + " → " + a.targetPort + " (" + a.protocol + ")"
11307
11308
};
11308
- }) :c.route.portOptions = []);
11309
+ }) :c.route.portOptions = [];
11310
+ }
11309
11311
};
11310
- c.services && !c.route.service && (c.route.service = _.find(c.services)), c.$watch("route.to.service ", function(a, b) {
11311
- h(a ), a === b && c.route.targetPort || (c.route.targetPort = _.get(c, "route.portOptions[0].port")), c.services && (c.alternateServiceOptions = _.reject(c.services, function(b) {
11312
- return a === b;
11312
+ c.services && !c.route.service && (c.route.service = _.find(c.services)), c.servicesByName, c.services ? c.servicesByName = _.indexBy(c.services, "metadata.name") :c.servicesByName = {}, c. $watch("route.to.name ", function(a, b) {
11313
+ h(c.servicesByName[a] ), a === b && c.route.targetPort || (c.route.targetPort = _.get(c, "route.portOptions[0].port")), c.services && (c.alternateServiceOptions = _.reject(c.services, function(b) {
11314
+ return a === b.metadata.name ;
11313
11315
}));
11314
11316
}), c.$watch("route.alternateServices", function(a) {
11315
- c.duplicateServices = _(a).map("service ").filter(function(a, b, c) {
11317
+ c.duplicateServices = _(a).map("name ").filter(function(a, b, c) {
11316
11318
return _.includes(c, a, b + 1);
11317
11319
}).value(), f.$setValidity("duplicateServices", !c.duplicateServices.length), c.options.alternateServices = !_.isEmpty(a);
11318
11320
}, !0);
@@ -11333,12 +11335,12 @@ a !== b && (a || (c.route.alternateServices = []), a && _.isEmpty(c.route.altern
11333
11335
}), c.addAlternateService = function() {
11334
11336
c.route.alternateServices = c.route.alternateServices || [];
11335
11337
var a = _.find(c.services, function(a) {
11336
- return a !== c.route.to.service && !_.some(c.route.alternateServices, {
11337
- service:a
11338
+ return a.metadata.name !== c.route.to.service && !_.some(c.route.alternateServices, {
11339
+ service:a.metadata.name
11338
11340
});
11339
11341
});
11340
11342
_.has(c, "route.to.weight") || _.set(c, "route.to.weight", 1), c.route.alternateServices.push({
11341
- service:a,
11343
+ service:a.metadata.name ,
11342
11344
weight:1
11343
11345
});
11344
11346
}, c.weightAsPercentage = function(a, b) {
@@ -11366,20 +11368,18 @@ return {
11366
11368
restrict:"E",
11367
11369
scope:{
11368
11370
model:"=",
11369
- services:"=",
11371
+ serviceOptions:"=",
11372
+ allServices:"=",
11370
11373
isAlternate:"=?",
11371
- showWeight:"=?"
11374
+ showWeight:"=?",
11375
+ warnUnnamedPort:"=?"
11372
11376
},
11373
11377
templateUrl:"views/directives/osc-routing-service.html",
11374
11378
link:function(a, b, c, d) {
11375
- a.form = d, a.id = _.uniqueId("osc-routing-service-"), a.$watchGroup([ "model.service", "services" ], function() {
11376
- if (!_.isEmpty(a.services)) {
11377
- var b = _.get(a, "model.service");
11378
- if (!b || !_.includes(a.services, b)) {
11379
- var c = _.find(a.services);
11380
- _.set(a, "model.service", c);
11381
- }
11382
- }
11379
+ a.form = d, a.id = _.uniqueId("osc-routing-service-"), a.$watchGroup([ "model.name", "serviceOptions" ], function() {
11380
+ if (_.isEmpty(a.serviceOptions)) return void (a.optionsNames = []);
11381
+ var b = _.get(a, "model.name");
11382
+ a.optionNames = [], a.selectedExists = !1, a.optionNames = _.map(a.serviceOptions, "metadata.name"), b && !a.allServices[b] && a.optionNames.push(b), b || _.set(a, "model.name", _.first(a.optionNames));
11383
11383
});
11384
11384
}
11385
11385
};
@@ -23671,10 +23671,10 @@ var _scriptsTemplatesJs = []byte(`angular.module('openshiftConsoleTemplates', []
23671
23671
"<label for=\"{{id}}-service-select\" class=\"required\">\n" +
23672
23672
"Service\n" +
23673
23673
"</label>\n" +
23674
- "<ui-select ng-model=\"model.service \" input-id=\"{{id}}-service-select\" aria-describedby=\"{{id}}-service-help\" required>\n" +
23675
- "<ui-select-match>{{$select.selected.metadata.name }}</ui-select-match>\n" +
23676
- "<ui-select-choices repeat=\"service in (services | filter : {metadata: { name: $select.search }}) track by (service | uid )\">\n" +
23677
- "<div ng-bind-html=\"service.metadata.name | highlight : $select.search\"></div>\n" +
23674
+ "<ui-select ng-model=\"model.name \" input-id=\"{{id}}-service-select\" aria-describedby=\"{{id}}-service-help\" required>\n" +
23675
+ "<ui-select-match>{{$select.selected}}</ui-select-match>\n" +
23676
+ "<ui-select-choices repeat=\"serviceName in (optionNames | filter : $select.search)\">\n" +
23677
+ "<div ng-bind-html=\"serviceName | highlight : $select.search\"></div>\n" +
23678
23678
"</ui-select-choices>\n" +
23679
23679
"</ui-select>\n" +
23680
23680
"<div>\n" +
@@ -23683,14 +23683,19 @@ var _scriptsTemplatesJs = []byte(`angular.module('openshiftConsoleTemplates', []
23683
23683
"<span ng-if=\"isAlternate\">Alternate service for route traffic.</span>\n" +
23684
23684
"</span>\n" +
23685
23685
"</div>\n" +
23686
- "<div ng-if=\"(services | hashSize) === 0\" class=\"has-error\">\n" +
23686
+ "<div ng-if=\"model.name && !allServices[model.name]\" class=\"has-warning\">\n" +
23687
+ "<span class=\"help-block\">\n" +
23688
+ "Service {{model.name}} does not exist.\n" +
23689
+ "</span>\n" +
23690
+ "</div>\n" +
23691
+ "<div ng-if=\"(optionNames | size) === 0\" class=\"has-error\">\n" +
23687
23692
"<span class=\"help-block\">\n" +
23688
23693
"There are no <span ng-if=\"is-alternate\">additional</span> services in your project to expose with a route.\n" +
23689
23694
"</span>\n" +
23690
23695
"</div>\n" +
23691
- "<div ng-if=\"unnamedServicePort \" class=\"has-warning\">\n" +
23696
+ "<div ng-if=\"warnUnnamedPort \" class=\"has-warning\">\n" +
23692
23697
"<span class=\"help-block\">\n" +
23693
- "Service {{route.service.metadata .name}} has a single, unnamed port. A route cannot specifically target an unnamed service port. If more service ports are added later, the route will also direct traffic to them.\n" +
23698
+ "Service {{model .name}} has a single, unnamed port. A route cannot specifically target an unnamed service port. If more service ports are added later, the route will also direct traffic to them.\n" +
23694
23699
"</span>\n" +
23695
23700
"</div>\n" +
23696
23701
"</div>\n" +
@@ -23796,7 +23801,7 @@ var _scriptsTemplatesJs = []byte(`angular.module('openshiftConsoleTemplates', []
23796
23801
"</div>\n" +
23797
23802
"\n" +
23798
23803
"<div ng-if=\"services\">\n" +
23799
- "<osc-routing-service model=\"route.to\" services =\"services\" show-weight=\"route.alternateServices.length > 1 || (controls.hideSlider && route.alternateServices.length)\">\n" +
23804
+ "<osc-routing-service model=\"route.to\" service-options =\"services\" all-services=\"servicesByName\" show-weight=\"route.alternateServices.length > 1 || (controls.hideSlider && route.alternateServices.length)\" warn-unnamed-port=\"unnamedServicePort \">\n" +
23800
23805
"</osc-routing-service>\n" +
23801
23806
"</div>\n" +
23802
23807
"\n" +
@@ -23829,7 +23834,7 @@ var _scriptsTemplatesJs = []byte(`angular.module('openshiftConsoleTemplates', []
23829
23834
"</div>\n" +
23830
23835
"</div>\n" +
23831
23836
"<div ng-repeat=\"alternate in route.alternateServices\" class=\"form-group\">\n" +
23832
- "<osc-routing-service model=\"alternate\" services =\"alternateServiceOptions\" is-alternate=\"true\" show-weight=\"route.alternateServices.length > 1 || controls.hideSlider\">\n" +
23837
+ "<osc-routing-service model=\"alternate\" service-options =\"alternateServiceOptions\" all-services=\"servicesByName \" is-alternate=\"true\" show-weight=\"route.alternateServices.length > 1 || controls.hideSlider\">\n" +
23833
23838
"</osc-routing-service>\n" +
23834
23839
"<a href=\"\" ng-click=\"route.alternateServices.splice($index, 1)\">Remove Service</a>\n" +
23835
23840
"<span ng-if=\"$last && route.alternateServices.length < alternateServiceOptions.length\">\n" +
@@ -23849,12 +23854,12 @@ var _scriptsTemplatesJs = []byte(`angular.module('openshiftConsoleTemplates', []
23849
23854
"<div class=\"form-group\">\n" +
23850
23855
"<div class=\"weight-slider-values\">\n" +
23851
23856
"<div>\n" +
23852
- "<span class=\"service-name\">{{route.to.service.metadata. name}}</span>\n" +
23857
+ "<span class=\"service-name\">{{route.to.name}}</span>\n" +
23853
23858
"<span class=\"weight-percentage\">{{weightAsPercentage(route.to.weight, true)}}</span>\n" +
23854
23859
"</div>\n" +
23855
23860
"<div>\n" +
23856
23861
"<span class=\"weight-percentage hidden-xs\">{{weightAsPercentage(route.alternateServices[0].weight, true)}}</span>\n" +
23857
- "<span class=\"service-name\">{{route.alternateServices[0].service.metadata. name}}</span>\n" +
23862
+ "<span class=\"service-name\">{{route.alternateServices[0].name}}</span>\n" +
23858
23863
"<span class=\"weight-percentage visible-xs-inline\">{{weightAsPercentage(route.alternateServices[0].weight, true)}}</span>\n" +
23859
23864
"</div>\n" +
23860
23865
"</div>\n" +
0 commit comments