-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor restructure of externalbuilders
- extract Instance to its own file - convert NewCommand to a method on Builder - minor white space changes FAB-16108 Change-Id: I8cf70f1a43a565fc3715027e0d93021c1b656f02 Signed-off-by: Matthew Sykes <[email protected]>
- Loading branch information
1 parent
1b99fdd
commit af55876
Showing
4 changed files
with
175 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package externalbuilders | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/hyperledger/fabric/core/container/ccintf" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
type Instance struct { | ||
PackageID string | ||
BldDir string | ||
Builder *Builder | ||
RunStatus *RunStatus | ||
} | ||
|
||
func (i *Instance) Start(peerConnection *ccintf.PeerConnection) error { | ||
rs, err := i.Builder.Run(i.PackageID, i.BldDir, peerConnection) | ||
if err != nil { | ||
return errors.WithMessage(err, "could not execute run") | ||
} | ||
i.RunStatus = rs | ||
return nil | ||
} | ||
|
||
func (i *Instance) Stop() error { | ||
return errors.Errorf("stop is not implemented for external builders yet") | ||
} | ||
|
||
func (i *Instance) Wait() (int, error) { | ||
if i.RunStatus == nil { | ||
return 0, errors.Errorf("instance was not successfully started") | ||
} | ||
<-i.RunStatus.Done() | ||
err := i.RunStatus.Err() | ||
if exitErr, ok := errors.Cause(err).(*exec.ExitError); ok { | ||
return exitErr.ExitCode(), err | ||
} | ||
return 0, err | ||
} |
Oops, something went wrong.