Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Implementing sigs.k8s.io YAML to remove .proto yaml annotations #9780

Merged
merged 42 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c1de062
Implementing sigs.k8s.io YAML fork
lukerhoads Jul 27, 2021
47c4f27
Removed unnecessary YAML annotations from moduleAccountPretty
lukerhoads Jul 27, 2021
7b15587
Removed unecessary YAML annotations from vestingAccountYAML
lukerhoads Jul 27, 2021
ebf6215
Merge branch 'cosmos:master' into lukerhoads/remote-yaml-annotations
lukerhoads Jul 27, 2021
0c75cad
Replaced usage of yaml.v2 with new one
lukerhoads Jul 30, 2021
d30726f
Merge branch 'master' into lukerhoads/remote-yaml-annotations
lukerhoads Jul 30, 2021
985390d
Fully removed usage of gopkg yaml
lukerhoads Jul 30, 2021
c902d70
Removed all protobuf moretag annotations
lukerhoads Jul 30, 2021
3a33260
Merge branch 'master' into lukerhoads/remote-yaml-annotations
lukerhoads Aug 1, 2021
5dd48e3
Resolve unused problem
lukerhoads Aug 1, 2021
9f4a035
Merge branch 'cosmos:master' into lukerhoads/remote-yaml-annotations
lukerhoads Aug 3, 2021
5f7839d
Merged master
lukerhoads Aug 9, 2021
ba76ca3
Regenned proto files
lukerhoads Aug 9, 2021
5bd7cb7
Updated CHANGELOG
lukerhoads Aug 9, 2021
9879240
Merge branch 'lukerhoads/remote-yaml-annotations' of https://github.c…
lukerhoads Aug 9, 2021
916c732
Reverted formatting changes
lukerhoads Aug 9, 2021
739a6eb
Regenerated proto files
lukerhoads Aug 9, 2021
f97a9b3
Merged master
lukerhoads Aug 9, 2021
5a15c04
Merged and resolved conflict
lukerhoads Aug 9, 2021
c70a939
Fixed newline formatting for changelog
lukerhoads Aug 9, 2021
8b30a16
Merged master
lukerhoads Sep 1, 2021
65578ae
Removed old yaml dep in go.mod
lukerhoads Sep 1, 2021
8fe0f1f
Fixed most tests
lukerhoads Sep 2, 2021
66468aa
Merge branch 'cosmos:master' into lukerhoads/remote-yaml-annotations
lukerhoads Sep 3, 2021
60f5061
Fixed other straightforward testing errors
lukerhoads Sep 3, 2021
4d288c9
Merge master
lukerhoads Sep 15, 2021
3b0d402
Removed last yaml tags, modified param test cases
lukerhoads Sep 15, 2021
91a91cb
Changed tests to directly call StdSignature marshalYAML as sigs.k8s.i…
lukerhoads Sep 16, 2021
fcec039
Fixed no new var build error
lukerhoads Sep 16, 2021
fbfe8f0
Added CLI breaking change in CHANGELOG
lukerhoads Sep 17, 2021
631d648
Merged master
lukerhoads Sep 17, 2021
bca0f70
Fix build error in bank types
lukerhoads Sep 17, 2021
4814390
Update CHANGELOG.md
amaury1093 Sep 17, 2021
75e97ee
go mod tidy
lukerhoads Sep 17, 2021
425c522
Merge branch 'lukerhoads/remote-yaml-annotations' of https://github.c…
lukerhoads Sep 17, 2021
3e83faa
Revert "go mod tidy"
lukerhoads Sep 17, 2021
9cc5706
Fix merge conflicts
lukerhoads Sep 18, 2021
0ace588
Fix param unit tests
lukerhoads Sep 18, 2021
64bd40c
Merge branch 'master' into lukerhoads/remote-yaml-annotations
lukerhoads Sep 23, 2021
d572a72
Resolve merge conflicts
lukerhoads Sep 23, 2021
a1d5263
Go mod tidy
lukerhoads Sep 24, 2021
a20180d
Merge branch 'master' into lukerhoads/remote-yaml-annotations
amaury1093 Sep 24, 2021
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
13 changes: 2 additions & 11 deletions codec/yaml.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package codec

import (
"encoding/json"

"github.com/gogo/protobuf/proto"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"
)

// MarshalYAML marshals toPrint using JSONCodec to leverage specialized MarshalJSON methods
Expand All @@ -18,12 +16,5 @@ func MarshalYAML(cdc JSONCodec, toPrint proto.Message) ([]byte, error) {
return nil, err
}

// generate YAML by decoding JSON and re-encoding to YAML
var j interface{}
err = json.Unmarshal(bz, &j)
if err != nil {
return nil, err
}

return yaml.Marshal(j)
return yaml.JSONToYAML(bz)
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0
nhooyr.io/websocket v1.8.6 // indirect
sigs.k8s.io/yaml v1.2.0
)

replace google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1240,4 +1240,6 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
7 changes: 4 additions & 3 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

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

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/internal/conv"
Expand Down Expand Up @@ -237,7 +238,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 := yaml.Unmarshal(data, &s)
err := sigsyaml.Unmarshal(data, &s)
if err != nil {
return err
}
Expand Down Expand Up @@ -387,7 +388,7 @@ func (va *ValAddress) UnmarshalJSON(data []byte) error {
func (va *ValAddress) UnmarshalYAML(data []byte) error {
var s string

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

err := yaml.Unmarshal(data, &s)
err := sigsyaml.Unmarshal(data, &s)
if err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions x/auth/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/gogo/protobuf/proto"
"github.com/tendermint/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 Expand Up @@ -237,12 +237,12 @@ func (ma ModuleAccount) Validate() error {
}

type moduleAccountPretty struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
PubKey string `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence" yaml:"sequence"`
Name string `json:"name" yaml:"name"`
Permissions []string `json:"permissions" yaml:"permissions"`
Address sdk.AccAddress `json:"address"`
PubKey string `json:"public_key"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
Name string `json:"name"`
Permissions []string `json:"permissions"`
}

func (ma ModuleAccount) String() string {
Expand Down
22 changes: 11 additions & 11 deletions x/auth/vesting/types/vesting_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"time"

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

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -162,18 +162,18 @@ func (bva BaseVestingAccount) Validate() error {
}

type vestingAccountYAML struct {
ruhatch marked this conversation as resolved.
Show resolved Hide resolved
Address sdk.AccAddress `json:"address" yaml:"address"`
PubKey string `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence" yaml:"sequence"`
OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"`
DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"`
DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"`
EndTime int64 `json:"end_time" yaml:"end_time"`
Address sdk.AccAddress `json:"address"`
PubKey string `json:"public_key"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
OriginalVesting sdk.Coins `json:"original_vesting"`
DelegatedFree sdk.Coins `json:"delegated_free"`
DelegatedVesting sdk.Coins `json:"delegated_vesting"`
EndTime int64 `json:"end_time"`

// custom fields based on concrete vesting type which can be omitted
StartTime int64 `json:"start_time,omitempty" yaml:"start_time,omitempty"`
VestingPeriods Periods `json:"vesting_periods,omitempty" yaml:"vesting_periods,omitempty"`
StartTime int64 `json:"start_time,omitempty"`
VestingPeriods Periods `json:"vesting_periods,omitempty"`
}

func (bva BaseVestingAccount) String() string {
Expand Down