Skip to content

Commit b76fbf9

Browse files
committed
moved copyNodeKeysToStaging from node.mjs to key_manager.mjs
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 49b0195 commit b76fbf9

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/commands/node.mjs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,6 @@ export class NodeCommand extends BaseCommand {
457457
}
458458

459459
// TODO: move to KeyManager
460-
async copyNodeKeysToStaging (nodeKey, destDir) {
461-
for (const keyFile of [nodeKey.privateKeyFile, nodeKey.certificateFile]) {
462-
if (!fs.existsSync(keyFile)) {
463-
throw new FullstackTestingError(`file (${keyFile}) is missing`)
464-
}
465-
466-
const fileName = path.basename(keyFile)
467-
fs.cpSync(keyFile, path.join(destDir, fileName))
468-
}
469-
}
470-
471460
async initializeSetup (config, k8) {
472461
// compute other config parameters
473462
config.keysDir = path.join(validatePath(config.cacheDir), 'keys')
@@ -801,7 +790,7 @@ export class NodeCommand extends BaseCommand {
801790
for (const nodeId of ctx.config.nodeIds) {
802791
const config = /** @type {NodeSetupConfigClass} **/ ctx.config
803792
const tlsKeyFiles = self.keyManager.prepareTLSKeyFilePaths(nodeId, config.keysDir)
804-
await self.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir)
793+
await self.keyManager.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir)
805794
}
806795
}
807796
}
@@ -1888,7 +1877,7 @@ export class NodeCommand extends BaseCommand {
18881877
const config = /** @type {NodeAddConfigClass} **/ ctx.config
18891878
for (const nodeId of config.allNodeIds) {
18901879
const tlsKeyFiles = self.keyManager.prepareTLSKeyFilePaths(nodeId, config.keysDir)
1891-
await self.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir)
1880+
await self.keyManager.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir)
18921881
}
18931882
}
18941883
}
@@ -2151,11 +2140,11 @@ export class NodeCommand extends BaseCommand {
21512140
switch (keyFormat) {
21522141
case constants.KEY_FORMAT_PEM: {
21532142
const signingKeyFiles = this.keyManager.prepareNodeKeyFilePaths(nodeId, keysDir, constants.SIGNING_KEY_PREFIX)
2154-
await this.copyNodeKeysToStaging(signingKeyFiles, stagingKeysDir)
2143+
await this.keyManager.copyNodeKeysToStaging(signingKeyFiles, stagingKeysDir)
21552144

21562145
// generate missing agreement keys
21572146
const agreementKeyFiles = this.keyManager.prepareNodeKeyFilePaths(nodeId, keysDir, constants.AGREEMENT_KEY_PREFIX)
2158-
await this.copyNodeKeysToStaging(agreementKeyFiles, stagingKeysDir)
2147+
await this.keyManager.copyNodeKeysToStaging(agreementKeyFiles, stagingKeysDir)
21592148
break
21602149
}
21612150

src/core/key_manager.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,15 @@ export class KeyManager {
666666

667667
return publicPfxFile
668668
}
669+
670+
async copyNodeKeysToStaging (nodeKey, destDir) {
671+
for (const keyFile of [nodeKey.privateKeyFile, nodeKey.certificateFile]) {
672+
if (!fs.existsSync(keyFile)) {
673+
throw new FullstackTestingError(`file (${keyFile}) is missing`)
674+
}
675+
676+
const fileName = path.basename(keyFile)
677+
fs.cpSync(keyFile, path.join(destDir, fileName))
678+
}
679+
}
669680
}

0 commit comments

Comments
 (0)