@@ -27,7 +27,6 @@ import (
27
27
"github.com/hyperledger/fabric/core/common/ccprovider"
28
28
"github.com/hyperledger/fabric/core/container"
29
29
"github.com/hyperledger/fabric/core/container/ccintf"
30
- cutil "github.com/hyperledger/fabric/core/container/util"
31
30
pb "github.com/hyperledger/fabric/protos/peer"
32
31
"github.com/pkg/errors"
33
32
)
@@ -291,13 +290,18 @@ func (vm *DockerVM) Start(ccid ccintf.CCID, ccType string, peerConnection *ccint
291
290
tw := tar .NewWriter (gw )
292
291
293
292
// Note, we goofily base64 encode 2 of the TLS artifacts but not the other for strange historical reasons
294
- cutil .WriteBytesToPackage (TLSClientKeyPath , []byte (base64 .StdEncoding .EncodeToString (peerConnection .TLSConfig .ClientKey )), tw )
295
- cutil .WriteBytesToPackage (TLSClientCertPath , []byte (base64 .StdEncoding .EncodeToString (peerConnection .TLSConfig .ClientCert )), tw )
296
- cutil .WriteBytesToPackage (TLSClientRootCertPath , peerConnection .TLSConfig .RootCert , tw )
293
+ err = addFiles (tw , map [string ][]byte {
294
+ TLSClientKeyPath : []byte (base64 .StdEncoding .EncodeToString (peerConnection .TLSConfig .ClientKey )),
295
+ TLSClientCertPath : []byte (base64 .StdEncoding .EncodeToString (peerConnection .TLSConfig .ClientCert )),
296
+ TLSClientRootCertPath : peerConnection .TLSConfig .RootCert ,
297
+ })
298
+ if err != nil {
299
+ return fmt .Errorf ("error writing files to upload to Docker instance into a temporary tar blob: %s" , err )
300
+ }
297
301
298
302
// Write the tar file out
299
303
if err := tw .Close (); err != nil {
300
- return fmt .Errorf ("Error writing files to upload to Docker instance into a temporary tar blob: %s" , err )
304
+ return fmt .Errorf ("error writing files to upload to Docker instance into a temporary tar blob: %s" , err )
301
305
}
302
306
303
307
gw .Close ()
@@ -323,6 +327,26 @@ func (vm *DockerVM) Start(ccid ccintf.CCID, ccType string, peerConnection *ccint
323
327
return nil
324
328
}
325
329
330
+ func addFiles (tw * tar.Writer , contents map [string ][]byte ) error {
331
+ for name , payload := range contents {
332
+ err := tw .WriteHeader (& tar.Header {
333
+ Name : name ,
334
+ Size : int64 (len (payload )),
335
+ Mode : 0100644 ,
336
+ })
337
+ if err != nil {
338
+ return err
339
+ }
340
+
341
+ _ , err = tw .Write (payload )
342
+ if err != nil {
343
+ return err
344
+ }
345
+ }
346
+
347
+ return nil
348
+ }
349
+
326
350
// streamOutput mirrors output from the named container to a fabric logger.
327
351
func streamOutput (logger * flogging.FabricLogger , client dockerClient , containerName string , containerLogger * flogging.FabricLogger ) {
328
352
// Launch a few go routines to manage output streams from the container.
0 commit comments