Skip to content

Commit aa2b207

Browse files
author
Bennett Buchanan
committed
bugfix: ZENKO-315 Update create NFS bucket script
* Add node shebang to NFS util * Add location constraint parameter
1 parent 5175639 commit aa2b207

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

bin/create_bucket_with_NFS_enabled.js

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env node
22
'use strict'; // eslint-disable-line strict
33

44
require('../lib/nfs/utilities.js').createBucketWithNFSEnabled();

lib/nfs/utilities.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const https = require('https');
55
const logger = require('../utilities/logger');
66

77
function _createBucketWithNFSEnabled(host, port, bucketName, accessKey,
8-
secretKey, verbose, ssl) {
8+
secretKey, verbose, ssl, locationConstraint) {
99
const options = {
1010
host,
1111
port,
@@ -46,6 +46,13 @@ function _createBucketWithNFSEnabled(host, port, bucketName, accessKey,
4646
if (verbose) {
4747
logger.info('request headers', { headers: request._headers });
4848
}
49+
if (locationConstraint) {
50+
const createBucketConfiguration = '<CreateBucketConfiguration ' +
51+
'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' +
52+
`<LocationConstraint>${locationConstraint}</LocationConstraint>` +
53+
'</CreateBucketConfiguration >';
54+
request.write(createBucketConfiguration);
55+
}
4956
request.end();
5057
}
5158

@@ -66,18 +73,20 @@ function createBucketWithNFSEnabled() {
6673
.option('-p, --port <port>', 'Port of the server')
6774
.option('-s', '--ssl', 'Enable ssl')
6875
.option('-v, --verbose')
76+
.option('-l, --location-constraint <locationConstraint>',
77+
'location Constraint')
6978
.parse(process.argv);
7079

7180
const { host, port, accessKey, secretKey, bucket, verbose,
72-
ssl } = commander;
81+
ssl, locationConstraint } = commander;
7382

7483
if (!host || !port || !accessKey || !secretKey || !bucket) {
7584
logger.error('missing parameter');
7685
commander.outputHelp();
7786
process.exit(1);
7887
}
7988
_createBucketWithNFSEnabled(host, port, bucket, accessKey, secretKey,
80-
verbose, ssl);
89+
verbose, ssl, locationConstraint);
8190
}
8291

8392
module.exports = {

0 commit comments

Comments
 (0)