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

go/oasis-node/cmd/stake: Make list command's verbose output consistent #3016

Merged
merged 3 commits into from
Jun 16, 2020
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
17 changes: 14 additions & 3 deletions .buildkite/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ pr_and_docker_changes() {
'docker/'
}

# Helper that checks if the given tag of the oasisprotocol/oasis-core-ci Docker image exists.
check_docker_ci_image_tag_exists() {
local tag=$1
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect oasisprotocol/oasis-core-ci:${tag}
}

# Determine the oasis-core-ci Docker image tag to use for tests.
if [[ -n $BUILDKITE_PULL_REQUEST_BASE_BRANCH ]]; then
docker_tag=$BUILDKITE_PULL_REQUEST_BASE_BRANCH
Expand All @@ -62,10 +68,15 @@ if pr_and_docker_changes; then
# Override the Docker tag that should be used.
docker_tag=pr-$(git describe --always --match '' --abbrev=7)
# Fail if the Docker image does not exist.
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect oasisprotocol/oasis-core-ci:${docker_tag} || {
echo "Updated Docker image does not yet exist. Wait for it to be rebuilt and retry."
if ! check_docker_ci_image_tag_exists "${docker_tag}"; then
echo 1>&2 "Updated Docker image does not yet exist. Wait for it to be rebuilt and retry."
exit 1
fi
fi

if ! check_docker_ci_image_tag_exists "${docker_tag}"; then
echo 1>&2 "Docker image 'oasisprotocol/oasis-core-ci:${docker_tag}' does not exist."
exit 1
}
fi

export DOCKER_OASIS_CORE_CI_BASE_TAG=${docker_tag//\//-}
Expand Down
5 changes: 5 additions & 0 deletions .changelog/3016.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/oasis-node/cmd/stake: Make `list` command's verbose output consistent

Change `oasis-node stake list --verbose` CLI command's output to not list
all accounts' information as a single-line JSON string but rather output
each account's JSON string on a separate line.
1 change: 1 addition & 0 deletions .changelog/3016.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ci: Make Buildkite fail if desired tag of Docker CI image doesn't exist
2 changes: 1 addition & 1 deletion go/oasis-node/cmd/stake/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func registerAccountCmd() {
}

func init() {
accountInfoFlags.String(CfgAccountAddr, "", "Address of the account")
accountInfoFlags.String(CfgAccountAddr, "", "account address")
_ = viper.BindPFlags(accountInfoFlags)
accountInfoFlags.AddFlagSet(cmdFlags.RetriesFlags)
accountInfoFlags.AddFlagSet(cmdGrpc.ClientFlags)
Expand Down
28 changes: 16 additions & 12 deletions go/oasis-node/cmd/stake/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,28 @@ func doList(cmd *cobra.Command, args []string) {

ctx := context.Background()

var addrs []api.Address
var addresses []api.Address
doWithRetries(cmd, "query addresses", func() error {
var err error
addrs, err = client.Addresses(ctx, consensus.HeightLatest)
addresses, err = client.Addresses(ctx, consensus.HeightLatest)
return err
})

if cmdFlags.Verbose() {
accts := make(map[api.Address]*api.Account)
for _, v := range addrs {
accts[v] = getAccount(ctx, cmd, v, client)
}
b, _ := json.Marshal(accts)
fmt.Printf("%v\n", string(b))
} else {
for _, v := range addrs {
fmt.Printf("%v\n", v)
for _, addr := range addresses {
var s string
switch cmdFlags.Verbose() {
case true:
// NOTE: getAccount()'s output doesn't contain an account's address,
// so we need to add it manually.
acctMap := make(map[api.Address]*api.Account)
acctMap[addr] = getAccount(ctx, cmd, addr, client)
b, _ := json.Marshal(acctMap)
s = string(b)
default:
s = addr.String()
}

fmt.Printf("%v\n", s)
}
}

Expand Down