mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-10-19 05:18:50 +00:00
feat(ui): type the namespace when the cluster does not list them (#84)
Some users cannot list namespaces on a cluster. The add wizard showed an error and offered no way forward. The namespace step now switches to a text prompt when the list call fails or returns nothing. The prompt shows the reason and checks that the name is a valid DNS label. Esc from a later step returns to the prompt. The j and k keys now type into text fields. They moved the list cursor before, so a name such as kube-system could not be typed. Closes #66
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -697,6 +698,14 @@ func validateDNS1123Label(name, field, entityType string) *ValidationError {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateNamespaceName validates a Kubernetes namespace name (a DNS-1123 label).
|
||||
func ValidateNamespaceName(name string) error {
|
||||
if verr := validateDNS1123Label(name, "namespace", "Namespace"); verr != nil {
|
||||
return errors.New(verr.Message)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateDNS1123Subdomain validates that a name is a valid DNS subdomain name (RFC 1123).
|
||||
// Used for resource names which can contain dots.
|
||||
func validateDNS1123Subdomain(name, field, entityType string) *ValidationError {
|
||||
|
||||
Reference in New Issue
Block a user