Commit 46050b00 by Sam Padgett Committed by GitHub

Merge pull request #199 from spadgett/plans-resource

Adopt service catalog API changes
parents 1ae1d255 5a278b38
...@@ -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 getPlanForInstance = function(serviceInstance, serviceClass) { var serviceClassName = _.get(serviceInstance, 'spec.serviceClassRef.name');
var planName = _.get(serviceInstance, 'spec.planName'); if (!serviceClassName) {
return _.find(serviceClass.plans, { name: planName }); return null;
}
return serviceClasses[serviceClassName];
}; };
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
......
...@@ -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