You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2019/01/30 18:10:04 UTC

[GitHub] lburgazzoli commented on a change in pull request #401: Improve error handling while parsing Prometheus service monitor labels

lburgazzoli commented on a change in pull request #401: Improve error handling while parsing Prometheus service monitor labels
URL: https://github.com/apache/camel-k/pull/401#discussion_r252374130
 
 

 ##########
 File path: pkg/trait/prometheus.go
 ##########
 @@ -139,14 +146,23 @@ func (t *prometheusTrait) getServiceMonitorFor(e *Environment) *monitoringv1.Ser
 			},
 		},
 	}
-	return &smt
+	return &smt, nil
 }
 
-func parseLabels(labels string) map[string]string {
+func parseLabels(labels string) (map[string]string, error) {
 	m := make(map[string]string)
+
+	if len(labels) == 0 {
+		return m, nil
+	}
+
 	for _, label := range strings.Split(labels, ",") {
 		kv := strings.Split(label, "=")
+		if len(kv) != 2 {
+			return nil, fmt.Errorf("Invalid label [%s] in labels [%s]", label, labels)
 
 Review comment:
   error strings should not start with a capital letter 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services