@@ -22,6 +22,7 @@ import (
22
22
docker "github.com/fsouza/go-dockerclient"
23
23
"github.com/hyperledger/fabric/integration/helpers"
24
24
"github.com/hyperledger/fabric/integration/nwo/commands"
25
+ "github.com/hyperledger/fabric/integration/nwo/fabricconfig"
25
26
"github.com/hyperledger/fabric/integration/runner"
26
27
"github.com/onsi/ginkgo"
27
28
. "github.com/onsi/gomega"
@@ -30,6 +31,7 @@ import (
30
31
"github.com/tedsuo/ifrit"
31
32
"github.com/tedsuo/ifrit/ginkgomon"
32
33
"github.com/tedsuo/ifrit/grouper"
34
+ yaml "gopkg.in/yaml.v2"
33
35
)
34
36
35
37
// Organization models information about an Organization. It includes
@@ -246,6 +248,29 @@ func (n *Network) OrdererConfigPath(o *Orderer) string {
246
248
return filepath .Join (n .OrdererDir (o ), "orderer.yaml" )
247
249
}
248
250
251
+ // ReadOrdererConfig unmarshals an orderer's orderer.yaml and returns an
252
+ // object approximating its contents.
253
+ func (n * Network ) ReadOrdererConfig (o * Orderer ) * fabricconfig.Orderer {
254
+ var orderer fabricconfig.Orderer
255
+ ordererBytes , err := ioutil .ReadFile (n .OrdererConfigPath (o ))
256
+ Expect (err ).NotTo (HaveOccurred ())
257
+
258
+ err = yaml .Unmarshal (ordererBytes , & orderer )
259
+ Expect (err ).NotTo (HaveOccurred ())
260
+
261
+ return & orderer
262
+ }
263
+
264
+ // WriteOrdererConfig serializes the provided configuration as the specified
265
+ // orderer's orderer.yaml document.
266
+ func (n * Network ) WriteOrdererConfig (o * Orderer , config * fabricconfig.Orderer ) {
267
+ ordererBytes , err := yaml .Marshal (config )
268
+ Expect (err ).NotTo (HaveOccurred ())
269
+
270
+ err = ioutil .WriteFile (n .OrdererConfigPath (o ), ordererBytes , 0644 )
271
+ Expect (err ).NotTo (HaveOccurred ())
272
+ }
273
+
249
274
// PeerDir returns the path to the configuration directory for the specified
250
275
// Peer.
251
276
func (n * Network ) PeerDir (p * Peer ) string {
@@ -258,6 +283,29 @@ func (n *Network) PeerConfigPath(p *Peer) string {
258
283
return filepath .Join (n .PeerDir (p ), "core.yaml" )
259
284
}
260
285
286
+ // ReadPeerConfig unmarshals a peer's core.yaml and returns an object
287
+ // approximating its contents.
288
+ func (n * Network ) ReadPeerConfig (p * Peer ) * fabricconfig.Core {
289
+ var core fabricconfig.Core
290
+ coreBytes , err := ioutil .ReadFile (n .PeerConfigPath (p ))
291
+ Expect (err ).NotTo (HaveOccurred ())
292
+
293
+ err = yaml .Unmarshal (coreBytes , & core )
294
+ Expect (err ).NotTo (HaveOccurred ())
295
+
296
+ return & core
297
+ }
298
+
299
+ // WritePeerConfig serializes the provided configuration as the specified
300
+ // peer's core.yaml document.
301
+ func (n * Network ) WritePeerConfig (p * Peer , config * fabricconfig.Core ) {
302
+ coreBytes , err := yaml .Marshal (config )
303
+ Expect (err ).NotTo (HaveOccurred ())
304
+
305
+ err = ioutil .WriteFile (n .PeerConfigPath (p ), coreBytes , 0644 )
306
+ Expect (err ).NotTo (HaveOccurred ())
307
+ }
308
+
261
309
// PeerUserMSPDir returns the path to the MSP directory containing the
262
310
// certificates and keys for the specified user of the peer.
263
311
func (n * Network ) PeerUserMSPDir (p * Peer , user string ) string {
0 commit comments