Skip to content

Commit

Permalink
Merge pull request #54 from dayuy/fix-2
Browse files Browse the repository at this point in the history
chaincode and chaincodebuild args de-duplication
  • Loading branch information
bjwswang authored Jul 3, 2023
2 parents 14b9a0f + f606cd7 commit cc906dc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/chaincode/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"k8s.io/kubectl/pkg/cmd/get"

"github.com/bestchains/bc-cli/pkg/common"
"github.com/bestchains/bc-cli/pkg/utils"
)

func NewCCGetCmd(option common.Options) *cobra.Command {
Expand Down Expand Up @@ -88,7 +89,7 @@ func NewCCGetCmd(option common.Options) *cobra.Command {
list.Items = append(list.Items, runtime.RawExtension{Object: &chaincodes.Items[i]})
}
} else {
for _, arg := range args {
for _, arg := range utils.RemoveDuplicateForStringSlice(args) {
chaincode, err := cli.Resource(schema.GroupVersionResource{Group: common.IBPGroup, Version: common.IBPVersion, Resource: common.Chaincode}).Get(context.TODO(), arg, v1.GetOptions{})
if err != nil {
fmt.Fprintln(option.ErrOut, err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/chaincodebuild/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"k8s.io/kubectl/pkg/cmd/get"

"github.com/bestchains/bc-cli/pkg/common"
"github.com/bestchains/bc-cli/pkg/utils"
)

func NewCCBGetCmd(option common.Options) *cobra.Command {
Expand Down Expand Up @@ -90,7 +91,7 @@ func NewCCBGetCmd(option common.Options) *cobra.Command {
list.Items = append(list.Items, runtime.RawExtension{Object: &chaincodeBuilds.Items[i]})
}
} else {
for _, arg := range args {
for _, arg := range utils.RemoveDuplicateForStringSlice(args) {
chaincodeBuild, err := cli.Resource(schema.GroupVersionResource{Group: common.IBPGroup, Version: common.IBPVersion, Resource: common.ChaincodeBuild}).Get(context.TODO(), arg, v1.GetOptions{})
if err != nil {
fmt.Fprintln(option.ErrOut, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewNetworkGetCmd(option common.Options) *cobra.Command {
list.Items = append(list.Items, runtime.RawExtension{Object: &networks.Items[i]})
}
} else {
for _, arg := range args {
for _, arg := range utils.RemoveDuplicateForStringSlice(args) {
network, err := cli.Resource(schema.GroupVersionResource{Group: common.IBPGroup, Version: common.IBPVersion, Resource: common.Network}).Get(context.TODO(), arg, v1.GetOptions{})
if err != nil {
fmt.Fprintln(option.ErrOut, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/proposal/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewProposalGetCmd(option common.Options) *cobra.Command {
list.Items = append(list.Items, runtime.RawExtension{Object: proposal})
}
} else {
for _, arg := range args {
for _, arg := range utils.RemoveDuplicateForStringSlice(args) {
proposal, err := cli.Resource(schema.GroupVersionResource{Group: common.IBPGroup, Version: common.IBPVersion, Resource: common.Proposal}).Get(context.TODO(), arg, v1.GetOptions{})
if err != nil {
fmt.Fprintln(option.ErrOut, err)
Expand Down

0 comments on commit cc906dc

Please sign in to comment.