Skip to content

Commit c3a21f8

Browse files
Jonathan S. Katzjkatz
authored andcommitted
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 003b7e8 commit c3a21f8

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
@@ -576,18 +576,12 @@ func CreateCluster(request *msgs.CreateClusterRequest, ns, pgouser string) msgs.
576576
return resp
577577
}
578578

579-
userLabelsMap := make(map[string]string)
580-
if request.UserLabels != "" {
581-
labels := strings.Split(request.UserLabels, ",")
582-
for _, v := range labels {
583-
p := strings.Split(v, "=")
584-
if len(p) < 2 {
585-
resp.Status.Code = msgs.Error
586-
resp.Status.Msg = "invalid labels format"
587-
return resp
588-
}
589-
userLabelsMap[p[0]] = p[1]
590-
}
579+
userLabelsMap, err := apiserver.ValidateLabel(request.UserLabels)
580+
581+
if err != nil {
582+
resp.Status.Code = msgs.Error
583+
resp.Status.Msg = err.Error()
584+
return resp
591585
}
592586

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

0 commit comments

Comments
 (0)