Skip to content

Commit 9f9941e

Browse files
author
Jonathan S. Katz
committed
Unify label validation strategy across API functions
The `pgo create cluster` command was not using the same label validation as the other label commands were using. Issue: [ch10201]
1 parent 5b61c9c commit 9f9941e

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

internal/apiserver/clusterservice/clusterimpl.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,12 @@ func CreateCluster(request *msgs.CreateClusterRequest, ns, pgouser string) msgs.
581581
return resp
582582
}
583583

584-
userLabelsMap := make(map[string]string)
585-
if request.UserLabels != "" {
586-
labels := strings.Split(request.UserLabels, ",")
587-
for _, v := range labels {
588-
p := strings.Split(v, "=")
589-
if len(p) < 2 {
590-
resp.Status.Code = msgs.Error
591-
resp.Status.Msg = "invalid labels format"
592-
return resp
593-
}
594-
userLabelsMap[p[0]] = p[1]
595-
}
584+
userLabelsMap, err := apiserver.ValidateLabel(request.UserLabels)
585+
586+
if err != nil {
587+
resp.Status.Code = msgs.Error
588+
resp.Status.Msg = err.Error()
589+
return resp
596590
}
597591

598592
// validate any parameters provided to bootstrap the cluster from an existing data source

0 commit comments

Comments
 (0)