getChaincodeSpec get chaincode spec from the cli cmd parameters
(cmd *cobra.Command)
| 34 | |
| 35 | // getChaincodeSpec get chaincode spec from the cli cmd parameters |
| 36 | func getChaincodeSpec(cmd *cobra.Command) (*pb.ChaincodeSpec, error) { |
| 37 | spec := &pb.ChaincodeSpec{} |
| 38 | if err := checkChaincodeCmdParams(cmd); err != nil { |
| 39 | // unset usage silence because it's a command line usage error |
| 40 | cmd.SilenceUsage = false |
| 41 | return spec, err |
| 42 | } |
| 43 | |
| 44 | // Build the spec |
| 45 | input := chaincodeInput{} |
| 46 | if err := json.Unmarshal([]byte(chaincodeCtorJSON), &input); err != nil { |
| 47 | return spec, errors.Wrap(err, "chaincode argument error") |
| 48 | } |
| 49 | input.IsInit = isInit |
| 50 | |
| 51 | chaincodeLang = strings.ToUpper(chaincodeLang) |
| 52 | spec = &pb.ChaincodeSpec{ |
| 53 | Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]), |
| 54 | ChaincodeId: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName, Version: chaincodeVersion}, |
| 55 | Input: &input.ChaincodeInput, |
| 56 | } |
| 57 | return spec, nil |
| 58 | } |
| 59 | |
| 60 | // chaincodeInput is wrapper around the proto defined ChaincodeInput message that |
| 61 | // is decorated with a custom JSON unmarshaller. |
no test coverage detected