Skip to content

Commit dd72cfb

Browse files
author
OpenShift Bot
authored
Merge pull request #1410 from benjaminapetersen/binding-update
Merged by openshift-bot
2 parents aa4a228 + 84fcfd6 commit dd72cfb

File tree

10 files changed

+158
-83
lines changed

10 files changed

+158
-83
lines changed

app/scripts/controllers/newOverview.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function OverviewController($scope,
9494
routesByService: {},
9595
servicesByObjectUID: {},
9696
serviceInstances: {},
97+
bindingsByInstanceRef: {},
9798
// Set to true below when metrics are available.
9899
showMetrics: false
99100
};
@@ -1072,7 +1073,7 @@ function OverviewController($scope,
10721073
}, 300);
10731074

10741075
// TODO: code duplicated from directives/bindService.js
1075-
// extract & share
1076+
// extract & share
10761077
var sortServiceInstances = function() {
10771078
if(!state.serviceInstances && !state.serviceClasses) {
10781079
return;
@@ -1252,6 +1253,10 @@ function OverviewController($scope,
12521253
resource: 'instances'
12531254
}, context, function(serviceInstances) {
12541255
state.serviceInstances = serviceInstances.by('metadata.name');
1256+
_.each(state.serviceInstances, function(instance) {
1257+
var notifications = ResourceAlertsService.getServiceInstanceAlerts(instance);
1258+
setNotifications(instance, notifications);
1259+
});
12551260
sortServiceInstances();
12561261
updateFilter();
12571262
}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));
@@ -1263,6 +1268,7 @@ function OverviewController($scope,
12631268
resource: 'bindings'
12641269
}, context, function(bindings) {
12651270
state.bindings = bindings.by('metadata.name');
1271+
overview.bindingsByInstanceRef = _.groupBy(state.bindings, 'spec.instanceRef.name');
12661272
refreshSecrets(context);
12671273
updateFilter();
12681274
}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));

app/scripts/directives/overview/serviceInstanceRow.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ angular.module('openshiftConsole').component('serviceInstanceRow', {
1111
controllerAs: 'row',
1212
bindings: {
1313
apiObject: '<',
14-
state: '<'
14+
state: '<',
15+
bindings: '<'
1516
},
1617
templateUrl: 'views/overview/_service-instance-row.html'
1718
});
@@ -21,7 +22,7 @@ function ServiceInstanceRow($filter, DataService, rowMethods, $uibModal) {
2122
_.extend(row, rowMethods.ui);
2223

2324
var getErrorDetails = $filter('getErrorDetails');
24-
25+
2526
var getDisplayName = function() {
2627
var serviceClassName = row.apiObject.spec.serviceClassName;
2728
var instanceName = row.apiObject.metadata.name;
@@ -34,17 +35,10 @@ function ServiceInstanceRow($filter, DataService, rowMethods, $uibModal) {
3435
return _.get(row, ['state','serviceClasses', serviceClassName, 'description']);
3536
};
3637

37-
var getBindings = function() {
38-
return _.filter(row.state.bindings, function(binding) {
39-
return binding.spec.instanceRef.name === row.apiObject.metadata.name;
40-
});
41-
};
42-
4338
row.$onChanges = function() {
4439
row.notifications = rowMethods.getNotifications(row.apiObject, row.state);
4540
row.displayName = getDisplayName();
4641
row.description = getDescription();
47-
row.instanceBindings = getBindings();
4842
};
4943

5044
row.getSecretForBinding = function(binding) {

app/scripts/filters/resources.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@ angular.module('openshiftConsole')
10841084
return lastFinishTime;
10851085
};
10861086
})
1087+
// gets the status condition that matches provided type
1088+
// statusCondition(object, 'Ready')
10871089
.filter('statusCondition', function() {
10881090
return function(apiObject, type) {
10891091
if (!apiObject) {
@@ -1093,6 +1095,14 @@ angular.module('openshiftConsole')
10931095
return _.find(_.get(apiObject, 'status.conditions'), {type: type});
10941096
};
10951097
})
1098+
.filter('isServiceInstanceReady', function(statusConditionFilter) {
1099+
return function(apiObject) {
1100+
return _.get(statusConditionFilter(apiObject, 'Ready'), 'status') === 'True';
1101+
};
1102+
})
1103+
.filter('isBindingReady', function(isServiceInstanceReadyFilter) {
1104+
return isServiceInstanceReadyFilter;
1105+
})
10961106
.filter('routeIngressCondition', function() {
10971107
return function(ingress, type) {
10981108
if (!ingress) {

app/scripts/services/resourceAlerts.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,39 @@ angular.module("openshiftConsole")
147147
return alerts;
148148
};
149149

150+
var makeConditionAlert = function(alerts, uid, condition, type) {
151+
alerts[uid+'-'+condition.reason] = {
152+
type: type,
153+
message: condition.message
154+
};
155+
};
156+
157+
var getServiceInstanceAlerts = function(instance) {
158+
var alerts = {};
159+
if(!instance) {
160+
return alerts;
161+
}
162+
var uid = instance.metadata.uid;
163+
var namespaceError = _.find(instance.status.conditions, {reason: 'ErrorFindingNamespaceForInstance'});
164+
var provisionFail = _.find(instance.status.conditions, {reason: 'ProvisionFailed'});
165+
var deprovisionFail = _.find(instance.status.conditions, {reason: 'DeprovisioningFailed'});
166+
167+
if(namespaceError) {
168+
makeConditionAlert(alerts, uid, namespaceError, 'warning');
169+
}
170+
if(provisionFail) {
171+
makeConditionAlert(alerts, uid, provisionFail, 'error');
172+
}
173+
if(deprovisionFail) {
174+
makeConditionAlert(alerts, uid, deprovisionFail, 'error');
175+
}
176+
return alerts;
177+
};
178+
150179
return {
151180
getPodAlerts: getPodAlerts,
152181
setGenericQuotaWarning: setGenericQuotaWarning,
153-
getDeploymentStatusAlerts: getDeploymentStatusAlerts
182+
getDeploymentStatusAlerts: getDeploymentStatusAlerts,
183+
getServiceInstanceAlerts: getServiceInstanceAlerts
154184
};
155185
});
156-

app/views/directives/bind-service/results.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div>
22
<div ng-if="!ctrl.error">
3-
<div ng-if="(ctrl.binding | statusCondition : 'Ready').status !== 'True'">
3+
<div ng-if="!(ctrl.binding | isBindingReady)">
44
<h3 class="mar-top-none center">
55
<span class="fa fa-spinner fa-pulse fa-3x fa-fw" aria-hidden="true"></span>
66
<span class="sr-only">Pending</span>
77
<div class="mar-top-lg">The binding was created but is not ready yet.</div>
88
</h3>
99
</div>
10-
<div ng-if="(ctrl.binding | statusCondition : 'Ready').status === 'True'">
10+
<div ng-if="(ctrl.binding | isBindingReady)">
1111
<h3 class="mar-top-none">
1212
<strong>{{ctrl.serviceToBind}}</strong> has been bound to <strong>{{ctrl.target.metadata.name}}</strong> successfully
1313
</h3>

app/views/directives/bind-service/select-service.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h3 class="mar-top-none">Select a service to bind to <strong>{{ctrl.target.metad
88
<label>
99
<input type="radio" ng-model="ctrl.serviceToBind" value="{{serviceInstance.metadata.name}}">
1010
{{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}
11-
<span ng-if="(serviceInstance | statusCondition : 'Ready').status !== 'True'" class="mar-left-sm">
11+
<span ng-if="!(serviceInstance | isServiceInstanceReady)" class="mar-left-sm">
1212
<span class="pficon pficon-info" data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready." data-toggle="popover" data-trigger="hover"></span>
1313
</span>
1414
<div class="help-block mar-top-none">

app/views/new-overview.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ <h2 ng-if="overview.state.serviceInstances">
365365
<service-instance-row
366366
ng-repeat="serviceInstance in overview.state.orderedServiceInstances"
367367
api-object="serviceInstance"
368+
bindings="overview.bindingsByInstanceRef[serviceInstance.metadata.name]"
368369
state="overview.state"></service-instance-row>
369370
</div>
370371
</div>

app/views/overview/_service-instance-row.html

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ <h3>
1919
</div>
2020
</div>
2121

22-
<div
23-
class="list-pf-content hidden-xs hidden-sm">
22+
<div class="list-pf-content hidden-xs hidden-sm">
2423
<div class="list-pf-content-right">
2524
<div>
2625
<strong ng-if="!row.instanceBindings.length">No Bindings</strong>
@@ -68,62 +67,68 @@ <h3>
6867
ng-class="{ in: row.expanded }">
6968

7069
<div class="list-pf-container">
71-
72-
<!--
73-
TODO: follow-on PR
7470
<div class="expanded-section">
75-
<div class="section-title">
76-
Configuration Details
77-
</div>
78-
<div class="row" ng-repeat="item in [{
79-
name: 'password',
80-
value: '*****'
81-
}, {
82-
name: 'lorem ipsum',
83-
value: 'dolor sit amet'
84-
}]">
85-
<div class="col-sm-5">{{item.name}}</div>
86-
<div class="col-sm-7">{{item.value}}</div>
71+
<alerts alerts="row.notifications"></alerts>
72+
<!--
73+
TODO: follow-on PR
74+
<div class="expanded-section">
75+
<div class="section-title">
76+
Configuration Details
77+
</div>
78+
<div class="row" ng-repeat="item in [{
79+
name: 'password',
80+
value: '*****'
81+
}, {
82+
name: 'lorem ipsum',
83+
value: 'dolor sit amet'
84+
}]">
85+
<div class="col-sm-5">{{item.name}}</div>
86+
<div class="col-sm-7">{{item.value}}</div>
87+
</div>
8788
</div>
88-
</div>
89-
-->
89+
-->
9090

91-
<div class="row">
92-
<div class="col-sm-12" ng-if="row.description">
93-
<p class="pre-wrap" ng-bind-html="row.description | linky"></p>
91+
<div class="row">
92+
<div class="col-sm-12" ng-if="row.description">
93+
<p class="pre-wrap" ng-bind-html="row.description | linky"></p>
94+
</div>
9495
</div>
95-
</div>
96-
<div class="section-title">
97-
Bindings
98-
</div>
99-
<span ng-if="!row.instanceBindings.length">There are no bindings.</span>
100-
<div
101-
ng-if="row.instanceBindings.length"
102-
class="row"
103-
ng-repeat="binding in row.instanceBindings">
104-
<div class="col-sm-4">
105-
<span>{{binding.metadata.name}}</span>
96+
<div class="section-title">
97+
Bindings
10698
</div>
107-
<div class="col-sm-8">
108-
<!-- TODO: follow-on PR
109-
<a ng-href="{{binding | navigateResourceURL}}">View configuration details</a>
110-
-->
111-
<a href="{{row.getSecretForBinding(binding) | navigateResourceURL}}">
112-
View secret
113-
</a>
99+
<span ng-if="!row.bindings">There are no bindings.</span>
100+
<div
101+
ng-if="row.bindings"
102+
class="row"
103+
ng-repeat="(name, binding) in row.bindings">
104+
<div class="col-sm-5">
105+
<span>{{binding.metadata.name}}</span>
106+
</div>
107+
<div class="col-sm-7">
108+
<!-- TODO: follow-on PR
109+
<a ng-href="{{binding | navigateResourceURL}}">View configuration details</a>
110+
-->
111+
<span ng-if="!(binding | isBindingReady)">
112+
<status-icon status="'Pending'"></status-icon> Pending
113+
</span>
114+
<a
115+
ng-if="(binding | isBindingReady) && ('secrets' | canI : 'get')"
116+
href="{{row.getSecretForBinding(binding) | navigateResourceURL}}">
117+
View secret
118+
</a>
119+
</div>
114120
</div>
115-
</div>
116-
<!-- TODO: follow-on PR
117-
<div class="row">
118-
<div class="col-sm-12">
119-
<a href="#">
120-
<i class="fa fa-plus-circle"></i> Create binding
121-
</a>
121+
<!-- TODO: follow-on PR
122+
<div class="row">
123+
<div class="col-sm-12">
124+
<a href="#">
125+
<i class="fa fa-plus-circle"></i> Create binding
126+
</a>
127+
</div>
122128
</div>
129+
-->
123130
</div>
124-
-->
125131
</div>
126-
127132
</div>
128133

129134
</div>

dist/scripts/scripts.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ recentPipelinesByDeploymentConfig:{},
1919
routesByService:{},
2020
servicesByObjectUID:{},
2121
serviceInstances:{},
22+
bindingsByInstanceRef:{},
2223
showMetrics:!1
2324
};
2425
d.getAlerts().forEach(function(a) {
@@ -453,15 +454,18 @@ pollInterval:x
453454
group:"servicecatalog.k8s.io",
454455
resource:"instances"
455456
}, c, function(a) {
456-
L.serviceInstances = a.by("metadata.name"), Wa(), da();
457+
L.serviceInstances = a.by("metadata.name"), _.each(L.serviceInstances, function(a) {
458+
var b = t.getServiceInstanceAlerts(a);
459+
ha(a, b);
460+
}), Wa(), da();
457461
}, {
458462
poll:w,
459463
pollInterval:x
460464
})), g.ENABLE_TECH_PREVIEW_FEATURE.service_catalog_landing_page && Xa.push(h.watch({
461465
group:"servicecatalog.k8s.io",
462466
resource:"bindings"
463467
}, c, function(a) {
464-
L.bindings = a.by("metadata.name"), Va(c), da();
468+
L.bindings = a.by("metadata.name"), v.bindingsByInstanceRef = _.groupBy(L.bindings, "spec.instanceRef.name"), Va(c), da();
465469
}, {
466470
poll:w,
467471
pollInterval:x
@@ -955,13 +959,9 @@ return c || a || b;
955959
}, h = function() {
956960
var a = e.apiObject.spec.serviceClassName;
957961
return _.get(e, [ "state", "serviceClasses", a, "description" ]);
958-
}, i = function() {
959-
return _.filter(e.state.bindings, function(a) {
960-
return a.spec.instanceRef.name === e.apiObject.metadata.name;
961-
});
962962
};
963963
e.$onChanges = function() {
964-
e.notifications = c.getNotifications(e.apiObject, e.state), e.displayName = g(), e.description = h(), e.instanceBindings = i();
964+
e.notifications = c.getNotifications(e.apiObject, e.state), e.displayName = g(), e.description = h();
965965
}, e.getSecretForBinding = function(a) {
966966
return a && _.get(e, [ "state", "secrets", a.spec.secretName ]);
967967
}, e.closeOverlayPanel = function() {
@@ -4426,11 +4426,28 @@ label:"View Events"
44264426
};
44274427
}
44284428
return g;
4429+
}, k = function(a, b, c, d) {
4430+
a[b + "-" + c.reason] = {
4431+
type:d,
4432+
message:c.message
4433+
};
4434+
}, l = function(a) {
4435+
var b = {};
4436+
if (!a) return b;
4437+
var c = a.metadata.uid, d = _.find(a.status.conditions, {
4438+
reason:"ErrorFindingNamespaceForInstance"
4439+
}), e = _.find(a.status.conditions, {
4440+
reason:"ProvisionFailed"
4441+
}), f = _.find(a.status.conditions, {
4442+
reason:"DeprovisioningFailed"
4443+
});
4444+
return d && k(b, c, d, "warning"), e && k(b, c, e, "error"), f && k(b, c, f, "error"), b;
44294445
};
44304446
return {
44314447
getPodAlerts:h,
44324448
setGenericQuotaWarning:i,
4433-
getDeploymentStatusAlerts:j
4449+
getDeploymentStatusAlerts:j,
4450+
getServiceInstanceAlerts:l
44344451
};
44354452
} ]), angular.module("openshiftConsole").factory("ListRowUtils", function() {
44364453
var a = function(a) {
@@ -13808,7 +13825,8 @@ controller:[ "$filter", "DataService", "ListRowUtils", "$uibModal", ServiceInsta
1380813825
controllerAs:"row",
1380913826
bindings:{
1381013827
apiObject:"<",
13811-
state:"<"
13828+
state:"<",
13829+
bindings:"<"
1381213830
},
1381313831
templateUrl:"views/overview/_service-instance-row.html"
1381413832
}), angular.module("openshiftConsole").component("overviewNetworking", {
@@ -14855,7 +14873,13 @@ return a ? _.find(_.get(a, "status.conditions"), {
1485514873
type:b
1485614874
}) :null;
1485714875
};
14858-
}).filter("routeIngressCondition", function() {
14876+
}).filter("isServiceInstanceReady", [ "statusConditionFilter", function(a) {
14877+
return function(b) {
14878+
return "True" === _.get(a(b, "Ready"), "status");
14879+
};
14880+
} ]).filter("isBindingReady", [ "isServiceInstanceReadyFilter", function(a) {
14881+
return a;
14882+
} ]).filter("routeIngressCondition", function() {
1485914883
return function(a, b) {
1486014884
return a ? _.find(a.conditions, {
1486114885
type:b

0 commit comments

Comments
 (0)