YUKI Hiroshi
null+****@clear*****
Mon Oct 15 18:07:50 JST 2012
YUKI Hiroshi 2012-10-15 18:07:50 +0900 (Mon, 15 Oct 2012) New Revision: 4dee2fb28d5d55adb344b56d4c9f6166284ebb83 https://github.com/groonga/gcs/commit/4dee2fb28d5d55adb344b56d4c9f6166284ebb83 Log: Make gcs-create-domain based on HTTP APIs Modified files: bin/gcs-create-domain lib/command-line.js test/gcs-commands.test.js Modified: bin/gcs-create-domain (+18 -11) =================================================================== --- bin/gcs-create-domain 2012-10-15 17:56:15 +0900 (14f5ac4) +++ bin/gcs-create-domain 2012-10-15 18:07:50 +0900 (8e38e5a) @@ -12,14 +12,21 @@ commandLine commandLine.assertHaveDomainName(); -if (commandLine.domain.exists()) { - console.log('The domain [' + commandLine.domain.name + '] already exists.'); - return process.exit(1); -} - -console.log('Creating domain [' + commandLine.domain.name + ']'); - -commandLine.domain.createSync(); - -console.log('Domain endpoints are currently being created. ' + - 'Use gcs-describe-domain to check for endpoints.'); +var domainName = commandLine.domainName; +commandLine.getDomainStatus(domainName, function(error, domain) { + if (domain) { + console.log('The domain [' + domainName + '] already exists.'); + return process.exit(1); + } + console.log('Creating domain [' + domainName + ']'); + commandLine.cloudSearch.CreateDomain( + { DomainName: domainName }, + function(error, result) { + if (error) + commandLine.raiseFatalError(error); + console.log('Domain endpoints are currently being created. ' + + 'Use gcs-describe-domain to check for endpoints.'); + process.exit(0); + } + }); +}); Modified: lib/command-line.js (+1 -1) =================================================================== --- lib/command-line.js 2012-10-15 17:56:15 +0900 (dc983bc) +++ lib/command-line.js 2012-10-15 18:07:50 +0900 (ceddd96) @@ -144,7 +144,7 @@ CommandLineInterface.prototype = { if (domainStatuses.length && domainStatuses[0]) { callback(null, domainStatuses[0]); } else { - self.raiseFatalError(domainName + ' does not exist. You must specify an existing domain name.'); + callback(domainName + ' does not exist. You must specify an existing domain name.', null); } } ); Modified: test/gcs-commands.test.js (+6 -3) =================================================================== --- test/gcs-commands.test.js 2012-10-15 17:56:15 +0900 (1111f43) +++ test/gcs-commands.test.js 2012-10-15 18:07:50 +0900 (470af6d) @@ -46,7 +46,8 @@ suite('gcs-create-domain', function() { utils .run('gcs-create-domain', '--domain-name', 'test', - '--database-path', temporaryDatabase.path) + '--port', utils.testPort, + '--base-host', 'localhost:' + utils.testPort) .next(function(result) { assert.equal(result.code, 0, result.output.stderr); assert.include(result.output.stdout, @@ -68,7 +69,8 @@ suite('gcs-create-domain', function() { utils .run('gcs-create-domain', '--domain-name', 'test', - '--database-path', temporaryDatabase.path) + '--port', utils.testPort, + '--base-host', 'localhost:' + utils.testPort) .next(function(result) { assert.deepEqual({ code: result.code, message: result.output.stdout }, @@ -92,7 +94,8 @@ suite('gcs-create-domain', function() { test('missing domain name', function(done) { utils .run('gcs-create-domain', - '--database-path', temporaryDatabase.path) + '--port', utils.testPort, + '--base-host', 'localhost:' + utils.testPort) .next(function(result) { assertDomainNotSpecified(result); -------------- next part -------------- HTML����������������������������... ダウンロード