Skip to content

Commit

Permalink
Adopt more service catalog API changes
Browse files Browse the repository at this point in the history
* Update to v1beta1 instead of v1alpha1
* Cluster prefix for service classes and plans
* ServiceInstanceCredential -> ServiceBinding
* Check removedFromBrokerCatalog
  • Loading branch information
spadgett committed Oct 11, 2017
1 parent bcb969b commit 7657983
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 231 deletions.
2 changes: 1 addition & 1 deletion app/scripts/controllers/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ function OverviewController($scope,
};

// Updated on viewBy changes to include the app label when appropriate.
var filterFields = ['metadata.name', 'spec.externalServiceClassName'];
var filterFields = ['metadata.name', 'spec.externalClusterServiceClassName'];
var filterByName = function(items) {
return KeywordService.filterForKeywords(items, filterFields, state.filterKeywords);
};
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/controllers/serviceInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ angular.module('openshiftConsole')
var serviceInstanceDisplayName = $filter('serviceInstanceDisplayName');

// API Versions
var serviceInstancesVersion = APIService.getPreferredVersion('serviceinstances');
$scope.serviceInstancesVersion = APIService.getPreferredVersion('serviceinstances');

var updateBreadcrumbs = function() {
$scope.breadcrumbs.push({
Expand Down Expand Up @@ -81,10 +81,10 @@ angular.module('openshiftConsole')
$scope.projectContext = context;

DataService
.get(serviceInstancesVersion, $routeParams.instance, context, { errorNotification: false })
.get($scope.serviceInstancesVersion, $routeParams.instance, context, { errorNotification: false })
.then(function(serviceInstance) {
serviceResolved(serviceInstance);
watches.push(DataService.watchObject(serviceInstancesVersion, $routeParams.instance, context, serviceResolved));
watches.push(DataService.watchObject($scope.serviceInstancesVersion, $routeParams.instance, context, serviceResolved));
}, function(error) {
$scope.loaded = true;
$scope.alerts["load"] = {
Expand Down
10 changes: 6 additions & 4 deletions app/scripts/directives/overview/listRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
var isBinaryBuild = $filter('isBinaryBuild');
var enableTechPreviewFeature = $filter('enableTechPreviewFeature');

row.serviceBindingsVersion = APIService.getPreferredVersion('servicebindings');

var updateTriggers = function(apiObject) {
var triggers = _.get(apiObject, 'spec.triggers');
if (_.isEmpty(triggers)) {
Expand Down Expand Up @@ -174,13 +176,13 @@
// Create Binding is displayed.
if (enableTechPreviewFeature('pod_presets') &&
!_.isEmpty(row.state.bindableServiceInstances) &&
canI({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'}, 'create')) {
canI(row.serviceBindingsVersion, 'create')) {
return true;
}
// Delete Binding is displayed.
if (enableTechPreviewFeature('pod_presets') &&
!_.isEmpty(deleteableBindings) &&
canI({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'}, 'delete')) {
canI(row.serviceBindingsVersion, 'delete')) {
return true;
}
// Check if one of the start build actions is displayed
Expand Down Expand Up @@ -210,13 +212,13 @@
// Create Binding is displayed.
if (enableTechPreviewFeature('pod_presets') &&
!_.isEmpty(row.state.bindableServiceInstances) &&
canI({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'}, 'create')) {
canI(row.serviceBindingsVersion, 'create')) {
return true;
}
// Delete Binding is displayed.
if (enableTechPreviewFeature('pod_presets') &&
!_.isEmpty(deleteableBindings) &&
canI({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'}, 'delete')) {
canI(row.serviceBindingsVersion, 'delete')) {
return true;
}
return false;
Expand Down
11 changes: 8 additions & 3 deletions app/scripts/directives/overview/serviceInstanceRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
angular.module('openshiftConsole').component('serviceInstanceRow', {
controller: [
'$filter',
'APIService',
'AuthorizationService',
'BindingService',
'ListRowUtils',
Expand All @@ -20,6 +21,7 @@
});

function ServiceInstanceRow($filter,
APIService,
AuthorizationService,
BindingService,
ListRowUtils,
Expand All @@ -32,6 +34,9 @@

var serviceInstanceDisplayName = $filter('serviceInstanceDisplayName');

row.serviceBindingsVersion = APIService.getPreferredVersion('servicebindings');
row.serviceInstancesVersion = APIService.getPreferredVersion('serviceinstances');

var getServiceClass = function() {
var serviceClassName = ServiceInstancesService.getServiceClassNameForInstance(row.apiObject);
return _.get(row, ['state','serviceClasses', serviceClassName]);
Expand Down Expand Up @@ -81,15 +86,15 @@
}

// We can create bindings
if (row.isBindable && AuthorizationService.canI({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'}, 'create')) {
if (row.isBindable && AuthorizationService.canI(row.serviceBindingsVersion, 'create')) {
return true;
}
// We can delete bindings
if (!_.isEmpty(row.deleteableBindings) && AuthorizationService.canI({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'}, 'delete')) {
if (!_.isEmpty(row.deleteableBindings) && AuthorizationService.canI(row.serviceBindingsVersion, 'delete')) {
return true;
}
// We can delete instances
if (AuthorizationService.canI({resource: 'serviceinstances', group: 'servicecatalog.k8s.io'}, 'delete')) {
if (AuthorizationService.canI(row.serviceInstancesVersion, 'delete')) {
return true;
}

Expand Down
8 changes: 6 additions & 2 deletions app/scripts/directives/serviceBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
(function() {
angular.module('openshiftConsole').component('serviceBinding', {
controller: [
"APIService",
"ServiceInstancesService",
ServiceBinding
],
controllerAs: '$ctrl',
Expand All @@ -17,14 +19,16 @@
templateUrl: 'views/directives/_service-binding.html'
});

function ServiceBinding() {
function ServiceBinding(APIService,
ServiceInstancesService) {
var ctrl = this;
ctrl.serviceBindingsVersion = APIService.getPreferredVersion('servicebindings');

var updateServiceClass = function() {
if (_.get(ctrl.refApiObject, 'kind') !== 'ServiceInstance') {
var instanceName = _.get(ctrl.binding, 'spec.instanceRef.name');
var instance = _.get(ctrl.serviceInstances, [instanceName]);
var serviceClassName = _.get(instance, 'spec.serviceClassRef.name');
var serviceClassName = ServiceInstancesService.getServiceClassNameForInstance(instance);
ctrl.serviceClass = _.get(ctrl.serviceClasses, [serviceClassName]);
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/filters/canI.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ angular
_.assign({}, APIService.getPreferredVersion('imagestreams'), {verbs: ['update', 'delete']})
],
'serviceInstances': [
{group: 'servicecatalog.k8s.io', resource: 'serviceinstances', verbs: ['update', 'delete']}
_.assign({}, APIService.getPreferredVersion('serviceinstances'), {verbs: ['update', 'delete']})
],
'persistentVolumeClaims': [
{group: '', resource: 'persistentvolumeclaims', verbs: ['update', 'delete']}
Expand Down
39 changes: 0 additions & 39 deletions app/scripts/filters/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,45 +1316,6 @@ angular.module('openshiftConsole')
return !_.isEmpty(alternateBackends);
};
})
.filter('serviceClassDisplayName', function() {
return function(serviceClass) {
var serviceClassDisplayName = _.get(serviceClass, 'spec.externalMetadata.displayName');
if (serviceClassDisplayName) {
return serviceClassDisplayName;
}

var serviceClassExternalName = _.get(serviceClass, 'spec.externalName');
if (serviceClassExternalName) {
return serviceClassExternalName;
}

return _.get(serviceClass, 'metadata.name');
};
})
.filter('serviceInstanceDisplayName', function(serviceClassDisplayNameFilter) {
return function(instance, serviceClass) {
if (serviceClass) {
return serviceClassDisplayNameFilter(serviceClass);
}

return _.get(instance, 'metadata.name');
};
})
.filter('serviceInstanceStatus', function(isServiceInstanceReadyFilter) {
return function(instance) {
var status = 'Pending';
var conditions = _.get(instance, 'status.conditions');
var instanceError = _.find(conditions, {type: 'Failed', status: 'True'});

if (instanceError) {
status = 'Failed';
} else if (isServiceInstanceReadyFilter(instance)) {
status = 'Ready';
}

return status;
};
})
.filter('readyConditionMessage', function(statusConditionFilter) {
return function(instance) {
return _.get(statusConditionFilter(instance, 'Ready'), 'message');
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/serviceInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module("openshiftConsole")
var servicePlansVersion = APIService.getPreferredVersion('clusterserviceplans');

var getServiceClassNameForInstance = function(serviceInstance) {
return _.get(serviceInstance, 'spec.serviceClassRef.name');
return _.get(serviceInstance, 'spec.clusterServiceClassRef.name');
};

var fetchServiceClassForInstance = function(serviceInstance) {
Expand All @@ -23,7 +23,7 @@ angular.module("openshiftConsole")
};

var getServicePlanNameForInstance = function(serviceInstance) {
return _.get(serviceInstance, 'spec.servicePlanRef.name');
return _.get(serviceInstance, 'spec.clusterServicePlanRef.name');
};

var fetchServicePlanForInstance = function(serviceInstance) {
Expand Down
4 changes: 2 additions & 2 deletions app/views/browse/service-instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ <h1 class="contains-actions">
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
data-toggle="dropdown"><i class="fa fa-ellipsis-v" aria-hidden="true"></i><span class="sr-only">Actions</span></a>
<ul class="dropdown-menu dropdown-menu-right actions action-button">
<li ng-if="{resource: 'serviceinstances', group: 'servicecatalog.k8s.io'} | canI : 'update'">
<li ng-if="serviceInstancesVersion | canI : 'update'">
<a ng-href="{{serviceInstance | editYamlURL}}" role="button">Edit YAML</a>
</li>
<li ng-if="{resource: 'serviceinstances', group: 'servicecatalog.k8s.io'} | canI : 'delete'">
<li ng-if="serviceInstancesVersion | canI : 'delete'">
<a href="" ng-click="deprovision()" role="button">Delete</a>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions app/views/directives/_service-binding.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ <h3>
</div>
<div class="service-binding-actions" ng-if="!$ctrl.binding.metadata.deletionTimestamp">
<delete-link
ng-if="({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'delete')"
kind="ServiceInstanceCredential"
ng-if="serviceBindingsVersion | canI : 'delete'"
kind="ServiceBinding"
group="servicecatalog.k8s.io"
type-display-name="binding"
resource-name="{{$ctrl.binding.metadata.name}}"
Expand Down
8 changes: 4 additions & 4 deletions app/views/overview/_list-row-actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
</li>
<li ng-if="('pod_presets' | enableTechPreviewFeature)
&& row.state.bindableServiceInstances.length
&& ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'create')" role="menuitem">
&& (row.serviceBindingsVersion | canI : 'create')" role="menuitem">
<a href="" ng-click="row.showOverlayPanel('bindService', {target: row.apiObject})">Create Binding</a>
</li>
<li ng-if="('pod_presets' | enableTechPreviewFeature)
&& row.state.deleteableBindingsByApplicationUID[row.apiObject.metadata.uid].length
&& ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'delete')" role="menuitem">
&& (row.serviceBindingsVersion | canI : 'delete')" role="menuitem">
<a href="" ng-click="row.showOverlayPanel('unbindService', {target: row.apiObject})">Delete Binding</a>
</li>
<li ng-if="row.current && ('deploymentconfigs/log' | canI : 'get')" role="menuitem">
Expand Down Expand Up @@ -65,12 +65,12 @@
</li>
<li ng-if="('pod_presets' | enableTechPreviewFeature)
&& row.state.bindableServiceInstances.length
&& ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'create')" role="menuitem">
&& (row.serviceBindingsVersion | canI : 'create')" role="menuitem">
<a href="" ng-click="row.showOverlayPanel('bindService', {target: row.apiObject})">Create Binding</a>
</li>
<li ng-if="('pod_presets' | enableTechPreviewFeature)
&& row.state.deleteableBindingsByApplicationUID[row.apiObject.metadata.uid].length
&& ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'delete')" role="menuitem">
&& (row.serviceBindingsVersion | canI : 'delete')" role="menuitem">
<a href="" ng-click="row.showOverlayPanel('unbindService', {target: row.apiObject})">Delete Binding</a>
</li>
<li ng-if="(pod = row.firstPod(row.current)) && ('pods/log' | canI : 'get')" role="menuitem">
Expand Down
2 changes: 1 addition & 1 deletion app/views/overview/_service-bindings.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
service-instances="$ctrl.serviceInstances"
secrets="$ctrl.secrets">
</service-binding>
<div ng-if="!$ctrl.refApiObject.metadata.deletionTimestamp && (($ctrl.refApiObject.kind === 'ServiceInstance') || ($ctrl.bindableServiceInstances | size)) && ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'create')">
<div ng-if="!$ctrl.refApiObject.metadata.deletionTimestamp && (($ctrl.refApiObject.kind === 'ServiceInstance') || ($ctrl.bindableServiceInstances | size)) && ({resource: 'servicebindings', group: 'servicecatalog.k8s.io'} | canI : 'create')">
<a href="" ng-click="$ctrl.createBinding()" role="button">
<span class="pficon pficon-add-circle-o" aria-hidden="true"></span>
Create Binding
Expand Down
10 changes: 5 additions & 5 deletions app/views/overview/_service-instance-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3>
<div class="list-pf-details" ng-if="!row.expanded">
<span ng-if="!row.bindings.length
&& row.isBindable
&& ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'create')"
&& (row.serviceBindingsVersion | canI : 'create')"
class="hidden-xs hidden-sm">
<a href="" ng-click="row.showOverlayPanel('bindService', {target: row.apiObject})">
<span class="pficon pficon-add-circle-o" aria-hidden="true"></span>
Expand Down Expand Up @@ -74,16 +74,16 @@ <h3>
uib-dropdown-toggle
class="actions-dropdown-kebab"><i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span></a>
<ul class="dropdown-menu dropdown-menu-right" uib-dropdown-menu role="menu">
<li role="menuitem" ng-if="row.isBindable && ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'create')">
<li role="menuitem" ng-if="row.isBindable && (row.serviceBindingsVersion | canI : 'create')">
<a href="" ng-click="row.showOverlayPanel('bindService', {target: row.apiObject})">
Create Binding
</a>
</li>
<li role="menuitem" ng-if="row.deleteableBindings.length && ({resource: 'serviceinstancecredentials', group: 'servicecatalog.k8s.io'} | canI : 'delete')">
<li role="menuitem" ng-if="row.deleteableBindings.length && (row.serviceBindingsVersion | canI : 'delete')">
<a href="" ng-click="row.showOverlayPanel('unbindService', {target: row.apiObject})">Delete Binding</a>
</li>
<li role="menuitem">
<a href="" ng-click="row.deprovision()" role="button" ng-if="{resource: 'serviceinstances', group: 'servicecatalog.k8s.io'} | canI : 'delete'">Delete</a>
<a href="" ng-click="row.deprovision()" role="button" ng-if="row.serviceInstancesVersion | canI : 'delete'">Delete</a>
</li>
</ul>
</div>
Expand Down Expand Up @@ -116,7 +116,7 @@ <h3>
<span class="mar-right-md">
<truncate-long-text content="row.apiObject | serviceInstanceFailedMessage" limit="265"></truncate-long-text>
</span>
<span ng-if="{resource: 'serviceinstances', group: 'servicecatalog.k8s.io'} | canI : 'delete'" class="nowrap">
<span ng-if="row.serviceInstancesVersion | canI : 'delete'" class="nowrap">
<a href="" ng-click="row.deprovision()">Delete This Service</a>
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"angular-moment": "1.0.0",
"angular-utf8-base64": "0.0.5",
"file-saver": "1.3.3",
"origin-web-common": "0.0.65",
"origin-web-catalog": "0.0.53"
"origin-web-common": "0.0.66",
"origin-web-catalog": "0.0.54"
},
"devDependencies": {
"angular-mocks": "1.5.11",
Expand Down
Loading

0 comments on commit 7657983

Please sign in to comment.