forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoscRouting.js
63 lines (58 loc) · 1.84 KB
/
oscRouting.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"use strict";
angular.module("openshiftConsole")
/**
* Widget for entering route information
*
* model:
* The model for the input. The model will either use or add the following keys:
* {
* name: "",
* host: "",
* path: "",
* tls.termination: "",
* tls.insecureEdgeTerminationPolicy: "",
* tls.certificate: "",
* tls.key: "",
* tls.caCertificate: "",
* tls.destinationCACertificate: ""
* }
*
* showNameInput:
* Whether to prompt the user for a route name (default: false)
*
* routingDisabled:
* An expression that will disable the form (default: false)
*/
.directive("oscRouting", function(){
return {
require: '^form',
restrict: 'E',
scope: {
route: "=model",
showNameInput: "=",
routingDisabled: "="
},
templateUrl: 'views/directives/osc-routing.html',
link: function(scope, element, attrs, formCtl){
scope.form = formCtl;
var showCertificateWarning = function() {
if (!scope.route.tls) {
return false;
}
if (scope.route.tls.termination && scope.route.tls.termination !== 'passthrough') {
return false;
}
// Check if any certificate or key is set with an incompatible termination.
return scope.route.tls.certificate ||
scope.route.tls.key ||
scope.route.tls.caCertificate ||
scope.route.tls.destinationCACertificate;
};
// Show a warning if previously-set certificates won't be used because
// the TLS termination is now incompatible.
scope.$watch('route.tls.termination', function() {
scope.showCertificatesNotUsedWarning = showCertificateWarning();
});
}
};
});