@@ -22,6 +22,7 @@ import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } fro
22
22
import { constants } from './index.mjs'
23
23
import { Templates } from './templates.mjs'
24
24
import { flags } from '../commands/index.mjs'
25
+ import * as Base64 from 'js-base64'
25
26
26
27
/**
27
28
* PlatformInstaller install platform code in the root-container of a network pod
@@ -171,13 +172,27 @@ export class PlatformInstaller {
171
172
throw new FullstackTestingError ( `Unsupported key file format ${ keyFormat } ` )
172
173
}
173
174
175
+ const data = { }
176
+ for ( const srcFile of srcFiles ) {
177
+ const fileContents = fs . readFileSync ( srcFile )
178
+ const fileName = path . basename ( srcFile )
179
+ data [ fileName ] = Base64 . encode ( fileContents )
180
+ }
181
+
182
+ if ( ! await this . k8 . createSecret (
183
+ Templates . renderGossipKeySecretName ( nodeId ) ,
184
+ this . _getNamespace ( ) , 'Opaque' , data ,
185
+ Templates . renderGossipKeySecretLabelObject ( nodeId ) , true ) ) {
186
+ this . logger . error ( `failed to create secret for gossip keys for node '${ nodeId } '` )
187
+ throw new FullstackTestingError ( `failed to create secret for gossip keys for node '${ nodeId } '` )
188
+ }
189
+
174
190
return await self . copyFiles ( podName , srcFiles , keysDir )
175
191
} catch ( e ) {
176
192
throw new FullstackTestingError ( `failed to copy gossip keys to pod '${ podName } ': ${ e . message } ` , e )
177
193
}
178
194
}
179
195
180
- // TODO: update to copy the keys to the k8s secrets
181
196
async copyTLSKeys ( podName , stagingDir ) {
182
197
if ( ! podName ) throw new MissingArgumentError ( 'podName is required' )
183
198
if ( ! stagingDir ) throw new MissingArgumentError ( 'stagingDir is required' )
@@ -196,6 +211,8 @@ export class PlatformInstaller {
196
211
srcFiles . push ( path . join ( tmpDir , 'hedera.key' ) )
197
212
srcFiles . push ( path . join ( tmpDir , 'hedera.crt' ) )
198
213
214
+ // TODO: create secret and store in network-node-hapi-app-secrets, hedera-{{ $node.name }}.crt, hedera-{{ $node.name }}.key
215
+
199
216
return this . copyFiles ( podName , srcFiles , constants . HEDERA_HAPI_PATH )
200
217
} catch ( e ) {
201
218
throw new FullstackTestingError ( `failed to copy TLS keys to pod '${ podName } ': ${ e . message } ` , e )
0 commit comments