gxthrj commented on a change in pull request #715:
URL:
https://github.com/apache/apisix-ingress-controller/pull/715#discussion_r737616629
##########
File path: pkg/config/config.go
##########
@@ -191,3 +200,54 @@ func purifyAppNamespaces(namespaces []string) []string {
}
return ultimate
}
+
+func (cfg *Config) verifyNamespaceSelector() (bool, error) {
+ labels := cfg.Kubernetes.NamespaceSelector
+ // default is [""]
+ if len(labels) == 1 && labels[0] == "" {
+ cfg.Kubernetes.NamespaceSelector = []string{}
+ }
+
+ for _, s := range cfg.Kubernetes.NamespaceSelector {
+ parts := strings.Split(s, "=")
+ if len(parts) != 2 {
+ return false, fmt.Errorf("Illegal namespaceSelector:
%s, should be key-value pairs divided by = ", s)
+ } else {
+ if err := cfg.validateLabelKey(parts[0]); err != nil {
+ return false, err
+ }
+ if err := cfg.validateLabelValue(parts[1]); err != nil {
+ return false, err
+ }
+ }
+ }
+ return true, nil
+}
+
+// validateLabelKey validate the key part of label
+// ref:
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
+func (cfg *Config) validateLabelKey(key string) error {
+ errorMsg := validation.IsQualifiedName(key)
+ msg := ""
Review comment:
The type of `errorMsg ` is []string, So just use `strings.Join`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]