Skip to content

Commit

Permalink
Fully removed usage of gopkg yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
lukerhoads committed Jul 30, 2021
1 parent d30726f commit 985390d
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 28 deletions.
13 changes: 2 additions & 11 deletions client/context.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package client

import (
"encoding/json"
"io"
"os"

"github.com/spf13/viper"

"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
Expand Down Expand Up @@ -277,15 +276,7 @@ func (ctx Context) PrintObjectLegacy(toPrint interface{}) error {

func (ctx Context) printOutput(out []byte) error {
if ctx.OutputFormat == "text" {
// handle text format by decoding and re-encoding JSON as YAML
var j interface{}

err := json.Unmarshal(out, &j)
if err != nil {
return err
}

out, err = yaml.Marshal(j)
out, err := yaml.JSONToYAML(out)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c
google.golang.org/grpc v1.39.0
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v2 v2.4.0 // indirect
nhooyr.io/websocket v1.8.6 // indirect
sigs.k8s.io/yaml v1.2.0
)
Expand Down
13 changes: 4 additions & 9 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
"sync"

"github.com/hashicorp/golang-lru/simplelru"
yaml "gopkg.in/yaml.v2"
sigsyaml "sigs.k8s.io/yaml"
"sigs.k8s.io/yaml"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/internal/conv"
Expand Down Expand Up @@ -117,10 +116,6 @@ var _ Address = AccAddress{}
var _ Address = ValAddress{}
var _ Address = ConsAddress{}

var _ yaml.Marshaler = AccAddress{}
var _ yaml.Marshaler = ValAddress{}
var _ yaml.Marshaler = ConsAddress{}

// ----------------------------------------------------------------------------
// account
// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -238,7 +233,7 @@ func (aa *AccAddress) UnmarshalJSON(data []byte) error {
// UnmarshalYAML unmarshals from JSON assuming Bech32 encoding.
func (aa *AccAddress) UnmarshalYAML(data []byte) error {
var s string
err := sigsyaml.Unmarshal(data, &s)
err := yaml.Unmarshal(data, &s)
if err != nil {
return err
}
Expand Down Expand Up @@ -388,7 +383,7 @@ func (va *ValAddress) UnmarshalJSON(data []byte) error {
func (va *ValAddress) UnmarshalYAML(data []byte) error {
var s string

err := sigsyaml.Unmarshal(data, &s)
err := yaml.Unmarshal(data, &s)
if err != nil {
return err
}
Expand Down Expand Up @@ -543,7 +538,7 @@ func (ca *ConsAddress) UnmarshalJSON(data []byte) error {
func (ca *ConsAddress) UnmarshalYAML(data []byte) error {
var s string

err := sigsyaml.Unmarshal(data, &s)
err := yaml.Unmarshal(data, &s)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion types/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
Expand Down
2 changes: 1 addition & 1 deletion types/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/suite"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
2 changes: 1 addition & 1 deletion x/auth/migrations/legacytx/stdsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/migrations/v038/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/tendermint/tendermint/crypto/tmhash"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/types/evidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
Expand Down
1 change: 0 additions & 1 deletion x/genutil/types/genesis_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func SetGenesisStateInAppState(
//
// NOTE: The pubkey input is this machines pubkey.
func GenesisStateFromGenDoc(genDoc tmtypes.GenesisDoc) (genesisState map[string]json.RawMessage, err error) {

if err = json.Unmarshal(genDoc.AppState, &genesisState); err != nil {
return genesisState, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/staking/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

abci "github.com/tendermint/tendermint/abci/types"
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down

0 comments on commit 985390d

Please sign in to comment.