Navigation Menu

Skip to content

Commit

Permalink
Accept port number as a part of base host and configuration host
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 15, 2012
1 parent a2b2afb commit 8b49677
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bin/gcs
Expand Up @@ -15,12 +15,12 @@ commandLine
String,
CLI.defaultPrivilegedRanges)
.option('--base-host <hostname>',
'The base host name assigned to this server '+
'The base host name assigned to the service '+
'[' + CLI.defaultBaseHost + ']',
String,
CLI.defaultBaseHost)
.option('--configuration-host <hostname>',
'The host name for configuration API of this server '+
'The host name for configuration API of the service '+
'[' + CLI.defaultConfigurationHost + ']',
String,
CLI.defaultConfigurationHost)
Expand Down
10 changes: 8 additions & 2 deletions lib/api/2011-02-01/configuration.js
Expand Up @@ -27,10 +27,16 @@ var handlers = Object.create(null);

function getBaseHostAndPort(config) {
var host = config.baseHost;
if (config.port == 80)
var port = config.port;
var portMatching = host.match(/:(\d+)$/);
if (portMatching) {
host = host.replace(portMatching[0], '');
port = parseInt(portMatching[1]);
}
if (port == 80)
return host;
else
return host + ':' + config.port;
return host + ':' + port;
}

function createDomainStatus(options) {
Expand Down
4 changes: 2 additions & 2 deletions lib/command-line.js
Expand Up @@ -12,10 +12,10 @@ var defaultPort =
CommandLineInterface.defaultPort = 7575;
var defaultBaseHost =
exports.defaultBaseHost =
CommandLineInterface.defaultBaseHost = '127.0.0.1.xip.io';
CommandLineInterface.defaultBaseHost = '127.0.0.1.xip.io:' + defaultPort;
var defaultConfigurationHost =
exports.defaultConfigurationHost =
CommandLineInterface.defaultConfigurationHost = '127.0.0.1.xip.io';
CommandLineInterface.defaultConfigurationHost = '127.0.0.1.xip.io:' + defaultPort;
var defaultPrivilegedRanges =
exports.defaultPrivilegedRanges =
CommandLineInterface.defaultPrivilegedRanges = '127.0.0.0/8';
Expand Down
8 changes: 4 additions & 4 deletions test/api-configuration.test.js
Expand Up @@ -337,7 +337,7 @@ suite('Configuration API', function() {
Created: 'true',
Deleted: 'false',
DocService: {
Endpoint: domain.getDocumentsEndpoint('localhost:' + utils.testPort)
Endpoint: domain.getDocumentsEndpoint('api.localhost')
},
DomainId: domain.domainId,
DomainName: domain.name,
Expand All @@ -346,7 +346,7 @@ suite('Configuration API', function() {
SearchInstanceCount: String(domain.searchInstanceCount),
SearchPartitionCount: String(domain.searchPartitionCount),
SearchService: {
Endpoint: domain.getSearchEndpoint('localhost:' + utils.testPort)
Endpoint: domain.getSearchEndpoint('api.localhost')
}
};
var status = response.body.CreateDomainResponse.CreateDomainResult.DomainStatus;
Expand Down Expand Up @@ -383,7 +383,7 @@ suite('Configuration API', function() {
Created: 'false',
Deleted: 'true',
DocService: {
Endpoint: domain.getDocumentsEndpoint('localhost:' + utils.testPort)
Endpoint: domain.getDocumentsEndpoint('api.localhost')
},
DomainId: domain.domainId,
DomainName: domain.name,
Expand All @@ -392,7 +392,7 @@ suite('Configuration API', function() {
SearchInstanceCount: String(domain.searchInstanceCount),
SearchPartitionCount: String(domain.searchPartitionCount),
SearchService: {
Endpoint: domain.getSearchEndpoint('localhost:' + utils.testPort)
Endpoint: domain.getSearchEndpoint('api.localhost')
}
};
var status = response.body.DeleteDomainResponse.DeleteDomainResult.DomainStatus;
Expand Down
4 changes: 2 additions & 2 deletions test/test-utils.js
Expand Up @@ -11,8 +11,8 @@ var spawn = require('child_process').spawn;

var temporaryDirectory = exports.temporaryDirectory = path.join(__dirname, 'tmp');

var testBaseHost = 'localhost';
var testConfigurationHost = 'configuration.localhost';
var testBaseHost = 'api.localhost:80';
var testConfigurationHost = 'configuration.localhost:80';
var testPort = 3333;
exports.testBaseHost = testBaseHost;
exports.testConfigurationHost = testConfigurationHost;
Expand Down

0 comments on commit 8b49677

Please sign in to comment.