Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion kubectl-hlf/cmd/chaincode/queryapproved.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package chaincode
import (
"encoding/json"
"fmt"
"io"

"github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
"github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"io"
)

type queryApprovedCmd struct {
Expand All @@ -18,6 +19,7 @@ type queryApprovedCmd struct {
userName string
channelName string
chaincodeName string
output string
}

func (c *queryApprovedCmd) validate() error {
Expand Down Expand Up @@ -59,6 +61,17 @@ func (c *queryApprovedCmd) run(out io.Writer) error {
},
resmgmt.WithTargetEndpoints(peerName),
)
if err != nil {
return err
}
if c.output == "json" {
b, err := json.MarshalIndent(chaincode, "", " ")
if err != nil {
return err
}
_, err = out.Write(b)
return err
}
signaturePolicyBytes, err := json.Marshal(chaincode.SignaturePolicy)
if err != nil {
return err
Expand Down Expand Up @@ -99,6 +112,7 @@ func newQueryApprovedCMD(out io.Writer, errOut io.Writer) *cobra.Command {
persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK")
persistentFlags.StringVarP(&c.channelName, "channel", "C", "", "Channel name")
persistentFlags.StringVarP(&c.chaincodeName, "chaincode", "c", "", "Chaincode label")
persistentFlags.StringVarP(&c.output, "output", "o", "table", "Output format, can be table or json")
cmd.MarkPersistentFlagRequired("user")
cmd.MarkPersistentFlagRequired("peer")
cmd.MarkPersistentFlagRequired("config")
Expand Down
13 changes: 12 additions & 1 deletion kubectl-hlf/cmd/chaincode/querycommitted.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package chaincode
import (
"encoding/json"
"fmt"
"io"

"github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
"github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers"
"github.com/olekukonko/tablewriter"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"io"
)

type queryCommittedCmd struct {
Expand All @@ -19,6 +20,7 @@ type queryCommittedCmd struct {
userName string
channelName string
chaincodeName string
output string
}

func (c *queryCommittedCmd) validate() error {
Expand Down Expand Up @@ -67,6 +69,14 @@ func (c *queryCommittedCmd) run(out io.Writer) error {
log.Infof("No chaincode found")
return nil
}
if c.output == "json" {
b, err := json.MarshalIndent(chaincodes, "", " ")
if err != nil {
return err
}
_, err = out.Write(b)
return err
}
var data [][]string
for _, chaincode := range chaincodes {
approvalJson, err := json.Marshal(chaincode.Approvals)
Expand Down Expand Up @@ -121,6 +131,7 @@ func newQueryCommittedCMD(out io.Writer, errOut io.Writer) *cobra.Command {
persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK")
persistentFlags.StringVarP(&c.channelName, "channel", "C", "", "Channel name")
persistentFlags.StringVarP(&c.chaincodeName, "chaincode", "c", "", "Chaincode label")
persistentFlags.StringVarP(&c.output, "output", "o", "table", "Output format, can be table or json")
cmd.MarkPersistentFlagRequired("user")
cmd.MarkPersistentFlagRequired("peer")
cmd.MarkPersistentFlagRequired("config")
Expand Down
13 changes: 12 additions & 1 deletion kubectl-hlf/cmd/chaincode/queryinstalled.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ package chaincode

import (
"encoding/json"
"io"

"github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
"github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers"
"github.com/olekukonko/tablewriter"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"io"
)

type queryInstalledCmd struct {
configPath string
peer string
userName string
mspID string
output string
}

func (c *queryInstalledCmd) validate() error {
Expand Down Expand Up @@ -66,6 +68,14 @@ func (c *queryInstalledCmd) run(out io.Writer) error {
log.Infof("No chaincodes installed")
return nil
}
if c.output == "json" {
b, err := json.MarshalIndent(chaincodes, "", " ")
if err != nil {
return err
}
_, err = out.Write(b)
return err
}
var data [][]string
for _, chaincode := range chaincodes {
referencesJson, err := json.Marshal(chaincode.References)
Expand Down Expand Up @@ -109,6 +119,7 @@ func newChaincodeQueryInstalledCMD(out io.Writer, errOut io.Writer) *cobra.Comma
persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction")
persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK")
persistentFlags.StringVarP(&c.mspID, "mspID", "", "", "MSP ID of the peer")
persistentFlags.StringVarP(&c.output, "output", "o", "table", "Output format, can be table or json")
cmd.MarkPersistentFlagRequired("user")
cmd.MarkPersistentFlagRequired("peer")
cmd.MarkPersistentFlagRequired("config")
Expand Down