Commit 39f1f70a by Jeffrey Phillips

Add BindingService and DNS1123_SUBDOMAIN_VALIDATION constant

parent 7e65a620
...@@ -996,6 +996,43 @@ angular.module('openshiftCommonServices') ...@@ -996,6 +996,43 @@ angular.module('openshiftCommonServices')
}); });
;'use strict'; ;'use strict';
angular.module("openshiftCommonServices")
.service("BindingService", function($filter, $q, DataService, DNS1123_SUBDOMAIN_VALIDATION){
var bindingResource = {
group: 'servicecatalog.k8s.io',
resource: 'bindings'
};
var makeBinding = function (serviceToBind) {
var generateName = $filter('generateName');
return {
kind: 'Binding',
apiVersion: 'servicecatalog.k8s.io/v1alpha1',
metadata: {
generateName: serviceToBind + '-'
},
spec: {
instanceRef: {
name: serviceToBind
},
secretName: generateName(_.trunc(serviceToBind, DNS1123_SUBDOMAIN_VALIDATION.maxlength - 6) + '-')
}
};
};
return {
bindingResource: bindingResource,
bindService: function(context, serviceToBind, appToBind) {
var newBinding = makeBinding(serviceToBind);
// TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context);
}
};
});
;'use strict';
angular.module('openshiftCommonServices') angular.module('openshiftCommonServices')
.factory('Constants', function() { .factory('Constants', function() {
var constants = _.clone(window.OPENSHIFT_CONSTANTS || {}); var constants = _.clone(window.OPENSHIFT_CONSTANTS || {});
......
...@@ -4,7 +4,15 @@ ...@@ -4,7 +4,15 @@
* @description * @description
* Base module for openshiftCommonUI. * Base module for openshiftCommonUI.
*/ */
angular.module('openshiftCommonUI', []); angular.module('openshiftCommonUI', [])
// DNS1123 subdomain patterns are used for name validation of many resources,
// including persistent volume claims, config maps, and secrets.
// See https://github.com/kubernetes/kubernetes/blob/master/pkg/api/validation/validation.go
.constant('DNS1123_SUBDOMAIN_VALIDATION', {
pattern: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-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.'
});
hawtioPluginLoader.addModule('openshiftCommonUI'); hawtioPluginLoader.addModule('openshiftCommonUI');
...@@ -82,8 +90,8 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -82,8 +90,8 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <div class=\"sub-title\">\n" + " <div class=\"sub-title\">\n" +
" The binding operation created the secret\n" + " The binding operation created the secret\n" +
" <a ng-if=\"ctrl.secretHref && 'secrets' | canI : 'list'\"\n" + " <a ng-if=\"ctrl.secretHref && 'secrets' | canI : 'list'\"\n" +
" ng-href=\"{{ctrl.secretHref}}\">{{ctrl.generatedSecretName}}</a>\n" + " ng-href=\"{{ctrl.secretHref}}\">{{ctrl.binding.spec.secretName}}</a>\n" +
" <span ng-if=\"!ctrl.secretHref || !('secrets' | canI : 'list')\">{{ctrl.generatedSecretName}}</span>\n" + " <span ng-if=\"!ctrl.secretHref || !('secrets' | canI : 'list')\">{{ctrl.binding.spec.secretName}}</span>\n" +
" that you may need to reference in your application.\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" + " <span ng-if=\"ctrl.showPodPresets\">Its data will be available to your application as environment variables.</span>\n" +
" </div>\n" + " </div>\n" +
...@@ -443,7 +451,6 @@ angular.module('openshiftCommonUI').component('bindResults', { ...@@ -443,7 +451,6 @@ angular.module('openshiftCommonUI').component('bindResults', {
progressInline: '@', progressInline: '@',
serviceToBind: '<', serviceToBind: '<',
applicationToBind: '<', applicationToBind: '<',
generatedSecretName: '<',
showPodPresets: '<', showPodPresets: '<',
secretHref: '<' secretHref: '<'
}, },
......
...@@ -175,7 +175,15 @@ hawtioPluginLoader.registerPreBootstrapTask(function(next) { ...@@ -175,7 +175,15 @@ hawtioPluginLoader.registerPreBootstrapTask(function(next) {
* @description * @description
* Base module for openshiftCommonUI. * Base module for openshiftCommonUI.
*/ */
angular.module('openshiftCommonUI', []); angular.module('openshiftCommonUI', [])
// DNS1123 subdomain patterns are used for name validation of many resources,
// including persistent volume claims, config maps, and secrets.
// See https://github.com/kubernetes/kubernetes/blob/master/pkg/api/validation/validation.go
.constant('DNS1123_SUBDOMAIN_VALIDATION', {
pattern: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-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.'
});
hawtioPluginLoader.addModule('openshiftCommonUI'); hawtioPluginLoader.addModule('openshiftCommonUI');
...@@ -253,8 +261,8 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -253,8 +261,8 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <div class=\"sub-title\">\n" + " <div class=\"sub-title\">\n" +
" The binding operation created the secret\n" + " The binding operation created the secret\n" +
" <a ng-if=\"ctrl.secretHref && 'secrets' | canI : 'list'\"\n" + " <a ng-if=\"ctrl.secretHref && 'secrets' | canI : 'list'\"\n" +
" ng-href=\"{{ctrl.secretHref}}\">{{ctrl.generatedSecretName}}</a>\n" + " ng-href=\"{{ctrl.secretHref}}\">{{ctrl.binding.spec.secretName}}</a>\n" +
" <span ng-if=\"!ctrl.secretHref || !('secrets' | canI : 'list')\">{{ctrl.generatedSecretName}}</span>\n" + " <span ng-if=\"!ctrl.secretHref || !('secrets' | canI : 'list')\">{{ctrl.binding.spec.secretName}}</span>\n" +
" that you may need to reference in your application.\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" + " <span ng-if=\"ctrl.showPodPresets\">Its data will be available to your application as environment variables.</span>\n" +
" </div>\n" + " </div>\n" +
...@@ -614,7 +622,6 @@ angular.module('openshiftCommonUI').component('bindResults', { ...@@ -614,7 +622,6 @@ angular.module('openshiftCommonUI').component('bindResults', {
progressInline: '@', progressInline: '@',
serviceToBind: '<', serviceToBind: '<',
applicationToBind: '<', applicationToBind: '<',
generatedSecretName: '<',
showPodPresets: '<', showPodPresets: '<',
secretHref: '<' secretHref: '<'
}, },
...@@ -2542,6 +2549,43 @@ angular.module('openshiftCommonServices') ...@@ -2542,6 +2549,43 @@ angular.module('openshiftCommonServices')
}); });
;'use strict'; ;'use strict';
angular.module("openshiftCommonServices")
.service("BindingService", ["$filter", "$q", "DataService", "DNS1123_SUBDOMAIN_VALIDATION", function($filter, $q, DataService, DNS1123_SUBDOMAIN_VALIDATION){
var bindingResource = {
group: 'servicecatalog.k8s.io',
resource: 'bindings'
};
var makeBinding = function (serviceToBind) {
var generateName = $filter('generateName');
return {
kind: 'Binding',
apiVersion: 'servicecatalog.k8s.io/v1alpha1',
metadata: {
generateName: serviceToBind + '-'
},
spec: {
instanceRef: {
name: serviceToBind
},
secretName: generateName(_.trunc(serviceToBind, DNS1123_SUBDOMAIN_VALIDATION.maxlength - 6) + '-')
}
};
};
return {
bindingResource: bindingResource,
bindService: function(context, serviceToBind, appToBind) {
var newBinding = makeBinding(serviceToBind);
// TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context);
}
};
}]);
;'use strict';
angular.module('openshiftCommonServices') angular.module('openshiftCommonServices')
.factory('Constants', function() { .factory('Constants', function() {
var constants = _.clone(window.OPENSHIFT_CONSTANTS || {}); var constants = _.clone(window.OPENSHIFT_CONSTANTS || {});
......
...@@ -72,8 +72,8 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -72,8 +72,8 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <div class=\"sub-title\">\n" + " <div class=\"sub-title\">\n" +
" The binding operation created the secret\n" + " The binding operation created the secret\n" +
" <a ng-if=\"ctrl.secretHref && 'secrets' | canI : 'list'\"\n" + " <a ng-if=\"ctrl.secretHref && 'secrets' | canI : 'list'\"\n" +
" ng-href=\"{{ctrl.secretHref}}\">{{ctrl.generatedSecretName}}</a>\n" + " ng-href=\"{{ctrl.secretHref}}\">{{ctrl.binding.spec.secretName}}</a>\n" +
" <span ng-if=\"!ctrl.secretHref || !('secrets' | canI : 'list')\">{{ctrl.generatedSecretName}}</span>\n" + " <span ng-if=\"!ctrl.secretHref || !('secrets' | canI : 'list')\">{{ctrl.binding.spec.secretName}}</span>\n" +
" that you may need to reference in your application.\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" + " <span ng-if=\"ctrl.showPodPresets\">Its data will be available to your application as environment variables.</span>\n" +
" </div>\n" + " </div>\n" +
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
<div class="sub-title"> <div class="sub-title">
The binding operation created the secret The binding operation created the secret
<a ng-if="ctrl.secretHref && 'secrets' | canI : 'list'" <a ng-if="ctrl.secretHref && 'secrets' | canI : 'list'"
ng-href="{{ctrl.secretHref}}">{{ctrl.generatedSecretName}}</a> ng-href="{{ctrl.secretHref}}">{{ctrl.binding.spec.secretName}}</a>
<span ng-if="!ctrl.secretHref || !('secrets' | canI : 'list')">{{ctrl.generatedSecretName}}</span> <span ng-if="!ctrl.secretHref || !('secrets' | canI : 'list')">{{ctrl.binding.spec.secretName}}</span>
that you may need to reference in your application. that you may need to reference in your application.
<span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span> <span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span>
</div> </div>
......
...@@ -8,7 +8,6 @@ angular.module('openshiftCommonUI').component('bindResults', { ...@@ -8,7 +8,6 @@ angular.module('openshiftCommonUI').component('bindResults', {
progressInline: '@', progressInline: '@',
serviceToBind: '<', serviceToBind: '<',
applicationToBind: '<', applicationToBind: '<',
generatedSecretName: '<',
showPodPresets: '<', showPodPresets: '<',
secretHref: '<' secretHref: '<'
}, },
......
...@@ -4,7 +4,15 @@ ...@@ -4,7 +4,15 @@
* @description * @description
* Base module for openshiftCommonUI. * Base module for openshiftCommonUI.
*/ */
angular.module('openshiftCommonUI', []); angular.module('openshiftCommonUI', [])
// DNS1123 subdomain patterns are used for name validation of many resources,
// including persistent volume claims, config maps, and secrets.
// See https://github.com/kubernetes/kubernetes/blob/master/pkg/api/validation/validation.go
.constant('DNS1123_SUBDOMAIN_VALIDATION', {
pattern: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-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.'
});
hawtioPluginLoader.addModule('openshiftCommonUI'); hawtioPluginLoader.addModule('openshiftCommonUI');
'use strict';
angular.module("openshiftCommonServices")
.service("BindingService", function($filter, $q, DataService, DNS1123_SUBDOMAIN_VALIDATION){
var bindingResource = {
group: 'servicecatalog.k8s.io',
resource: 'bindings'
};
var makeBinding = function (serviceToBind) {
var generateName = $filter('generateName');
return {
kind: 'Binding',
apiVersion: 'servicecatalog.k8s.io/v1alpha1',
metadata: {
generateName: serviceToBind + '-'
},
spec: {
instanceRef: {
name: serviceToBind
},
secretName: generateName(_.trunc(serviceToBind, DNS1123_SUBDOMAIN_VALIDATION.maxlength - 6) + '-')
}
};
};
return {
bindingResource: bindingResource,
bindService: function(context, serviceToBind, appToBind) {
var newBinding = makeBinding(serviceToBind);
// TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context);
}
};
});
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