Refactor id file interaction

* Use IP instead of endpoint in clusterIDsFile
* Move and rename validateEnpoint to addPortIfMissing
* Refactor clusterIDsFile handling in verify cmd
This commit is contained in:
katexochen 2022-07-29 08:24:13 +02:00 committed by Paul Meyer
parent c2faa20d6e
commit 7bbcc564bb
8 changed files with 95 additions and 106 deletions

View file

@ -3,9 +3,6 @@ package cmd
import (
"errors"
"fmt"
"net"
"strconv"
"strings"
"github.com/edgelesssys/constellation/cli/internal/azure"
"github.com/edgelesssys/constellation/cli/internal/gcp"
@ -56,20 +53,3 @@ func validInstanceTypeForProvider(cmd *cobra.Command, insType string, provider c
return fmt.Errorf("%s isn't a valid cloud platform", provider)
}
}
func validateEndpoint(endpoint string, defaultPort int) (string, error) {
if endpoint == "" {
return "", errors.New("endpoint is empty")
}
_, _, err := net.SplitHostPort(endpoint)
if err == nil {
return endpoint, nil
}
if strings.Contains(err.Error(), "missing port in address") {
return net.JoinHostPort(endpoint, strconv.Itoa(defaultPort)), nil
}
return "", err
}