forked from TrueCloudLab/frostfs-node
[#884] cli: Fix error message for undefined endpoint
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
d5d3d8badb
commit
b19ba94556
2 changed files with 8 additions and 0 deletions
|
@ -34,6 +34,10 @@ func GetSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag
|
||||||
func getSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag string) (*client.Client, error) {
|
func getSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag string) (*client.Client, error) {
|
||||||
var addr network.Address
|
var addr network.Address
|
||||||
|
|
||||||
|
if len(viper.GetString(endpointFlag)) == 0 {
|
||||||
|
return nil, fmt.Errorf("%s is not defined", endpointFlag)
|
||||||
|
}
|
||||||
|
|
||||||
err := addr.FromString(viper.GetString(endpointFlag))
|
err := addr.FromString(viper.GetString(endpointFlag))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%v: %w", errInvalidEndpoint, err)
|
return nil, fmt.Errorf("%v: %w", errInvalidEndpoint, err)
|
||||||
|
|
|
@ -88,6 +88,10 @@ func (a *Address) FromString(s string) error {
|
||||||
|
|
||||||
// multiaddrStringFromHostAddr converts "localhost:8080" to "/dns4/localhost/tcp/8080".
|
// multiaddrStringFromHostAddr converts "localhost:8080" to "/dns4/localhost/tcp/8080".
|
||||||
func multiaddrStringFromHostAddr(host string) (string, error) {
|
func multiaddrStringFromHostAddr(host string) (string, error) {
|
||||||
|
if len(host) == 0 {
|
||||||
|
return "", fmt.Errorf("host is empty")
|
||||||
|
}
|
||||||
|
|
||||||
endpoint, port, err := net.SplitHostPort(host)
|
endpoint, port, err := net.SplitHostPort(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in a new issue