Skip to content

Commit 6c2b12e

Browse files
committed
Merge branch 'bugfix/S3UTILS-227/compat' into tmp/octopus/w/1/bugfix/S3UTILS-227/compat
2 parents b1f7af1 + ec54481 commit 6c2b12e

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

replicationAudit/fix-missing-replication-permissions.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
const fs = require('fs');
3131
const http = require('http');
3232
const https = require('https');
33-
const { parseArgs } = require('util');
3433
const { Client: VaultClient } = require('vaultclient');
3534
const AWS = require('aws-sdk');
3635

@@ -49,17 +48,30 @@ function log(message) {
4948
}
5049

5150
// ===========================================================================
52-
// Argument parsing (Node.js 22+ built-in util.parseArgs)
51+
// Argument parsing (manual process.argv for Node 16+ compatibility)
5352
// ===========================================================================
5453
function getConfig() {
55-
const { values, positionals } = parseArgs({
56-
allowPositionals: true,
57-
options: {
58-
'iam-port': { type: 'string', default: '8600' },
59-
'https': { type: 'boolean', default: false },
60-
'dry-run': { type: 'boolean', default: false },
61-
},
62-
});
54+
const args = process.argv.slice(2);
55+
56+
const positionals = [];
57+
let iamPort = 8600;
58+
let useHttps = false;
59+
let dryRun = false;
60+
61+
for (let i = 0; i < args.length; i++) {
62+
if (args[i] === '--iam-port') {
63+
if (i + 1 >= args.length) {
64+
throw new Error('Missing value for --iam-port');
65+
}
66+
iamPort = parseInt(args[++i], 10);
67+
} else if (args[i] === '--https') {
68+
useHttps = true;
69+
} else if (args[i] === '--dry-run') {
70+
dryRun = true;
71+
} else {
72+
positionals.push(args[i]);
73+
}
74+
}
6375

6476
if (positionals.length < 3) {
6577
log('Usage: node fix-missing-replication-permissions.js'
@@ -72,11 +84,11 @@ function getConfig() {
7284
return {
7385
inputFile,
7486
vaultHost,
75-
iamPort: parseInt(values['iam-port'], 10),
87+
iamPort,
7688
adminConfig,
77-
useHttps: values.https,
89+
useHttps,
7890
outputFile: outputFile || 'replication-fix-results.json',
79-
dryRun: values['dry-run'],
91+
dryRun,
8092
};
8193
}
8294

0 commit comments

Comments
 (0)