-
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.
Merge "Minor restructure of externalbuilders"
- Loading branch information
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.