Skip to content

Commit a857823

Browse files
committed
[FAB-2122] Generalize GOLANG install path
We have a defunct configuration key to specify the chaincode install path, but it is not used. We also specify a chaincode specific binary name, which is not really necessary. Therefore we remove the defunct config item and implement a generic binary name to clean this up. Part of the fix for FAB-2122. Change-Id: I84f76862535f819e4f023b7822ec89b441e07a1e Signed-off-by: Greg Haskins <[email protected]>
1 parent cb13064 commit a857823

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

core/chaincode/chaincode_support.go

+13-20
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,6 @@ func NewChaincodeSupport(getPeerEndpoint func() (*pb.PeerEndpoint, error), userr
144144

145145
theChaincodeSupport.ccStartupTimeout = ccstartuptimeout
146146

147-
//TODO I'm not sure if this needs to be on a per chain basis... too lowel and just needs to be a global default ?
148-
theChaincodeSupport.chaincodeInstallPath = viper.GetString("chaincode.installpath")
149-
if theChaincodeSupport.chaincodeInstallPath == "" {
150-
theChaincodeSupport.chaincodeInstallPath = chaincodeInstallPathDefault
151-
}
152-
153147
theChaincodeSupport.peerTLS = viper.GetBool("peer.tls.enabled")
154148
if theChaincodeSupport.peerTLS {
155149
theChaincodeSupport.peerTLSCertFile = viper.GetString("peer.tls.cert.file")
@@ -198,19 +192,18 @@ func NewChaincodeSupport(getPeerEndpoint func() (*pb.PeerEndpoint, error), userr
198192

199193
// ChaincodeSupport responsible for providing interfacing with chaincodes from the Peer.
200194
type ChaincodeSupport struct {
201-
runningChaincodes *runningChaincodes
202-
peerAddress string
203-
ccStartupTimeout time.Duration
204-
chaincodeInstallPath string
205-
userRunsCC bool
206-
peerNetworkID string
207-
peerID string
208-
peerTLS bool
209-
peerTLSCertFile string
210-
peerTLSKeyFile string
211-
peerTLSSvrHostOrd string
212-
keepalive time.Duration
213-
chaincodeLogLevel string
195+
runningChaincodes *runningChaincodes
196+
peerAddress string
197+
ccStartupTimeout time.Duration
198+
userRunsCC bool
199+
peerNetworkID string
200+
peerID string
201+
peerTLS bool
202+
peerTLSCertFile string
203+
peerTLSKeyFile string
204+
peerTLSSvrHostOrd string
205+
keepalive time.Duration
206+
chaincodeLogLevel string
214207
}
215208

216209
// DuplicateChaincodeHandlerError returned if attempt to register same chaincodeID while a stream already exists.
@@ -356,7 +349,7 @@ func (chaincodeSupport *ChaincodeSupport) getArgsAndEnv(cccid *ccprovider.CCCont
356349
switch cLang {
357350
case pb.ChaincodeSpec_GOLANG, pb.ChaincodeSpec_CAR:
358351
//chaincode executable will be same as the name of the chaincode
359-
args = []string{chaincodeSupport.chaincodeInstallPath + cccid.Name, fmt.Sprintf("-peer.address=%s", chaincodeSupport.peerAddress)}
352+
args = []string{"chaincode", fmt.Sprintf("-peer.address=%s", chaincodeSupport.peerAddress)}
360353
chaincodeLogger.Debugf("Executable is %s", args[0])
361354
case pb.ChaincodeSpec_JAVA:
362355
//TODO add security args

core/chaincode/platforms/car/platform.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package car
1818

1919
import (
2020
"archive/tar"
21-
"fmt"
2221
"io/ioutil"
2322
"strings"
2423

@@ -46,13 +45,11 @@ func (carPlatform *Platform) GenerateDockerfile(cds *pb.ChaincodeDeploymentSpec)
4645

4746
var buf []string
4847

49-
spec := cds.ChaincodeSpec
50-
5148
//let the executable's name be chaincode ID's name
5249
buf = append(buf, cutil.GetDockerfileFromConfig("chaincode.car.Dockerfile"))
5350
buf = append(buf, "COPY codepackage.car /tmp/codepackage.car")
5451
// invoking directly for maximum JRE compatiblity
55-
buf = append(buf, fmt.Sprintf("RUN java -jar /usr/local/bin/chaintool buildcar /tmp/codepackage.car -o $GOPATH/bin/%s && rm /tmp/codepackage.car", spec.ChaincodeId.Name))
52+
buf = append(buf, "RUN java -jar /usr/local/bin/chaintool buildcar /tmp/codepackage.car -o /usr/local/bin/chaincode && rm /tmp/codepackage.car")
5653

5754
dockerFileContents := strings.Join(buf, "\n")
5855

core/chaincode/platforms/golang/platform.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ func (goPlatform *Platform) GenerateDockerfile(cds *pb.ChaincodeDeploymentSpec)
138138
}
139139

140140
buf = append(buf, cutil.GetDockerfileFromConfig("chaincode.golang.Dockerfile"))
141-
buf = append(buf, "ADD codepackage.tgz $GOPATH")
141+
buf = append(buf, "ADD codepackage.tgz /tmp/codepackage")
142142
//let the executable's name be chaincode ID's name
143-
buf = append(buf, fmt.Sprintf("RUN go build -o $GOPATH/bin/%s %s", spec.ChaincodeId.Name, urlLocation))
143+
buf = append(buf, fmt.Sprintf("RUN GOPATH=/tmp/codepackage:$GOPATH go build -o /usr/local/bin/chaincode %s", urlLocation))
144144

145145
dockerFileContents := strings.Join(buf, "\n")
146146

peer/core.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,6 @@ chaincode:
306306
#net - in net mode validator will run chaincode in a docker container
307307

308308
mode: net
309-
# typically installpath should not be modified. Otherwise, user must ensure
310-
# the chaincode executable is placed in the path specifed by installpath in
311-
# the image
312-
installpath: /opt/gopath/bin/
313309

314310
# keepalive in seconds. In situations where the communiction goes through a
315311
# proxy that does not support keep-alive, this parameter will maintain connection

0 commit comments

Comments
 (0)