-
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.
FAB-9604 Move container/vm.go to car test
The container/vm.go file is only used by the car platform test. There is no reason to export it in the production code. Change-Id: I519c75fe09bba51b165694e329241fee23f4268c Signed-off-by: Jason Yellick <[email protected]>
- Loading branch information
Jason Yellick
committed
May 2, 2018
1 parent
3d11489
commit ef600ce
Showing
6 changed files
with
100 additions
and
258 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package car_test | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/fsouza/go-dockerclient" | ||
"github.com/hyperledger/fabric/core/chaincode/platforms" | ||
"github.com/hyperledger/fabric/core/container" | ||
cutil "github.com/hyperledger/fabric/core/container/util" | ||
pb "github.com/hyperledger/fabric/protos/peer" | ||
) | ||
|
||
// VM implementation of VM management functionality. | ||
type VM struct { | ||
Client *docker.Client | ||
} | ||
|
||
// NewVM creates a new VM instance. | ||
func NewVM() (*VM, error) { | ||
client, err := cutil.NewDockerClient() | ||
if err != nil { | ||
return nil, err | ||
} | ||
VM := &VM{Client: client} | ||
return VM, nil | ||
} | ||
|
||
// BuildChaincodeContainer builds the container for the supplied chaincode specification | ||
func (vm *VM) BuildChaincodeContainer(spec *pb.ChaincodeSpec) error { | ||
codePackage, err := container.GetChaincodePackageBytes(spec) | ||
if err != nil { | ||
return fmt.Errorf("Error getting chaincode package bytes: %s", err) | ||
} | ||
|
||
cds := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackage} | ||
dockerSpec, err := platforms.GenerateDockerBuild(cds) | ||
if err != nil { | ||
return fmt.Errorf("Error getting chaincode docker image: %s", err) | ||
} | ||
|
||
output := bytes.NewBuffer(nil) | ||
|
||
err = vm.Client.BuildImage(docker.BuildImageOptions{ | ||
Name: spec.ChaincodeId.Name, | ||
InputStream: dockerSpec, | ||
OutputStream: output, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("Error building docker: %s (output = %s)", err, output.String()) | ||
} | ||
|
||
return nil | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.