package nns import ( "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags" "github.com/spf13/cobra" "github.com/spf13/viper" ) const ( nnsNameFlag = "name" nnsNameFlagDesc = "Domain name" nnsEmailFlag = "email" nnsRefreshFlag = "refresh" nnsRetryFlag = "retry" nnsExpireFlag = "expire" nnsTTLFlag = "ttl" nnsRecordTypeFlag = "type" nnsRecordTypeFlagDesc = "Domain name service record type(A|CNAME|SOA|TXT)" nnsRecordDataFlag = "data" nnsRecordDataFlagDesc = "Domain name service record data" ) var ( Cmd = &cobra.Command{ Use: "nns", Short: "Section for Neo Name Service (NNS)", } tokensCmd = &cobra.Command{ Use: "tokens", Short: "List all registered domain names", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) }, Run: listTokens, } registerCmd = &cobra.Command{ Use: "register", Short: "Registers a new domain", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: registerDomain, } deleteCmd = &cobra.Command{ Use: "delete", Short: "Delete a domain by name", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: deleteDomain, } renewCmd = &cobra.Command{ Use: "renew", Short: "Increases domain expiration date", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: renewDomain, } updateCmd = &cobra.Command{ Use: "update", Short: "Updates soa record", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: updateSOA, } addRecordCmd = &cobra.Command{ Use: "add-record", Short: "Adds a new record of the specified type to the provided domain", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: addRecord, } getRecordsCmd = &cobra.Command{ Use: "get-records", Short: "Returns domain record of the specified type", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) }, Run: getRecords, } delRecordsCmd = &cobra.Command{ Use: "delete-records", Short: "Removes domain records with the specified type", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: delRecords, } delRecordCmd = &cobra.Command{ Use: "delete-record", Short: "Removes domain record with the specified type and data", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) }, Run: delRecord, } ) func init() { initTokensCmd() initRegisterCmd() initDeleteCmd() initRenewCmd() initUpdateCmd() initAddRecordCmd() initGetRecordsCmd() initDelRecordsCmd() initDelRecordCmd() }