Skip to content

Commit

Permalink
update cluster links and option handling (#1420)
Browse files Browse the repository at this point in the history
bigtable: update cluster links and option handling
  • Loading branch information
callmehiphop authored and stephenplusplus committed Jul 12, 2016
1 parent 4bce495 commit 3f01f61
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ job.getQueryResults().on('data', function(row) {});
- [API Documentation][gcloud-bigtable-docs]
- [Official Documentation][cloud-bigtable-docs]

*You may need to [create a cluster][gcloud-bigtable-cluster] to use the Google Cloud Bigtable API with your project.*
*You may need to [create a cluster][cloud-bigtable-cluster] to use the Google Cloud Bigtable API with your project.*

#### Preview

Expand Down Expand Up @@ -741,7 +741,7 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
[cloud-bigquery-docs]: https://cloud.google.com/bigquery/what-is-bigquery

[cloud-bigtable-docs]: https://cloud.google.com/bigtable/docs/
[cloud-bigtable-cluster]: https://cloud.google.com/bigtable/docs/creating-cluster
[cloud-bigtable-cluster]: https://cloud.google.com/bigtable/docs/creating-compute-instance

[cloud-compute-docs]: https://cloud.google.com/compute/docs

Expand Down
13 changes: 6 additions & 7 deletions lib/bigtable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var googleProtoFiles = require('google-proto-files');
var is = require('is');
var nodeutil = require('util');
var format = require('string-format-obj');
var extend = require('extend');

/**
* @type {module:bigtable/table}
Expand Down Expand Up @@ -56,7 +57,7 @@ var util = require('../common/util.js');
* To learn more about Bigtable, read the
* [Google Cloud Bigtable Concepts Overview](https://cloud.google.com/bigtable/docs/concepts)
*
* @resource [Creating a Cloud Bigtable Cluster]{@link https://cloud.google.com/bigtable/docs/creating-cluster}
* @resource [Creating a Cloud Bigtable Cluster]{@link https://cloud.google.com/bigtable/docs/creating-compute-instance}
*
* @param {object=} options - [Configuration object](#/docs).
* @param {string} options.cluster - The cluster name that hosts your tables.
Expand All @@ -80,7 +81,7 @@ var util = require('../common/util.js');
* // Before you create your table, you first need to create a Bigtable Cluster
* // for the table to be served from. This can be done from either the
* // Google Cloud Platform Console or the `gcloud` cli tool. Please refer to
* // the <a href="https://cloud.google.com/bigtable/docs/creating-cluster">
* // the <a href="https://cloud.google.com/bigtable/docs/creating-compute-instance">
* // official Bigtable documentation</a> for more information.
* //-
*
Expand Down Expand Up @@ -280,11 +281,9 @@ function Bigtable(options) {
return new Bigtable(options);
}

options = {
projectId: options.projectId,
zone: options.zone.name || options.zone,
cluster: options.cluster
};
options = extend({}, options, {
zone: options.zone.name || options.zone
});

this.clusterName = format(
'projects/{projectId}/zones/{zone}/clusters/{cluster}',
Expand Down
18 changes: 18 additions & 0 deletions test/bigtable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ describe('Bigtable', function() {
fakeUtil.normalizeArguments = normalizeArguments;
});

it('should leave the original options unaltered', function() {
var fakeOptions = {
a: 'a',
b: 'b',
c: 'c',
zone: 'zone'
};

var bigtable = new Bigtable(fakeOptions);
var options = bigtable.calledWith_[1];

for (var option in fakeOptions) {
assert.strictEqual(fakeOptions[option], options[option]);
}

assert.notStrictEqual(fakeOptions, options);
});

it('should localize the cluster name', function() {
assert.strictEqual(bigtable.clusterName, CLUSTER_NAME);
});
Expand Down

0 comments on commit 3f01f61

Please sign in to comment.