From b91930dba2fb302ae77c1b315c601c3e0819c032 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 9 Feb 2015 17:55:46 -0500 Subject: [PATCH] Have DB setup warn about "localhost" --- static/js/controllers/setup.js | 10 ++++++++++ static/partials/setup.html | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/static/js/controllers/setup.js b/static/js/controllers/setup.js index d156d7d9c..e3f6b0772 100644 --- a/static/js/controllers/setup.js +++ b/static/js/controllers/setup.js @@ -3,6 +3,16 @@ function SetupCtrl($scope, $timeout, ApiService, Features, UserService, Containe return; } + $scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9\.]+(:[0-9]+)?$'; + + $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; + }; + // Note: The values of the enumeration are important for isStepFamily. For example, // *all* states under the "configuring db" family must start with "config-db". $scope.States = { diff --git a/static/partials/setup.html b/static/partials/setup.html index d36b172cd..644f4c070 100644 --- a/static/partials/setup.html +++ b/static/partials/setup.html @@ -163,7 +163,9 @@ Database Server: + placeholder="dbserverhost" + pattern="{{ HOSTNAME_REGEX }}" + validator="validateHostname(value)">>
The server (and optionally, custom port) where the database lives