Commit 5a278b38 by Samuel Padgett

Adopt service catalog API changes

parent 1ae1d255
...@@ -1112,25 +1112,26 @@ angular.module("openshiftCommonServices") ...@@ -1112,25 +1112,26 @@ angular.module("openshiftCommonServices")
.service("BindingService", .service("BindingService",
function($filter, function($filter,
$q, $q,
APIService,
AuthService, AuthService,
DataService, DataService,
DNS1123_SUBDOMAIN_VALIDATION) { DNS1123_SUBDOMAIN_VALIDATION) {
// The secret key this service uses for the parameters JSON blob when binding. // The secret key this service uses for the parameters JSON blob when binding.
var PARAMETERS_SECRET_KEY = 'parameters'; var PARAMETERS_SECRET_KEY = 'parameters';
var bindingResource = { var bindingResource = APIService.getPreferredVersion('servicebindings');
group: 'servicecatalog.k8s.io',
resource: 'serviceinstancecredentials'
};
var getServiceClassForInstance = function(serviceInstance, serviceClasses) { var getServiceClassForInstance = function(serviceInstance, serviceClasses) {
var serviceClassName = _.get(serviceInstance, 'spec.serviceClassName'); if (!serviceClasses) {
return _.get(serviceClasses, [serviceClassName]); return null;
}; }
var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
if (!serviceClassName) {
return null;
}
var getPlanForInstance = function(serviceInstance, serviceClass) { return serviceClasses[serviceClassName];
var planName = _.get(serviceInstance, 'spec.planName');
return _.find(serviceClass.plans, { name: planName });
}; };
var generateName = $filter('generateName'); var generateName = $filter('generateName');
...@@ -1173,7 +1174,6 @@ angular.module("openshiftCommonServices") ...@@ -1173,7 +1174,6 @@ angular.module("openshiftCommonServices")
}; };
var makeBinding = function(serviceInstance, application, parametersSecretName) { var makeBinding = function(serviceInstance, application, parametersSecretName) {
var parametersSecretName;
var instanceName = serviceInstance.metadata.name; var instanceName = serviceInstance.metadata.name;
var credentialSecretName = generateSecretName(serviceInstance.metadata.name + '-credentials-'); var credentialSecretName = generateSecretName(serviceInstance.metadata.name + '-credentials-');
...@@ -1217,7 +1217,11 @@ angular.module("openshiftCommonServices") ...@@ -1217,7 +1217,11 @@ angular.module("openshiftCommonServices")
return binding; return binding;
}; };
var isServiceBindable = function(serviceInstance, serviceClasses) { var isServiceBindable = function(serviceInstance, serviceClass, servicePlan) {
if (!serviceInstance || !serviceClass || !servicePlan) {
return false;
}
// If being deleted, it is not bindable // If being deleted, it is not bindable
if (_.get(serviceInstance, 'metadata.deletionTimestamp')) { if (_.get(serviceInstance, 'metadata.deletionTimestamp')) {
return false; return false;
...@@ -1228,13 +1232,7 @@ angular.module("openshiftCommonServices") ...@@ -1228,13 +1232,7 @@ angular.module("openshiftCommonServices")
return false; return false;
} }
var serviceClass = getServiceClassForInstance(serviceInstance, serviceClasses); var planBindable = _.get(servicePlan, 'spec.bindable');
if (!serviceClass) {
return !!serviceInstance;
}
var plan = getPlanForInstance(serviceInstance, serviceClass);
var planBindable = _.get(plan, 'bindable');
if (planBindable === true) { if (planBindable === true) {
return true; return true;
} }
...@@ -1242,8 +1240,8 @@ angular.module("openshiftCommonServices") ...@@ -1242,8 +1240,8 @@ angular.module("openshiftCommonServices")
return false; return false;
} }
// If `plan.bindable` is not set, fall back to `serviceClass.bindable`. // If `plan.spec.bindable` is not set, fall back to `serviceClass.spec.bindable`.
return serviceClass.bindable; return serviceClass.spec.bindable;
}; };
var getPodPresetSelectorsForBindings = function(bindings) { var getPodPresetSelectorsForBindings = function(bindings) {
...@@ -1285,13 +1283,15 @@ angular.module("openshiftCommonServices") ...@@ -1285,13 +1283,15 @@ angular.module("openshiftCommonServices")
return resourceBindings; return resourceBindings;
}; };
var filterBindableServiceInstances = function(serviceInstances, serviceClasses) { var filterBindableServiceInstances = function(serviceInstances, serviceClasses, servicePlans) {
if (!serviceInstances && !serviceClasses) { if (!serviceInstances || !serviceClasses || !servicePlans) {
return null; return null;
} }
return _.filter(serviceInstances, function (serviceInstance) { return _.filter(serviceInstances, function (serviceInstance) {
return isServiceBindable(serviceInstance, serviceClasses); var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
var servicePlanName = _.get(serviceInstance, 'spec.servicePlanRef.name');
return isServiceBindable(serviceInstance, serviceClasses[serviceClassName], servicePlans[servicePlanName]);
}); });
}; };
...@@ -1302,7 +1302,8 @@ angular.module("openshiftCommonServices") ...@@ -1302,7 +1302,8 @@ angular.module("openshiftCommonServices")
return _.sortBy(serviceInstances, return _.sortBy(serviceInstances,
function(item) { function(item) {
return _.get(serviceClasses, [item.spec.serviceClassName, 'externalMetadata', 'displayName']) || item.spec.serviceClassName; var serviceClassName = _.get(item, 'spec.serviceClassRef.name');
return _.get(serviceClasses, [serviceClassName, 'spec', 'externalMetadata', 'displayName']) || item.spec.externalServiceClassName;
}, },
function(item) { function(item) {
return _.get(item, 'metadata.name', ''); return _.get(item, 'metadata.name', '');
...@@ -1313,7 +1314,6 @@ angular.module("openshiftCommonServices") ...@@ -1313,7 +1314,6 @@ angular.module("openshiftCommonServices")
return { return {
bindingResource: bindingResource, bindingResource: bindingResource,
getServiceClassForInstance: getServiceClassForInstance, getServiceClassForInstance: getServiceClassForInstance,
getPlanForInstance: getPlanForInstance,
// Create a binding for `serviceInstance`. If an `application` API object // Create a binding for `serviceInstance`. If an `application` API object
// is specified, also create a pod preset for that application using its // is specified, also create a pod preset for that application using its
...@@ -3669,6 +3669,10 @@ angular.module('openshiftCommonServices') ...@@ -3669,6 +3669,10 @@ angular.module('openshiftCommonServices')
'buildconfigs/instantiate': {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs/instantiate' }, 'buildconfigs/instantiate': {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs/instantiate' },
buildconfigs: {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs' }, buildconfigs: {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs' },
configmaps: {version: 'v1', resource: 'configmaps' }, configmaps: {version: 'v1', resource: 'configmaps' },
// Using the anticipated name for the resources, even though they aren't yet prefixed with `cluster`.
// https://github.com/kubernetes-incubator/service-catalog/issues/1288
clusterserviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' },
clusterserviceplans: {group: 'servicecatalog.k8s.io', resource: 'serviceplans' },
deployments: {group: 'apps', version: 'v1beta1', resource: 'deployments' }, deployments: {group: 'apps', version: 'v1beta1', resource: 'deployments' },
deploymentconfigs: {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs' }, deploymentconfigs: {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs' },
'deploymentconfigs/instantiate': {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs/instantiate' }, 'deploymentconfigs/instantiate': {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs/instantiate' },
...@@ -3691,9 +3695,8 @@ angular.module('openshiftCommonServices') ...@@ -3691,9 +3695,8 @@ angular.module('openshiftCommonServices')
selfsubjectrulesreviews: {group: 'authorization.openshift.io', version: 'v1', resource: 'selfsubjectrulesreviews' }, selfsubjectrulesreviews: {group: 'authorization.openshift.io', version: 'v1', resource: 'selfsubjectrulesreviews' },
services: {version: 'v1', resource: 'services' }, services: {version: 'v1', resource: 'services' },
serviceaccounts: {version: 'v1', resource: 'serviceaccounts' }, serviceaccounts: {version: 'v1', resource: 'serviceaccounts' },
// TODO: add version once these reach beta // Using the anticipated name for this resource, even though it's not currently called servicebindings.
serviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' }, servicebindings: {group: 'servicecatalog.k8s.io', resource: 'serviceinstancecredentials' },
serviceinstancecredentials: {group: 'servicecatalog.k8s.io', resource: 'serviceinstancecredentials' },
serviceinstances: {group: 'servicecatalog.k8s.io', resource: 'serviceinstances' }, serviceinstances: {group: 'servicecatalog.k8s.io', resource: 'serviceinstances' },
statefulsets: {group: 'apps', version: 'v1beta1', resource: 'statefulsets' }, statefulsets: {group: 'apps', version: 'v1beta1', resource: 'statefulsets' },
templates: {group: 'template.openshift.io', verison: 'v1', resource: 'templates' } templates: {group: 'template.openshift.io', verison: 'v1', resource: 'templates' }
......
...@@ -63,7 +63,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -63,7 +63,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\" class=\"bind-service-selection\">\n" + " <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\" class=\"bind-service-selection\">\n" +
" <label>\n" + " <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" ng-value=\"serviceInstance\">\n" + " <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" ng-value=\"serviceInstance\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" + " {{ctrl.serviceClasses[serviceInstance.spec.serviceClassRef.name].spec.externalMetadata.displayName || serviceInstance.spec.serviceClassRef.name}}\n" +
" </label>\n" + " </label>\n" +
" <div class=\"bind-description\">\n" + " <div class=\"bind-description\">\n" +
" <span class=\"pficon pficon-info\"\n" + " <span class=\"pficon pficon-info\"\n" +
...@@ -162,7 +162,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -162,7 +162,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <form>\n" + " <form>\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label>\n" + " <label>\n" +
" <h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3>\n" + " <h3>Create a binding for <strong>{{ctrl.serviceClass.spec.externalMetadata.displayName || ctrl.serviceClass.spec.externalName}}</strong></h3>\n" +
" </label>\n" + " </label>\n" +
" <span class=\"help-block\">Bindings create a secret containing the necessary information for an application to use this service.</span>\n" + " <span class=\"help-block\">Bindings create a secret containing the necessary information for an application to use this service.</span>\n" +
" </div>\n" + " </div>\n" +
...@@ -534,7 +534,6 @@ angular.module('openshiftCommonUI').component('bindServiceForm', { ...@@ -534,7 +534,6 @@ angular.module('openshiftCommonUI').component('bindServiceForm', {
controllerAs: 'ctrl', controllerAs: 'ctrl',
bindings: { bindings: {
serviceClass: '<', serviceClass: '<',
serviceClassName: '<',
showPodPresets: '<', showPodPresets: '<',
applications: '<', applications: '<',
formName: '=', formName: '=',
...@@ -1750,6 +1749,10 @@ angular.module('openshiftCommonUI') ...@@ -1750,6 +1749,10 @@ angular.module('openshiftCommonUI')
return kind; return kind;
} }
if (kind === 'ServiceInstance') {
return useTitleCase ? 'Provisioned Service' : 'provisioned service';
}
var humanized = _.startCase(kind); var humanized = _.startCase(kind);
if (useTitleCase) { if (useTitleCase) {
return humanized; return humanized;
......
...@@ -234,7 +234,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -234,7 +234,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\" class=\"bind-service-selection\">\n" + " <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\" class=\"bind-service-selection\">\n" +
" <label>\n" + " <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" ng-value=\"serviceInstance\">\n" + " <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" ng-value=\"serviceInstance\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" + " {{ctrl.serviceClasses[serviceInstance.spec.serviceClassRef.name].spec.externalMetadata.displayName || serviceInstance.spec.serviceClassRef.name}}\n" +
" </label>\n" + " </label>\n" +
" <div class=\"bind-description\">\n" + " <div class=\"bind-description\">\n" +
" <span class=\"pficon pficon-info\"\n" + " <span class=\"pficon pficon-info\"\n" +
...@@ -333,7 +333,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -333,7 +333,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <form>\n" + " <form>\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label>\n" + " <label>\n" +
" <h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3>\n" + " <h3>Create a binding for <strong>{{ctrl.serviceClass.spec.externalMetadata.displayName || ctrl.serviceClass.spec.externalName}}</strong></h3>\n" +
" </label>\n" + " </label>\n" +
" <span class=\"help-block\">Bindings create a secret containing the necessary information for an application to use this service.</span>\n" + " <span class=\"help-block\">Bindings create a secret containing the necessary information for an application to use this service.</span>\n" +
" </div>\n" + " </div>\n" +
...@@ -705,7 +705,6 @@ angular.module('openshiftCommonUI').component('bindServiceForm', { ...@@ -705,7 +705,6 @@ angular.module('openshiftCommonUI').component('bindServiceForm', {
controllerAs: 'ctrl', controllerAs: 'ctrl',
bindings: { bindings: {
serviceClass: '<', serviceClass: '<',
serviceClassName: '<',
showPodPresets: '<', showPodPresets: '<',
applications: '<', applications: '<',
formName: '=', formName: '=',
...@@ -1440,6 +1439,10 @@ angular.module('openshiftCommonServices') ...@@ -1440,6 +1439,10 @@ angular.module('openshiftCommonServices')
'buildconfigs/instantiate': {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs/instantiate' }, 'buildconfigs/instantiate': {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs/instantiate' },
buildconfigs: {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs' }, buildconfigs: {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs' },
configmaps: {version: 'v1', resource: 'configmaps' }, configmaps: {version: 'v1', resource: 'configmaps' },
// Using the anticipated name for the resources, even though they aren't yet prefixed with `cluster`.
// https://github.com/kubernetes-incubator/service-catalog/issues/1288
clusterserviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' },
clusterserviceplans: {group: 'servicecatalog.k8s.io', resource: 'serviceplans' },
deployments: {group: 'apps', version: 'v1beta1', resource: 'deployments' }, deployments: {group: 'apps', version: 'v1beta1', resource: 'deployments' },
deploymentconfigs: {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs' }, deploymentconfigs: {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs' },
'deploymentconfigs/instantiate': {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs/instantiate' }, 'deploymentconfigs/instantiate': {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs/instantiate' },
...@@ -1462,9 +1465,8 @@ angular.module('openshiftCommonServices') ...@@ -1462,9 +1465,8 @@ angular.module('openshiftCommonServices')
selfsubjectrulesreviews: {group: 'authorization.openshift.io', version: 'v1', resource: 'selfsubjectrulesreviews' }, selfsubjectrulesreviews: {group: 'authorization.openshift.io', version: 'v1', resource: 'selfsubjectrulesreviews' },
services: {version: 'v1', resource: 'services' }, services: {version: 'v1', resource: 'services' },
serviceaccounts: {version: 'v1', resource: 'serviceaccounts' }, serviceaccounts: {version: 'v1', resource: 'serviceaccounts' },
// TODO: add version once these reach beta // Using the anticipated name for this resource, even though it's not currently called servicebindings.
serviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' }, servicebindings: {group: 'servicecatalog.k8s.io', resource: 'serviceinstancecredentials' },
serviceinstancecredentials: {group: 'servicecatalog.k8s.io', resource: 'serviceinstancecredentials' },
serviceinstances: {group: 'servicecatalog.k8s.io', resource: 'serviceinstances' }, serviceinstances: {group: 'servicecatalog.k8s.io', resource: 'serviceinstances' },
statefulsets: {group: 'apps', version: 'v1beta1', resource: 'statefulsets' }, statefulsets: {group: 'apps', version: 'v1beta1', resource: 'statefulsets' },
templates: {group: 'template.openshift.io', verison: 'v1', resource: 'templates' } templates: {group: 'template.openshift.io', verison: 'v1', resource: 'templates' }
...@@ -1960,6 +1962,10 @@ angular.module('openshiftCommonUI') ...@@ -1960,6 +1962,10 @@ angular.module('openshiftCommonUI')
return kind; return kind;
} }
if (kind === 'ServiceInstance') {
return useTitleCase ? 'Provisioned Service' : 'provisioned service';
}
var humanized = _.startCase(kind); var humanized = _.startCase(kind);
if (useTitleCase) { if (useTitleCase) {
return humanized; return humanized;
...@@ -3121,27 +3127,28 @@ angular.module('openshiftCommonServices') ...@@ -3121,27 +3127,28 @@ angular.module('openshiftCommonServices')
angular.module("openshiftCommonServices") angular.module("openshiftCommonServices")
.service("BindingService", .service("BindingService",
["$filter", "$q", "AuthService", "DataService", "DNS1123_SUBDOMAIN_VALIDATION", function($filter, ["$filter", "$q", "APIService", "AuthService", "DataService", "DNS1123_SUBDOMAIN_VALIDATION", function($filter,
$q, $q,
APIService,
AuthService, AuthService,
DataService, DataService,
DNS1123_SUBDOMAIN_VALIDATION) { DNS1123_SUBDOMAIN_VALIDATION) {
// The secret key this service uses for the parameters JSON blob when binding. // The secret key this service uses for the parameters JSON blob when binding.
var PARAMETERS_SECRET_KEY = 'parameters'; var PARAMETERS_SECRET_KEY = 'parameters';
var bindingResource = { var bindingResource = APIService.getPreferredVersion('servicebindings');
group: 'servicecatalog.k8s.io',
resource: 'serviceinstancecredentials'
};
var getServiceClassForInstance = function(serviceInstance, serviceClasses) { var getServiceClassForInstance = function(serviceInstance, serviceClasses) {
var serviceClassName = _.get(serviceInstance, 'spec.serviceClassName'); if (!serviceClasses) {
return _.get(serviceClasses, [serviceClassName]); return null;
}; }
var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
if (!serviceClassName) {
return null;
}
var getPlanForInstance = function(serviceInstance, serviceClass) { return serviceClasses[serviceClassName];
var planName = _.get(serviceInstance, 'spec.planName');
return _.find(serviceClass.plans, { name: planName });
}; };
var generateName = $filter('generateName'); var generateName = $filter('generateName');
...@@ -3184,7 +3191,6 @@ angular.module("openshiftCommonServices") ...@@ -3184,7 +3191,6 @@ angular.module("openshiftCommonServices")
}; };
var makeBinding = function(serviceInstance, application, parametersSecretName) { var makeBinding = function(serviceInstance, application, parametersSecretName) {
var parametersSecretName;
var instanceName = serviceInstance.metadata.name; var instanceName = serviceInstance.metadata.name;
var credentialSecretName = generateSecretName(serviceInstance.metadata.name + '-credentials-'); var credentialSecretName = generateSecretName(serviceInstance.metadata.name + '-credentials-');
...@@ -3228,7 +3234,11 @@ angular.module("openshiftCommonServices") ...@@ -3228,7 +3234,11 @@ angular.module("openshiftCommonServices")
return binding; return binding;
}; };
var isServiceBindable = function(serviceInstance, serviceClasses) { var isServiceBindable = function(serviceInstance, serviceClass, servicePlan) {
if (!serviceInstance || !serviceClass || !servicePlan) {
return false;
}
// If being deleted, it is not bindable // If being deleted, it is not bindable
if (_.get(serviceInstance, 'metadata.deletionTimestamp')) { if (_.get(serviceInstance, 'metadata.deletionTimestamp')) {
return false; return false;
...@@ -3239,13 +3249,7 @@ angular.module("openshiftCommonServices") ...@@ -3239,13 +3249,7 @@ angular.module("openshiftCommonServices")
return false; return false;
} }
var serviceClass = getServiceClassForInstance(serviceInstance, serviceClasses); var planBindable = _.get(servicePlan, 'spec.bindable');
if (!serviceClass) {
return !!serviceInstance;
}
var plan = getPlanForInstance(serviceInstance, serviceClass);
var planBindable = _.get(plan, 'bindable');
if (planBindable === true) { if (planBindable === true) {
return true; return true;
} }
...@@ -3253,8 +3257,8 @@ angular.module("openshiftCommonServices") ...@@ -3253,8 +3257,8 @@ angular.module("openshiftCommonServices")
return false; return false;
} }
// If `plan.bindable` is not set, fall back to `serviceClass.bindable`. // If `plan.spec.bindable` is not set, fall back to `serviceClass.spec.bindable`.
return serviceClass.bindable; return serviceClass.spec.bindable;
}; };
var getPodPresetSelectorsForBindings = function(bindings) { var getPodPresetSelectorsForBindings = function(bindings) {
...@@ -3296,13 +3300,15 @@ angular.module("openshiftCommonServices") ...@@ -3296,13 +3300,15 @@ angular.module("openshiftCommonServices")
return resourceBindings; return resourceBindings;
}; };
var filterBindableServiceInstances = function(serviceInstances, serviceClasses) { var filterBindableServiceInstances = function(serviceInstances, serviceClasses, servicePlans) {
if (!serviceInstances && !serviceClasses) { if (!serviceInstances || !serviceClasses || !servicePlans) {
return null; return null;
} }
return _.filter(serviceInstances, function (serviceInstance) { return _.filter(serviceInstances, function (serviceInstance) {
return isServiceBindable(serviceInstance, serviceClasses); var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
var servicePlanName = _.get(serviceInstance, 'spec.servicePlanRef.name');
return isServiceBindable(serviceInstance, serviceClasses[serviceClassName], servicePlans[servicePlanName]);
}); });
}; };
...@@ -3313,7 +3319,8 @@ angular.module("openshiftCommonServices") ...@@ -3313,7 +3319,8 @@ angular.module("openshiftCommonServices")
return _.sortBy(serviceInstances, return _.sortBy(serviceInstances,
function(item) { function(item) {
return _.get(serviceClasses, [item.spec.serviceClassName, 'externalMetadata', 'displayName']) || item.spec.serviceClassName; var serviceClassName = _.get(item, 'spec.serviceClassRef.name');
return _.get(serviceClasses, [serviceClassName, 'spec', 'externalMetadata', 'displayName']) || item.spec.externalServiceClassName;
}, },
function(item) { function(item) {
return _.get(item, 'metadata.name', ''); return _.get(item, 'metadata.name', '');
...@@ -3324,7 +3331,6 @@ angular.module("openshiftCommonServices") ...@@ -3324,7 +3331,6 @@ angular.module("openshiftCommonServices")
return { return {
bindingResource: bindingResource, bindingResource: bindingResource,
getServiceClassForInstance: getServiceClassForInstance, getServiceClassForInstance: getServiceClassForInstance,
getPlanForInstance: getPlanForInstance,
// Create a binding for `serviceInstance`. If an `application` API object // Create a binding for `serviceInstance`. If an `application` API object
// is specified, also create a pod preset for that application using its // is specified, also create a pod preset for that application using its
......
...@@ -85,9 +85,9 @@ maxlength:253, ...@@ -85,9 +85,9 @@ maxlength:253,
description:"Name must consist of lower-case letters, numbers, periods, and hyphens. It must start and end with a letter or a number." description:"Name must consist of lower-case letters, numbers, periods, and hyphens. It must start and end with a letter or a number."
}).constant("IS_IOS", /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream), hawtioPluginLoader.addModule("openshiftCommonUI"), angular.module("openshiftCommonUI").run([ "$templateCache", function($templateCache) { }).constant("IS_IOS", /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream), hawtioPluginLoader.addModule("openshiftCommonUI"), angular.module("openshiftCommonUI").run([ "$templateCache", function($templateCache) {
"use strict"; "use strict";
$templateCache.put("src/components/binding/bindApplicationForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for application <strong>{{ctrl.applicationName}}</strong></h3>\n </label>\n <span class="help-block">\n Bindings create a secret containing the necessary information for an application to use a service.\n </span>\n </div>\n </form>\n\n <label ng-if="!ctrl.allowNoBinding">\n Select a service:\n </label>\n <form name="ctrl.formName">\n <fieldset>\n <div class="radio">\n <div ng-if="ctrl.allowNoBinding" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="null">\n Do not bind at this time.\n </label>\n <div class="bind-description">\n <span class="help-block service-instance-name">\n Bindings can be created later from within a project.\n </span>\n </div>\n </div>\n <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance">\n {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}}\n </label>\n <div class="bind-description">\n <span class="pficon pficon-info"\n ng-if="!(serviceInstance | isServiceInstanceReady)"\n data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready."\n data-toggle="popover"\n data-trigger="hover">\n </span>\n <span class="help-block service-instance-name">\n {{serviceInstance.metadata.name}}\n </span>\n </div>\n </div>\n <h4 ng-if="!ctrl.bindableServiceInstances.length">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="help-block service-instance-name">\n There are no bindable services in this project\n </span>\n </h4>\n </div>\n </fieldset>\n </form>\n</div>\n'), $templateCache.put("src/components/binding/bindApplicationForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for application <strong>{{ctrl.applicationName}}</strong></h3>\n </label>\n <span class="help-block">\n Bindings create a secret containing the necessary information for an application to use a service.\n </span>\n </div>\n </form>\n\n <label ng-if="!ctrl.allowNoBinding">\n Select a service:\n </label>\n <form name="ctrl.formName">\n <fieldset>\n <div class="radio">\n <div ng-if="ctrl.allowNoBinding" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="null">\n Do not bind at this time.\n </label>\n <div class="bind-description">\n <span class="help-block service-instance-name">\n Bindings can be created later from within a project.\n </span>\n </div>\n </div>\n <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance">\n {{ctrl.serviceClasses[serviceInstance.spec.serviceClassRef.name].spec.externalMetadata.displayName || serviceInstance.spec.serviceClassRef.name}}\n </label>\n <div class="bind-description">\n <span class="pficon pficon-info"\n ng-if="!(serviceInstance | isServiceInstanceReady)"\n data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready."\n data-toggle="popover"\n data-trigger="hover">\n </span>\n <span class="help-block service-instance-name">\n {{serviceInstance.metadata.name}}\n </span>\n </div>\n </div>\n <h4 ng-if="!ctrl.bindableServiceInstances.length">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="help-block service-instance-name">\n There are no bindable services in this project\n </span>\n </h4>\n </div>\n </fieldset>\n </form>\n</div>\n'),
$templateCache.put("src/components/binding/bindResults.html", '<div ng-if="!ctrl.error && !(ctrl.binding | isBindingFailed)">\n <div ng-if="ctrl.binding && !(ctrl.binding | isBindingReady)" class="results-status">\n <span class="fa fa-clock-o text-muted" aria-hidden="true"></span>\n <span class="sr-only">Pending</span>\n <div class="results-message">\n <h3>\n The binding is being created.\n </h3>\n <p class="results-message-details">This may take several minutes.</p>\n </div>\n </div>\n <div ng-if="(ctrl.binding | isBindingReady)">\n <div class="results-status">\n <span class="pficon pficon-ok" aria-hidden="true"></span>\n <span class="sr-only">Success</span>\n <div class="results-message">\n <h3>\n <span ng-if="ctrl.bindType === \'application\'">\n <strong>{{ctrl.serviceToBind}}</strong> has been bound to\n <strong>{{ctrl.applicationToBind}}</strong> successfully.\n </span>\n <span ng-if="ctrl.bindType !== \'application\'">\n The binding <strong>{{ctrl.serviceToBind}}</strong> has been created successfully.\n </span>\n </h3>\n <p class="results-message-details">\n The binding operation created the secret\n <a ng-if="ctrl.secretHref" ng-href="{{ctrl.secretHref}}">{{ctrl.binding.spec.secretName}}</a>\n <span ng-if="!ctrl.secretHref">{{ctrl.binding.spec.secretName}}</span>\n that you may need to reference in your application.\n <span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span>\n </p>\n </div>\n </div>\n <div class="alert alert-info results-info" ng-if="ctrl.bindType === \'application\'">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="sr-only">Info</span>\n The binding secret will only be available to new pods. You will need to redeploy your application.\n </div>\n </div>\n</div>\n<div ng-if="ctrl.error || (ctrl.binding | isBindingFailed)">\n <div class="results-status">\n <span class="pficon pficon-error-circle-o text-danger" aria-hidden="true"></span>\n <span class="sr-only">Error</span>\n <div class="results-message">\n <h3>\n The binding could not be created.\n </h3>\n </div>\n </div>\n <div ng-if="ctrl.error" class="sub-title">\n <span ng-if="ctrl.error.data.message">\n {{ctrl.error.data.message | upperFirst}}\n </span>\n <span ng-if="!ctrl.error.data.message">\n An error occurred creating the binding.\n </span>\n </div>\n <div ng-if="!ctrl.error" class="sub-title">\n {{ctrl.binding | bindingFailedMessage}}\n </div>\n</div>\n'), $templateCache.put("src/components/binding/bindResults.html", '<div ng-if="!ctrl.error && !(ctrl.binding | isBindingFailed)">\n <div ng-if="ctrl.binding && !(ctrl.binding | isBindingReady)" class="results-status">\n <span class="fa fa-clock-o text-muted" aria-hidden="true"></span>\n <span class="sr-only">Pending</span>\n <div class="results-message">\n <h3>\n The binding is being created.\n </h3>\n <p class="results-message-details">This may take several minutes.</p>\n </div>\n </div>\n <div ng-if="(ctrl.binding | isBindingReady)">\n <div class="results-status">\n <span class="pficon pficon-ok" aria-hidden="true"></span>\n <span class="sr-only">Success</span>\n <div class="results-message">\n <h3>\n <span ng-if="ctrl.bindType === \'application\'">\n <strong>{{ctrl.serviceToBind}}</strong> has been bound to\n <strong>{{ctrl.applicationToBind}}</strong> successfully.\n </span>\n <span ng-if="ctrl.bindType !== \'application\'">\n The binding <strong>{{ctrl.serviceToBind}}</strong> has been created successfully.\n </span>\n </h3>\n <p class="results-message-details">\n The binding operation created the secret\n <a ng-if="ctrl.secretHref" ng-href="{{ctrl.secretHref}}">{{ctrl.binding.spec.secretName}}</a>\n <span ng-if="!ctrl.secretHref">{{ctrl.binding.spec.secretName}}</span>\n that you may need to reference in your application.\n <span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span>\n </p>\n </div>\n </div>\n <div class="alert alert-info results-info" ng-if="ctrl.bindType === \'application\'">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="sr-only">Info</span>\n The binding secret will only be available to new pods. You will need to redeploy your application.\n </div>\n </div>\n</div>\n<div ng-if="ctrl.error || (ctrl.binding | isBindingFailed)">\n <div class="results-status">\n <span class="pficon pficon-error-circle-o text-danger" aria-hidden="true"></span>\n <span class="sr-only">Error</span>\n <div class="results-message">\n <h3>\n The binding could not be created.\n </h3>\n </div>\n </div>\n <div ng-if="ctrl.error" class="sub-title">\n <span ng-if="ctrl.error.data.message">\n {{ctrl.error.data.message | upperFirst}}\n </span>\n <span ng-if="!ctrl.error.data.message">\n An error occurred creating the binding.\n </span>\n </div>\n <div ng-if="!ctrl.error" class="sub-title">\n {{ctrl.binding | bindingFailedMessage}}\n </div>\n</div>\n'),
$templateCache.put("src/components/binding/bindServiceForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3>\n </label>\n <span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span>\n </div>\n </form>\n\n <form ng-if="ctrl.allowNoBinding || ctrl.showPodPresets" name="ctrl.formName" class="mar-bottom-lg">\n <fieldset>\n <div class="radio">\n <label ng-if="ctrl.showPodPresets" class="bind-choice" ng-disabled="!ctrl.applications.length">\n <input type="radio" ng-model="ctrl.bindType" value="application" ng-disabled="!ctrl.applications.length">\n Create a secret and inject it into an application\n </label>\n <div ng-if="ctrl.showPodPresets" class="application-select">\n <ui-select ng-model="ctrl.appToBind"\n ng-disabled="ctrl.bindType !== \'application\'"\n ng-required="ctrl.bindType === \'application\'">\n <ui-select-match placeholder="{{ctrl.applications.length ? \'Select an application\' : \'There are no applications in this project\'}}">\n <span>\n {{$select.selected.metadata.name}}\n <small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n </span>\n </ui-select-match>\n <ui-select-choices\n repeat="application in (ctrl.applications) | filter : { metadata: { name: $select.search } } track by (application | uid)"\n group-by="ctrl.groupByKind">\n <span ng-bind-html="application.metadata.name | highlight : $select.search"></span>\n </ui-select-choices>\n </ui-select>\n </div>\n <label class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="secret-only">\n Create a secret in <strong>{{ctrl.projectName}}</strong> to be used later\n </label>\n <div class="help-block bind-description">\n Secrets can be referenced later from an application.\n </div>\n <label ng-if="ctrl.allowNoBinding" class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="none">\n Do not bind at this time\n </label>\n <div ng-if="ctrl.allowNoBinding" class="help-block bind-description">\n Bindings can be created later from within a project.\n </div>\n </div>\n </fieldset>\n </form>\n</div>\n'), $templateCache.put("src/components/binding/bindServiceForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for <strong>{{ctrl.serviceClass.spec.externalMetadata.displayName || ctrl.serviceClass.spec.externalName}}</strong></h3>\n </label>\n <span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span>\n </div>\n </form>\n\n <form ng-if="ctrl.allowNoBinding || ctrl.showPodPresets" name="ctrl.formName" class="mar-bottom-lg">\n <fieldset>\n <div class="radio">\n <label ng-if="ctrl.showPodPresets" class="bind-choice" ng-disabled="!ctrl.applications.length">\n <input type="radio" ng-model="ctrl.bindType" value="application" ng-disabled="!ctrl.applications.length">\n Create a secret and inject it into an application\n </label>\n <div ng-if="ctrl.showPodPresets" class="application-select">\n <ui-select ng-model="ctrl.appToBind"\n ng-disabled="ctrl.bindType !== \'application\'"\n ng-required="ctrl.bindType === \'application\'">\n <ui-select-match placeholder="{{ctrl.applications.length ? \'Select an application\' : \'There are no applications in this project\'}}">\n <span>\n {{$select.selected.metadata.name}}\n <small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n </span>\n </ui-select-match>\n <ui-select-choices\n repeat="application in (ctrl.applications) | filter : { metadata: { name: $select.search } } track by (application | uid)"\n group-by="ctrl.groupByKind">\n <span ng-bind-html="application.metadata.name | highlight : $select.search"></span>\n </ui-select-choices>\n </ui-select>\n </div>\n <label class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="secret-only">\n Create a secret in <strong>{{ctrl.projectName}}</strong> to be used later\n </label>\n <div class="help-block bind-description">\n Secrets can be referenced later from an application.\n </div>\n <label ng-if="ctrl.allowNoBinding" class="bind-choice">\n <input type="radio" ng-model="ctrl.bindType" value="none">\n Do not bind at this time\n </label>\n <div ng-if="ctrl.allowNoBinding" class="help-block bind-description">\n Bindings can be created later from within a project.\n </div>\n </div>\n </fieldset>\n </form>\n</div>\n'),
$templateCache.put("src/components/create-project/createProject.html", '<form name="createProjectForm" novalidate>\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="name" class="required">Name</label>\n <span ng-class="{\'has-error\': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}">\n <input class="form-control"\n name="name"\n id="name"\n placeholder="my-project"\n type="text"\n required\n take-focus\n minlength="2"\n maxlength="63"\n pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"\n aria-describedby="nameHelp"\n ng-model="name"\n ng-model-options="{ updateOn: \'default blur\' }"\n ng-change="nameTaken = false"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false">\n </span>\n <div>\n <span class="help-block">A unique name for the project.</span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.required && createProjectForm.name.$dirty">\n Name is required.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.minlength && createProjectForm.name.$touched">\n Name must have at least two characters.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.pattern && createProjectForm.name.$touched">\n Project names may only contain lower-case letters, numbers, and dashes.\n They may not start or end with a dash.\n </span>\n </div>\n <div class="has-error">\n <span class="help-block" ng-if="nameTaken">\n This name is already in use. Please choose a different name.\n </span>\n </div>\n </div>\n\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="createProject()"\n ng-disabled="createProjectForm.$invalid || nameTaken || disableInputs"\n value="">\n Create\n </button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelCreateProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'), $templateCache.put("src/components/create-project/createProject.html", '<form name="createProjectForm" novalidate>\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="name" class="required">Name</label>\n <span ng-class="{\'has-error\': (createProjectForm.name.$error.pattern && createProjectForm.name.$touched) || nameTaken}">\n <input class="form-control"\n name="name"\n id="name"\n placeholder="my-project"\n type="text"\n required\n take-focus\n minlength="2"\n maxlength="63"\n pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"\n aria-describedby="nameHelp"\n ng-model="name"\n ng-model-options="{ updateOn: \'default blur\' }"\n ng-change="nameTaken = false"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false">\n </span>\n <div>\n <span class="help-block">A unique name for the project.</span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.required && createProjectForm.name.$dirty">\n Name is required.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.minlength && createProjectForm.name.$touched">\n Name must have at least two characters.\n </span>\n </div>\n <div class="has-error">\n <span id="nameHelp" class="help-block" ng-if="createProjectForm.name.$error.pattern && createProjectForm.name.$touched">\n Project names may only contain lower-case letters, numbers, and dashes.\n They may not start or end with a dash.\n </span>\n </div>\n <div class="has-error">\n <span class="help-block" ng-if="nameTaken">\n This name is already in use. Please choose a different name.\n </span>\n </div>\n </div>\n\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="createProject()"\n ng-disabled="createProjectForm.$invalid || nameTaken || disableInputs"\n value="">\n Create\n </button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelCreateProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'),
$templateCache.put("src/components/delete-project/delete-project-button.html", '<div class="actions">\n <!-- Avoid whitespace inside the link -->\n <a href=""\n ng-click="$event.stopPropagation(); openDeleteModal()"\n role="button"\n class="action-button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n ><i class="fa fa-trash-o" aria-hidden="true"\n ></i><span class="sr-only">Delete Project {{projectName}}</span></a>\n</div>\n'), $templateCache.put("src/components/delete-project/delete-project-modal.html", '<div class="delete-resource-modal">\n <!-- Use a form so that the enter key submits when typing a project name to confirm. -->\n <form>\n <div class="modal-body">\n <h1>Are you sure you want to delete the project \'<strong>{{project | displayName}}</strong>\'?</h1>\n <p>\n This will <strong>delete all resources</strong> associated with\n the project {{project | displayName}} and <strong>cannot be\n undone</strong>. Make sure this is something you really want to do!\n </p>\n <div ng-show="typeNameToConfirm">\n <p>Type the name of the project to confirm.</p>\n <p>\n <label class="sr-only" for="resource-to-delete">project to delete</label>\n <input\n ng-model="confirmName"\n id="resource-to-delete"\n type="text"\n class="form-control input-lg"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false"\n autofocus>\n </p>\n </div>\n </div>\n <div class="modal-footer">\n <button ng-disabled="typeNameToConfirm && confirmName !== project.metadata.name && confirmName !== (project | displayName : false)" class="btn btn-lg btn-danger" type="submit" ng-click="delete()">Delete</button>\n <button class="btn btn-lg btn-default" type="button" ng-click="cancel()">Cancel</button>\n </div>\n </form>\n</div>\n'), $templateCache.put("src/components/delete-project/delete-project-button.html", '<div class="actions">\n <!-- Avoid whitespace inside the link -->\n <a href=""\n ng-click="$event.stopPropagation(); openDeleteModal()"\n role="button"\n class="action-button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n ><i class="fa fa-trash-o" aria-hidden="true"\n ></i><span class="sr-only">Delete Project {{projectName}}</span></a>\n</div>\n'), $templateCache.put("src/components/delete-project/delete-project-modal.html", '<div class="delete-resource-modal">\n <!-- Use a form so that the enter key submits when typing a project name to confirm. -->\n <form>\n <div class="modal-body">\n <h1>Are you sure you want to delete the project \'<strong>{{project | displayName}}</strong>\'?</h1>\n <p>\n This will <strong>delete all resources</strong> associated with\n the project {{project | displayName}} and <strong>cannot be\n undone</strong>. Make sure this is something you really want to do!\n </p>\n <div ng-show="typeNameToConfirm">\n <p>Type the name of the project to confirm.</p>\n <p>\n <label class="sr-only" for="resource-to-delete">project to delete</label>\n <input\n ng-model="confirmName"\n id="resource-to-delete"\n type="text"\n class="form-control input-lg"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false"\n autofocus>\n </p>\n </div>\n </div>\n <div class="modal-footer">\n <button ng-disabled="typeNameToConfirm && confirmName !== project.metadata.name && confirmName !== (project | displayName : false)" class="btn btn-lg btn-danger" type="submit" ng-click="delete()">Delete</button>\n <button class="btn btn-lg btn-default" type="button" ng-click="cancel()">Cancel</button>\n </div>\n </form>\n</div>\n'),
$templateCache.put("src/components/delete-project/delete-project.html", '<a href="javascript:void(0)"\n ng-click="openDeleteModal()"\n role="button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n>{{label || \'Delete\'}}</a>\n'), $templateCache.put("src/components/edit-project/editProject.html", '<form name="editProjectForm">\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="editableFields.displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="editableFields.description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="update()"\n ng-disabled="editProjectForm.$invalid || disableInputs"\n value="">{{submitButtonLabel}}</button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelEditProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'), $templateCache.put("src/components/delete-project/delete-project.html", '<a href="javascript:void(0)"\n ng-click="openDeleteModal()"\n role="button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n>{{label || \'Delete\'}}</a>\n'), $templateCache.put("src/components/edit-project/editProject.html", '<form name="editProjectForm">\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="editableFields.displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="editableFields.description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="update()"\n ng-disabled="editProjectForm.$invalid || disableInputs"\n value="">{{submitButtonLabel}}</button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelEditProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'),
...@@ -130,7 +130,6 @@ templateUrl:"src/components/binding/bindResults.html" ...@@ -130,7 +130,6 @@ templateUrl:"src/components/binding/bindResults.html"
controllerAs:"ctrl", controllerAs:"ctrl",
bindings:{ bindings:{
serviceClass:"<", serviceClass:"<",
serviceClassName:"<",
showPodPresets:"<", showPodPresets:"<",
applications:"<", applications:"<",
formName:"=", formName:"=",
...@@ -511,6 +510,14 @@ configmaps:{ ...@@ -511,6 +510,14 @@ configmaps:{
version:"v1", version:"v1",
resource:"configmaps" resource:"configmaps"
}, },
clusterserviceclasses:{
group:"servicecatalog.k8s.io",
resource:"serviceclasses"
},
clusterserviceplans:{
group:"servicecatalog.k8s.io",
resource:"serviceplans"
},
deployments:{ deployments:{
group:"apps", group:"apps",
version:"v1beta1", version:"v1beta1",
...@@ -611,11 +618,7 @@ serviceaccounts:{ ...@@ -611,11 +618,7 @@ serviceaccounts:{
version:"v1", version:"v1",
resource:"serviceaccounts" resource:"serviceaccounts"
}, },
serviceclasses:{ servicebindings:{
group:"servicecatalog.k8s.io",
resource:"serviceclasses"
},
serviceinstancecredentials:{
group:"servicecatalog.k8s.io", group:"servicecatalog.k8s.io",
resource:"serviceinstancecredentials" resource:"serviceinstancecredentials"
}, },
...@@ -864,6 +867,7 @@ return resource && resource.metadata && resource.metadata.labels ? resource.meta ...@@ -864,6 +867,7 @@ return resource && resource.metadata && resource.metadata.labels ? resource.meta
}).filter("humanizeKind", [ "startCaseFilter", function(startCaseFilter) { }).filter("humanizeKind", [ "startCaseFilter", function(startCaseFilter) {
return function(kind, useTitleCase) { return function(kind, useTitleCase) {
if (!kind) return kind; if (!kind) return kind;
if ("ServiceInstance" === kind) return useTitleCase ? "Provisioned Service" :"provisioned service";
var humanized = _.startCase(kind); var humanized = _.startCase(kind);
return useTitleCase ? humanized :humanized.toLowerCase(); return useTitleCase ? humanized :humanized.toLowerCase();
}; };
...@@ -1383,18 +1387,11 @@ return data; ...@@ -1383,18 +1387,11 @@ return data;
} }
} }
}; };
}), angular.module("openshiftCommonServices").service("BindingService", [ "$filter", "$q", "AuthService", "DataService", "DNS1123_SUBDOMAIN_VALIDATION", function($filter, $q, AuthService, DataService, DNS1123_SUBDOMAIN_VALIDATION) { }), angular.module("openshiftCommonServices").service("BindingService", [ "$filter", "$q", "APIService", "AuthService", "DataService", "DNS1123_SUBDOMAIN_VALIDATION", function($filter, $q, APIService, AuthService, DataService, DNS1123_SUBDOMAIN_VALIDATION) {
var PARAMETERS_SECRET_KEY = "parameters", bindingResource = { var PARAMETERS_SECRET_KEY = "parameters", bindingResource = APIService.getPreferredVersion("servicebindings"), getServiceClassForInstance = function(serviceInstance, serviceClasses) {
group:"servicecatalog.k8s.io", if (!serviceClasses) return null;
resource:"serviceinstancecredentials" var serviceClassName = _.get(serviceInstance, "spec.serviceClassRef.name");
}, getServiceClassForInstance = function(serviceInstance, serviceClasses) { return serviceClassName ? serviceClasses[serviceClassName] :null;
var serviceClassName = _.get(serviceInstance, "spec.serviceClassName");
return _.get(serviceClasses, [ serviceClassName ]);
}, getPlanForInstance = function(serviceInstance, serviceClass) {
var planName = _.get(serviceInstance, "spec.planName");
return _.find(serviceClass.plans, {
name:planName
});
}, generateName = $filter("generateName"), generateSecretName = function(prefix) { }, generateName = $filter("generateName"), generateSecretName = function(prefix) {
var generateNameLength = 5, secretNamePrefix = _.truncate(prefix, { var generateNameLength = 5, secretNamePrefix = _.truncate(prefix, {
length:DNS1123_SUBDOMAIN_VALIDATION.maxlength - generateNameLength - 1, length:DNS1123_SUBDOMAIN_VALIDATION.maxlength - generateNameLength - 1,
...@@ -1421,7 +1418,7 @@ stringData:{} ...@@ -1421,7 +1418,7 @@ stringData:{}
}; };
return secret.stringData[PARAMETERS_SECRET_KEY] = JSON.stringify(parameters), secret; return secret.stringData[PARAMETERS_SECRET_KEY] = JSON.stringify(parameters), secret;
}, makeBinding = function(serviceInstance, application, parametersSecretName) { }, makeBinding = function(serviceInstance, application, parametersSecretName) {
var parametersSecretName, instanceName = serviceInstance.metadata.name, credentialSecretName = generateSecretName(serviceInstance.metadata.name + "-credentials-"), binding = { var instanceName = serviceInstance.metadata.name, credentialSecretName = generateSecretName(serviceInstance.metadata.name + "-credentials-"), binding = {
kind:"ServiceInstanceCredential", kind:"ServiceInstanceCredential",
apiVersion:"servicecatalog.k8s.io/v1alpha1", apiVersion:"servicecatalog.k8s.io/v1alpha1",
metadata:{ metadata:{
...@@ -1447,13 +1444,12 @@ matchLabels:appSelector ...@@ -1447,13 +1444,12 @@ matchLabels:appSelector
name:credentialSecretName, name:credentialSecretName,
selector:appSelector selector:appSelector
}), binding; }), binding;
}, isServiceBindable = function(serviceInstance, serviceClasses) { }, isServiceBindable = function(serviceInstance, serviceClass, servicePlan) {
if (!serviceInstance || !serviceClass || !servicePlan) return !1;
if (_.get(serviceInstance, "metadata.deletionTimestamp")) return !1; if (_.get(serviceInstance, "metadata.deletionTimestamp")) return !1;
if ($filter("isServiceInstanceFailed")(serviceInstance, "Failed")) return !1; if ($filter("isServiceInstanceFailed")(serviceInstance, "Failed")) return !1;
var serviceClass = getServiceClassForInstance(serviceInstance, serviceClasses); var planBindable = _.get(servicePlan, "spec.bindable");
if (!serviceClass) return !!serviceInstance; return planBindable === !0 ? !0 :planBindable === !1 ? !1 :serviceClass.spec.bindable;
var plan = getPlanForInstance(serviceInstance, serviceClass), planBindable = _.get(plan, "bindable");
return planBindable === !0 ? !0 :planBindable === !1 ? !1 :serviceClass.bindable;
}, getPodPresetSelectorsForBindings = function(bindings) { }, getPodPresetSelectorsForBindings = function(bindings) {
var podPresetSelectors = {}; var podPresetSelectors = {};
return _.each(bindings, function(binding) { return _.each(bindings, function(binding) {
...@@ -1466,13 +1462,15 @@ var podPresetSelectors = getPodPresetSelectorsForBindings(bindings), application ...@@ -1466,13 +1462,15 @@ var podPresetSelectors = getPodPresetSelectorsForBindings(bindings), application
return _.each(podPresetSelectors, function(podPresetSelector, bindingName) { return _.each(podPresetSelectors, function(podPresetSelector, bindingName) {
podPresetSelector.covers(applicationSelector) && resourceBindings.push(bindings[bindingName]); podPresetSelector.covers(applicationSelector) && resourceBindings.push(bindings[bindingName]);
}), resourceBindings; }), resourceBindings;
}, filterBindableServiceInstances = function(serviceInstances, serviceClasses) { }, filterBindableServiceInstances = function(serviceInstances, serviceClasses, servicePlans) {
return serviceInstances || serviceClasses ? _.filter(serviceInstances, function(serviceInstance) { return serviceInstances && serviceClasses && servicePlans ? _.filter(serviceInstances, function(serviceInstance) {
return isServiceBindable(serviceInstance, serviceClasses); var serviceClassName = _.get(serviceInstance, "spec.serviceClassRef.name"), servicePlanName = _.get(serviceInstance, "spec.servicePlanRef.name");
return isServiceBindable(serviceInstance, serviceClasses[serviceClassName], servicePlans[servicePlanName]);
}) :null; }) :null;
}, sortServiceInstances = function(serviceInstances, serviceClasses) { }, sortServiceInstances = function(serviceInstances, serviceClasses) {
return serviceInstances || serviceClasses ? _.sortBy(serviceInstances, function(item) { return serviceInstances || serviceClasses ? _.sortBy(serviceInstances, function(item) {
return _.get(serviceClasses, [ item.spec.serviceClassName, "externalMetadata", "displayName" ]) || item.spec.serviceClassName; var serviceClassName = _.get(item, "spec.serviceClassRef.name");
return _.get(serviceClasses, [ serviceClassName, "spec", "externalMetadata", "displayName" ]) || item.spec.externalServiceClassName;
}, function(item) { }, function(item) {
return _.get(item, "metadata.name", ""); return _.get(item, "metadata.name", "");
}) :null; }) :null;
...@@ -1480,7 +1478,6 @@ return _.get(item, "metadata.name", ""); ...@@ -1480,7 +1478,6 @@ return _.get(item, "metadata.name", "");
return { return {
bindingResource:bindingResource, bindingResource:bindingResource,
getServiceClassForInstance:getServiceClassForInstance, getServiceClassForInstance:getServiceClassForInstance,
getPlanForInstance:getPlanForInstance,
bindService:function(serviceInstance, application, serviceClass, parameters) { bindService:function(serviceInstance, application, serviceClass, parameters) {
var parametersSecretName; var parametersSecretName;
_.isEmpty(parameters) || (parametersSecretName = generateSecretName(serviceInstance.metadata.name + "-bind-parameters-")); _.isEmpty(parameters) || (parametersSecretName = generateSecretName(serviceInstance.metadata.name + "-bind-parameters-"));
......
...@@ -34,7 +34,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -34,7 +34,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\" class=\"bind-service-selection\">\n" + " <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\" class=\"bind-service-selection\">\n" +
" <label>\n" + " <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" ng-value=\"serviceInstance\">\n" + " <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" ng-value=\"serviceInstance\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" + " {{ctrl.serviceClasses[serviceInstance.spec.serviceClassRef.name].spec.externalMetadata.displayName || serviceInstance.spec.serviceClassRef.name}}\n" +
" </label>\n" + " </label>\n" +
" <div class=\"bind-description\">\n" + " <div class=\"bind-description\">\n" +
" <span class=\"pficon pficon-info\"\n" + " <span class=\"pficon pficon-info\"\n" +
...@@ -133,7 +133,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -133,7 +133,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <form>\n" + " <form>\n" +
" <div class=\"form-group\">\n" + " <div class=\"form-group\">\n" +
" <label>\n" + " <label>\n" +
" <h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3>\n" + " <h3>Create a binding for <strong>{{ctrl.serviceClass.spec.externalMetadata.displayName || ctrl.serviceClass.spec.externalName}}</strong></h3>\n" +
" </label>\n" + " </label>\n" +
" <span class=\"help-block\">Bindings create a secret containing the necessary information for an application to use this service.</span>\n" + " <span class=\"help-block\">Bindings create a secret containing the necessary information for an application to use this service.</span>\n" +
" </div>\n" + " </div>\n" +
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection"> <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection">
<label> <label>
<input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance"> <input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance">
{{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].externalMetadata.displayName || serviceInstance.spec.serviceClassName}} {{ctrl.serviceClasses[serviceInstance.spec.serviceClassRef.name].spec.externalMetadata.displayName || serviceInstance.spec.serviceClassRef.name}}
</label> </label>
<div class="bind-description"> <div class="bind-description">
<span class="pficon pficon-info" <span class="pficon pficon-info"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<form> <form>
<div class="form-group"> <div class="form-group">
<label> <label>
<h3>Create a binding for <strong>{{ctrl.serviceClass.externalMetadata.displayName || ctrl.serviceClassName}}</strong></h3> <h3>Create a binding for <strong>{{ctrl.serviceClass.spec.externalMetadata.displayName || ctrl.serviceClass.spec.externalName}}</strong></h3>
</label> </label>
<span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span> <span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span>
</div> </div>
......
...@@ -4,7 +4,6 @@ angular.module('openshiftCommonUI').component('bindServiceForm', { ...@@ -4,7 +4,6 @@ angular.module('openshiftCommonUI').component('bindServiceForm', {
controllerAs: 'ctrl', controllerAs: 'ctrl',
bindings: { bindings: {
serviceClass: '<', serviceClass: '<',
serviceClassName: '<',
showPodPresets: '<', showPodPresets: '<',
applications: '<', applications: '<',
formName: '=', formName: '=',
......
...@@ -8,6 +8,10 @@ angular.module('openshiftCommonServices') ...@@ -8,6 +8,10 @@ angular.module('openshiftCommonServices')
'buildconfigs/instantiate': {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs/instantiate' }, 'buildconfigs/instantiate': {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs/instantiate' },
buildconfigs: {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs' }, buildconfigs: {group: 'build.openshift.io', version: 'v1', resource: 'buildconfigs' },
configmaps: {version: 'v1', resource: 'configmaps' }, configmaps: {version: 'v1', resource: 'configmaps' },
// Using the anticipated name for the resources, even though they aren't yet prefixed with `cluster`.
// https://github.com/kubernetes-incubator/service-catalog/issues/1288
clusterserviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' },
clusterserviceplans: {group: 'servicecatalog.k8s.io', resource: 'serviceplans' },
deployments: {group: 'apps', version: 'v1beta1', resource: 'deployments' }, deployments: {group: 'apps', version: 'v1beta1', resource: 'deployments' },
deploymentconfigs: {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs' }, deploymentconfigs: {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs' },
'deploymentconfigs/instantiate': {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs/instantiate' }, 'deploymentconfigs/instantiate': {group: 'apps.openshift.io', version: 'v1', resource: 'deploymentconfigs/instantiate' },
...@@ -30,9 +34,8 @@ angular.module('openshiftCommonServices') ...@@ -30,9 +34,8 @@ angular.module('openshiftCommonServices')
selfsubjectrulesreviews: {group: 'authorization.openshift.io', version: 'v1', resource: 'selfsubjectrulesreviews' }, selfsubjectrulesreviews: {group: 'authorization.openshift.io', version: 'v1', resource: 'selfsubjectrulesreviews' },
services: {version: 'v1', resource: 'services' }, services: {version: 'v1', resource: 'services' },
serviceaccounts: {version: 'v1', resource: 'serviceaccounts' }, serviceaccounts: {version: 'v1', resource: 'serviceaccounts' },
// TODO: add version once these reach beta // Using the anticipated name for this resource, even though it's not currently called servicebindings.
serviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' }, servicebindings: {group: 'servicecatalog.k8s.io', resource: 'serviceinstancecredentials' },
serviceinstancecredentials: {group: 'servicecatalog.k8s.io', resource: 'serviceinstancecredentials' },
serviceinstances: {group: 'servicecatalog.k8s.io', resource: 'serviceinstances' }, serviceinstances: {group: 'servicecatalog.k8s.io', resource: 'serviceinstances' },
statefulsets: {group: 'apps', version: 'v1beta1', resource: 'statefulsets' }, statefulsets: {group: 'apps', version: 'v1beta1', resource: 'statefulsets' },
templates: {group: 'template.openshift.io', verison: 'v1', resource: 'templates' } templates: {group: 'template.openshift.io', verison: 'v1', resource: 'templates' }
......
...@@ -107,6 +107,10 @@ angular.module('openshiftCommonUI') ...@@ -107,6 +107,10 @@ angular.module('openshiftCommonUI')
return kind; return kind;
} }
if (kind === 'ServiceInstance') {
return useTitleCase ? 'Provisioned Service' : 'provisioned service';
}
var humanized = _.startCase(kind); var humanized = _.startCase(kind);
if (useTitleCase) { if (useTitleCase) {
return humanized; return humanized;
......
...@@ -4,25 +4,26 @@ angular.module("openshiftCommonServices") ...@@ -4,25 +4,26 @@ angular.module("openshiftCommonServices")
.service("BindingService", .service("BindingService",
function($filter, function($filter,
$q, $q,
APIService,
AuthService, AuthService,
DataService, DataService,
DNS1123_SUBDOMAIN_VALIDATION) { DNS1123_SUBDOMAIN_VALIDATION) {
// The secret key this service uses for the parameters JSON blob when binding. // The secret key this service uses for the parameters JSON blob when binding.
var PARAMETERS_SECRET_KEY = 'parameters'; var PARAMETERS_SECRET_KEY = 'parameters';
var bindingResource = { var bindingResource = APIService.getPreferredVersion('servicebindings');
group: 'servicecatalog.k8s.io',
resource: 'serviceinstancecredentials'
};
var getServiceClassForInstance = function(serviceInstance, serviceClasses) { var getServiceClassForInstance = function(serviceInstance, serviceClasses) {
var serviceClassName = _.get(serviceInstance, 'spec.serviceClassName'); if (!serviceClasses) {
return _.get(serviceClasses, [serviceClassName]); return null;
}; }
var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
if (!serviceClassName) {
return null;
}
var getPlanForInstance = function(serviceInstance, serviceClass) { return serviceClasses[serviceClassName];
var planName = _.get(serviceInstance, 'spec.planName');
return _.find(serviceClass.plans, { name: planName });
}; };
var generateName = $filter('generateName'); var generateName = $filter('generateName');
...@@ -65,7 +66,6 @@ angular.module("openshiftCommonServices") ...@@ -65,7 +66,6 @@ angular.module("openshiftCommonServices")
}; };
var makeBinding = function(serviceInstance, application, parametersSecretName) { var makeBinding = function(serviceInstance, application, parametersSecretName) {
var parametersSecretName;
var instanceName = serviceInstance.metadata.name; var instanceName = serviceInstance.metadata.name;
var credentialSecretName = generateSecretName(serviceInstance.metadata.name + '-credentials-'); var credentialSecretName = generateSecretName(serviceInstance.metadata.name + '-credentials-');
...@@ -109,7 +109,11 @@ angular.module("openshiftCommonServices") ...@@ -109,7 +109,11 @@ angular.module("openshiftCommonServices")
return binding; return binding;
}; };
var isServiceBindable = function(serviceInstance, serviceClasses) { var isServiceBindable = function(serviceInstance, serviceClass, servicePlan) {
if (!serviceInstance || !serviceClass || !servicePlan) {
return false;
}
// If being deleted, it is not bindable // If being deleted, it is not bindable
if (_.get(serviceInstance, 'metadata.deletionTimestamp')) { if (_.get(serviceInstance, 'metadata.deletionTimestamp')) {
return false; return false;
...@@ -120,13 +124,7 @@ angular.module("openshiftCommonServices") ...@@ -120,13 +124,7 @@ angular.module("openshiftCommonServices")
return false; return false;
} }
var serviceClass = getServiceClassForInstance(serviceInstance, serviceClasses); var planBindable = _.get(servicePlan, 'spec.bindable');
if (!serviceClass) {
return !!serviceInstance;
}
var plan = getPlanForInstance(serviceInstance, serviceClass);
var planBindable = _.get(plan, 'bindable');
if (planBindable === true) { if (planBindable === true) {
return true; return true;
} }
...@@ -134,8 +132,8 @@ angular.module("openshiftCommonServices") ...@@ -134,8 +132,8 @@ angular.module("openshiftCommonServices")
return false; return false;
} }
// If `plan.bindable` is not set, fall back to `serviceClass.bindable`. // If `plan.spec.bindable` is not set, fall back to `serviceClass.spec.bindable`.
return serviceClass.bindable; return serviceClass.spec.bindable;
}; };
var getPodPresetSelectorsForBindings = function(bindings) { var getPodPresetSelectorsForBindings = function(bindings) {
...@@ -177,13 +175,15 @@ angular.module("openshiftCommonServices") ...@@ -177,13 +175,15 @@ angular.module("openshiftCommonServices")
return resourceBindings; return resourceBindings;
}; };
var filterBindableServiceInstances = function(serviceInstances, serviceClasses) { var filterBindableServiceInstances = function(serviceInstances, serviceClasses, servicePlans) {
if (!serviceInstances && !serviceClasses) { if (!serviceInstances || !serviceClasses || !servicePlans) {
return null; return null;
} }
return _.filter(serviceInstances, function (serviceInstance) { return _.filter(serviceInstances, function (serviceInstance) {
return isServiceBindable(serviceInstance, serviceClasses); var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
var servicePlanName = _.get(serviceInstance, 'spec.servicePlanRef.name');
return isServiceBindable(serviceInstance, serviceClasses[serviceClassName], servicePlans[servicePlanName]);
}); });
}; };
...@@ -194,7 +194,8 @@ angular.module("openshiftCommonServices") ...@@ -194,7 +194,8 @@ angular.module("openshiftCommonServices")
return _.sortBy(serviceInstances, return _.sortBy(serviceInstances,
function(item) { function(item) {
return _.get(serviceClasses, [item.spec.serviceClassName, 'externalMetadata', 'displayName']) || item.spec.serviceClassName; var serviceClassName = _.get(item, 'spec.serviceClassRef.name');
return _.get(serviceClasses, [serviceClassName, 'spec', 'externalMetadata', 'displayName']) || item.spec.externalServiceClassName;
}, },
function(item) { function(item) {
return _.get(item, 'metadata.name', ''); return _.get(item, 'metadata.name', '');
...@@ -205,7 +206,6 @@ angular.module("openshiftCommonServices") ...@@ -205,7 +206,6 @@ angular.module("openshiftCommonServices")
return { return {
bindingResource: bindingResource, bindingResource: bindingResource,
getServiceClassForInstance: getServiceClassForInstance, getServiceClassForInstance: getServiceClassForInstance,
getPlanForInstance: getPlanForInstance,
// Create a binding for `serviceInstance`. If an `application` API object // Create a binding for `serviceInstance`. If an `application` API object
// is specified, also create a pod preset for that application using its // is specified, also create a pod preset for that application using its
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment