Skip to content

Commit

Permalink
[FAB-2122] Simplify the go-install directives
Browse files Browse the repository at this point in the history
We clean up some unecessary logic related to creating
chaincode binaries with a desired name.

This refactor lays the groundwork for FAB-2122 fixes
later in the series.

Change-Id: I3ad8c6f7701ef5bb8e8f148f8c8f58ea3e0d9587
Signed-off-by: Greg Haskins <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Feb 14, 2017
1 parent 9b2612a commit 512265f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions core/chaincode/platforms/golang/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,10 @@ func (goPlatform *Platform) GenerateDockerfile(cds *pb.ChaincodeDeploymentSpec)
return "", fmt.Errorf("could not decode url: %s", err)
}

toks := strings.Split(urlLocation, "/")
if toks == nil || len(toks) == 0 {
return "", fmt.Errorf("cannot get path components from %s", urlLocation)
}

chaincodeGoName := toks[len(toks)-1]
if chaincodeGoName == "" {
return "", fmt.Errorf("could not get chaincode name from path %s", urlLocation)
}

buf = append(buf, cutil.GetDockerfileFromConfig("chaincode.golang.Dockerfile"))
buf = append(buf, "ADD codepackage.tgz $GOPATH")
//let the executable's name be chaincode ID's name
buf = append(buf, fmt.Sprintf("RUN go install %s && mv $GOPATH/bin/%s $GOPATH/bin/%s", urlLocation, chaincodeGoName, spec.ChaincodeId.Name))
buf = append(buf, fmt.Sprintf("RUN go build -o $GOPATH/bin/%s %s", spec.ChaincodeId.Name, urlLocation))

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

Expand Down

0 comments on commit 512265f

Please sign in to comment.