[#1301] adm/morph: Support global domain
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 2m6s
Tests and linters / Run gofumpt (pull_request) Successful in 2m16s
DCO action / DCO (pull_request) Successful in 2m35s
Build / Build Components (1.23) (pull_request) Successful in 3m0s
Build / Build Components (1.22) (pull_request) Successful in 3m0s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m24s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m41s
Tests and linters / Staticcheck (pull_request) Successful in 3m39s
Tests and linters / Lint (pull_request) Successful in 4m15s
Tests and linters / Tests with -race (pull_request) Successful in 4m28s
Tests and linters / gopls check (pull_request) Successful in 4m29s
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 2m6s
Tests and linters / Run gofumpt (pull_request) Successful in 2m16s
DCO action / DCO (pull_request) Successful in 2m35s
Build / Build Components (1.23) (pull_request) Successful in 3m0s
Build / Build Components (1.22) (pull_request) Successful in 3m0s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m24s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m41s
Tests and linters / Staticcheck (pull_request) Successful in 3m39s
Tests and linters / Lint (pull_request) Successful in 4m15s
Tests and linters / Tests with -race (pull_request) Successful in 4m28s
Tests and linters / gopls check (pull_request) Successful in 4m29s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
98fe24cdb7
commit
05f92f2901
1 changed files with 34 additions and 1 deletions
|
@ -1,15 +1,24 @@
|
||||||
package nns
|
package nns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
|
client "git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/nns"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
verboseDesc = "Includes additional information about CNAME record."
|
||||||
|
)
|
||||||
|
|
||||||
func initTokensCmd() {
|
func initTokensCmd() {
|
||||||
Cmd.AddCommand(tokensCmd)
|
Cmd.AddCommand(tokensCmd)
|
||||||
tokensCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
tokensCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
tokensCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
tokensCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
|
tokensCmd.Flags().BoolP(commonflags.Verbose, commonflags.VerboseShorthand, false, verboseDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func listTokens(cmd *cobra.Command, _ []string) {
|
func listTokens(cmd *cobra.Command, _ []string) {
|
||||||
|
@ -18,7 +27,31 @@ func listTokens(cmd *cobra.Command, _ []string) {
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get tokens: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to get tokens: %w", err)
|
||||||
for toks, err := it.Next(10); err == nil && len(toks) > 0; toks, err = it.Next(10) {
|
for toks, err := it.Next(10); err == nil && len(toks) > 0; toks, err = it.Next(10) {
|
||||||
for _, token := range toks {
|
for _, token := range toks {
|
||||||
cmd.Println(string(token))
|
output := string(token)
|
||||||
|
if longFlag, err := cmd.Flags().GetBool(commonflags.Verbose); err == nil && longFlag {
|
||||||
|
if cname := getCnameRecord(c, token); cname != "" {
|
||||||
|
output += " ( CNAME: " + cname + " )"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd.Println(output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCnameRecord(c *client.Contract, token []byte) string {
|
||||||
|
items, err := c.GetRecords(string(token), big.NewInt(int64(nns.CNAME)))
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range items {
|
||||||
|
record, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(record)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue