Skip to content

Commit

Permalink
[FAB-16310] Vendor Go dependencies in all samples
Browse files Browse the repository at this point in the history
All samples that deploy Go chaincode must now vendor
their dependencies before deployment, due to changes
in FAB-5177 which stop the shim being available at
deployment time. This CR adds the command:

"GO111MODULE=on go mod vendor"

... to all scripts/readmes as appropriate.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: If0a2cc3a20dc943917d8325a8905427a79eb2400
  • Loading branch information
Simon Stone committed Aug 15, 2019
1 parent 0063abe commit ce154e0
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 2 deletions.
8 changes: 8 additions & 0 deletions first-network/byfn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ function networkUp() {
sleep 14
fi

if [ "${NO_CHAINCODE}" != "true" ]; then
echo Vendoring Go dependencies ...
pushd ../chaincode/abstore/go
GO111MODULE=on go mod vendor
popd
echo Finished vendoring Go dependencies
fi

# now run the end to end script
docker exec cli scripts/script.sh $CHANNEL_NAME $CLI_DELAY $CC_SRC_LANGUAGE $CLI_TIMEOUT $VERBOSE $NO_CHAINCODE
if [ $? -ne 0 ]; then
Expand Down
5 changes: 5 additions & 0 deletions high-throughput/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ and run some invocations are provided below.
4. Open a new terminal window and enter the CLI container using `docker exec -it cli bash`, all operations on the network will happen within
this container from now on.

### Vendor the chaincode dependencies
1. Outside of the CLI container, change into the chaincode directory, e.g. `cd ~/fabric-samples/high-throughput/chaincode`
2. Vendor the Go dependencies by running the following command: `GO111MODULE=on go mod vendor`
3. The chaincode directory will now contain a `vendor` directory.

### Install and define the chaincode
1. Once you're in the CLI container run `cd scripts` to enter the `scripts` folder
2. Set-up the environment variables by running `source setclienv.sh`
Expand Down
18 changes: 18 additions & 0 deletions interest_rate_swaps/chaincode/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module github.com/hyperledger/fabric-samples/interest_rate_swaps/chaincode

go 1.12

require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Shopify/sarama v1.22.1 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hyperledger/fabric v2.0.0-alpha.0.20190624224950-f2b8fef8859c+incompatible
github.com/hyperledger/fabric-amcl v0.0.0-20181230093703-5ccba6eab8d6 // indirect
github.com/miekg/pkcs11 v1.0.2 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/spf13/viper v1.4.0 // indirect
github.com/sykesm/zap-logfmt v0.0.2 // indirect
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 // indirect
google.golang.org/grpc v1.21.1 // indirect
)
175 changes: 175 additions & 0 deletions interest_rate_swaps/chaincode/go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions interest_rate_swaps/network/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
channel-artifacts/
crypto-config/
5 changes: 5 additions & 0 deletions interest_rate_swaps/network/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ function networkUp() {
echo "ERROR !!!! Unable to start network"
exit 1
fi
echo Vendoring Go dependencies ...
pushd ../chaincode
GO111MODULE=on go mod vendor
popd
echo Finished vendoring Go dependencies
# now run the end to end script
docker exec cli scripts/script.sh
if [ $? -ne 0 ]; then
Expand Down
8 changes: 6 additions & 2 deletions off_chain_data/startFabric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ set -e pipefail
# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1
starttime=$(date +%s)
CC_SRC_LANGUAGE=${1:-"golang"}
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
CC_SRC_LANGUAGE=golang
CC_RUNTIME_LANGUAGE=golang
CC_SRC_PATH=github.com/hyperledger/fabric-samples/chaincode/marbles02/go
echo Vendoring Go dependencies ...
pushd ../chaincode/marbles02/go
GO111MODULE=on go mod vendor
popd
echo Finished vendoring Go dependencies

# clean the keystore
rm -rf ./hfc-key-store
Expand Down

0 comments on commit ce154e0

Please sign in to comment.