// GetControlPlaneEndpoint returns a properly formatted endpoint for the control plane built according following rules: // - If the controlPlaneEndpoint is defined, use it. // - if the controlPlaneEndpoint is defined but without a port number, use the controlPlaneEndpoint + localEndpoint.BindPort is used. // - Otherwise, in case the controlPlaneEndpoint is not defined, use the localEndpoint.AdvertiseAddress + the localEndpoint.BindPort. func GetControlPlaneEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.APIEndpoint) (string, error) { … } // GetLocalAPIEndpoint parses an APIEndpoint and returns it as a string, // or returns and error in case it cannot be parsed. func GetLocalAPIEndpoint(localEndpoint *kubeadmapi.APIEndpoint) (string, error) { … } // ParseHostPort parses a network address of the form "host:port", "ipv4:port", "[ipv6]:port" into host and port; // ":port" can be eventually omitted. // If the string is not a valid representation of network address, ParseHostPort returns an error. func ParseHostPort(hostport string) (string, string, error) { … } // ParsePort parses a string representing a TCP port. // If the string is not a valid representation of a TCP port, ParsePort returns an error. func ParsePort(port string) (int, error) { … } // parseAPIEndpoint parses an APIEndpoint and returns the AdvertiseAddress as net.IP and the BindPort as string. // If the BindPort or AdvertiseAddress are invalid it returns an error. func parseAPIEndpoint(localEndpoint *kubeadmapi.APIEndpoint) (net.IP, string, error) { … } // formatURL takes a host and a port string and creates a net.URL using https scheme func formatURL(host, port string) *url.URL { … }