-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-ssl-secret.js
31 lines (25 loc) · 1018 Bytes
/
build-ssl-secret.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const fs = require('fs');
const args = process.argv.slice(2);
const certsDirectory = args[0];
const secretName = 'ssl-certificates';
if (!certsDirectory) {
console.error('Usage: node build-ssl-secret certs_directory');
throw new Error('Incorrect usage');
}
else {
console.log(`Building ${secretName} secret from directory ${certsDirectory}`);
}
const secret = {
kind: 'Secret',
apiVersion: 'v1',
metadata: {
name: secretName
},
data: {}
}
secret.data['starbigwednesdayio.crt'] = fs.readFileSync(`${certsDirectory}/starbigwednesdayio.crt`).toString('base64');
secret.data['starbigwednesdayio.key'] = fs.readFileSync(`${certsDirectory}/starbigwednesdayio.key`).toString('base64');
secret.data['starorderableco.crt'] = fs.readFileSync(`${certsDirectory}/starorderableco.crt`).toString('base64');
secret.data['starorderableco.key'] = fs.readFileSync(`${certsDirectory}/starorderableco.key`).toString('base64');
fs.writeFileSync(`${secretName}-secret.json`, JSON.stringify(secret));