示例#1
0
func (hc HostnameCheck) Check() (warnings, errors []error) {
	errors = []error{}
	hostname := node.GetHostname("")
	for _, msg := range validation.ValidateNodeName(hostname, false) {
		errors = append(errors, fmt.Errorf("hostname \"%s\" %s", hostname, msg))
	}
	return nil, errors
}
示例#2
0
func NodeMetricsUrl(name string) (string, error) {
	if len(name) > 0 {
		errs := validation.ValidateNodeName(name, false)
		if len(errs) > 0 {
			message := fmt.Sprintf("invalid node name: %s - %v", name, errs)
			return "", errors.New(message)
		}
	}
	return fmt.Sprintf("%s/nodes/%s", MetricsRoot, name), nil
}
// In default HTTPKubeletClient ctx is unused.
func (c *HTTPKubeletClient) GetRawConnectionInfo(ctx api.Context, nodeName string) (string, uint, http.RoundTripper, error) {
	if errs := validation.ValidateNodeName(nodeName, false); len(errs) != 0 {
		return "", 0, nil, fmt.Errorf("invalid node name: %s", strings.Join(errs, ";"))
	}
	scheme := "http"
	if c.Config.EnableHttps {
		scheme = "https"
	}
	return scheme, c.Config.Port, c.Client.Transport, nil
}
示例#4
0
func (c *HTTPKubeletClient) GetConnectionInfo(host string) (string, uint, http.RoundTripper, error) {
	if ok, msg := validation.ValidateNodeName(host, false); !ok {
		return "", 0, nil, fmt.Errorf("invalid node name: %s", msg)
	}
	scheme := "http"
	if c.Config.EnableHttps {
		scheme = "https"
	}
	return scheme, c.Config.Port, c.Client.Transport, nil
}