diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index a2c3c0fad..2c8397ecb 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -62,7 +62,7 @@ + pattern="{{ HOSTNAME_REGEX }}">
The HTTP host (and optionally the port number if a non-standard HTTP/HTTPS port) of the location where the registry will be accessible on the network @@ -121,7 +121,8 @@ + pattern="{{ HOSTNAME_REGEX }}" + validator="validateHostname(value)">> @@ -216,7 +217,8 @@ + pattern="{{ HOSTNAME_REGEX }}" + validator="validateHostname(value)">> @@ -377,7 +379,7 @@ + pattern="{{ GITHUB_REGEX }}">
The Github Enterprise endpoint. Must start with http:// or https://. @@ -509,7 +511,7 @@ + pattern="{{ GITHUB_REGEX }}">
The Github Enterprise endpoint. Must start with http:// or https://. diff --git a/static/directives/config/config-string-field.html b/static/directives/config/config-string-field.html index 5cbbe8a35..7714fd541 100644 --- a/static/directives/config/config-string-field.html +++ b/static/directives/config/config-string-field.html @@ -3,5 +3,8 @@ +
+ {{ errorMessage }} +
diff --git a/static/js/core-config-setup.js b/static/js/core-config-setup.js index e6a79d4b6..0b1f42e62 100644 --- a/static/js/core-config-setup.js +++ b/static/js/core-config-setup.js @@ -10,6 +10,9 @@ angular.module("core-config-setup", ['angularFileUpload']) 'isActive': '=isActive' }, controller: function($rootScope, $scope, $element, $timeout, ApiService) { + $scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9\.]+(:[0-9]+)?$'; + $scope.GITHUB_REGEX = '^https?://([a-zA-Z0-9]+\.?\/?)+$'; + $scope.SERVICES = [ {'id': 'redis', 'title': 'Redis'}, @@ -69,6 +72,14 @@ angular.module("core-config-setup", ['angularFileUpload']) ] }; + $scope.validateHostname = function(hostname) { + if (hostname.indexOf('127.0.0.1') == 0 || hostname.indexOf('localhost') == 0) { + return 'Please specify a non-localhost hostname. "localhost" will refer to the container, not your machine.' + } + + return null; + }; + $scope.config = null; $scope.mapped = { '$hasChanges': false @@ -719,7 +730,8 @@ angular.module("core-config-setup", ['angularFileUpload']) 'binding': '=binding', 'placeholder': '@placeholder', 'pattern': '@pattern', - 'defaultValue': '@defaultValue' + 'defaultValue': '@defaultValue', + 'validator': '&validator' }, controller: function($scope, $element) { $scope.getRegexp = function(pattern) { @@ -733,6 +745,8 @@ angular.module("core-config-setup", ['angularFileUpload']) if (!binding && $scope.defaultValue) { $scope.binding = $scope.defaultValue; } + + $scope.errorMessage = $scope.validator({'value': binding || ''}); }); } };