@@ -23,9 +23,7 @@ import (
2323 "net/url"
2424 "reflect"
2525 "strconv"
26- "strings"
2726 "time"
28- "unicode/utf8"
2927
3028 apiv2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
3129 scheduledworkflow "github.com/kubeflow/pipelines/backend/src/crd/pkg/apis/scheduledworkflow/v1beta1"
@@ -394,48 +392,22 @@ func (r *ResourceManager) UpdatePipelineDefaultVersion(pipelineId string, versio
394392
395393// MaxTagKeyLength is the maximum allowed length (in characters) for a tag key.
396394// Consistent with Kubernetes label value length limit (63 characters).
397- const MaxTagKeyLength = 63
395+ const MaxTagKeyLength = common . MaxTagKeyLength
398396
399397// MaxTagValueLength is the maximum allowed length (in characters) for a tag value.
400398// Consistent with Kubernetes label value length limit (63 characters).
401- const MaxTagValueLength = 63
399+ const MaxTagValueLength = common . MaxTagValueLength
402400
403401// MaxTagsPerEntity is the maximum number of tags allowed on a single pipeline or pipeline version.
404- const MaxTagsPerEntity = 20
405-
406- // validateTags checks that tags conform to all constraints:
407- // - maximum number of tags per entity
408- // - no empty keys
409- // - keys must not contain "." (conflicts with tag filter prefix "tags.")
410- // - key and value character lengths within limits
411- func validateTags (tags map [string ]string ) error {
412- if len (tags ) > MaxTagsPerEntity {
413- return util .NewInvalidInputError ("number of tags (%d) exceeds maximum of %d per entity" , len (tags ), MaxTagsPerEntity )
414- }
415- for key , value := range tags {
416- if key == "" {
417- return util .NewInvalidInputError ("tag key cannot be empty" )
418- }
419- if strings .Contains (key , "." ) {
420- return util .NewInvalidInputError ("tag key %q must not contain '.' character" , key )
421- }
422- if utf8 .RuneCountInString (key ) > MaxTagKeyLength {
423- return util .NewInvalidInputError ("tag key %q exceeds maximum length of %d characters" , key , MaxTagKeyLength )
424- }
425- if utf8 .RuneCountInString (value ) > MaxTagValueLength {
426- return util .NewInvalidInputError ("tag value %q for key %q exceeds maximum length of %d characters" , value , key , MaxTagValueLength )
427- }
428- }
429- return nil
430- }
402+ const MaxTagsPerEntity = common .MaxTagsPerEntity
431403
432404// UpdatePipeline updates mutable fields of a pipeline (display_name, tags).
433405// Both fields are updated in a single transaction via UpdatePipelineFields.
434406func (r * ResourceManager ) UpdatePipeline (pipelineID string , displayName string , tags map [string ]string ) (* model.Pipeline , error ) {
435407 if pipelineID == "" {
436408 return nil , util .NewInvalidInputError ("pipeline id cannot be empty when updating pipeline" )
437409 }
438- if err := validateTags (tags ); err != nil {
410+ if err := common . ValidateTags (tags ); err != nil {
439411 return nil , err
440412 }
441413 // Update fields and tags in a single transaction to prevent deadlocks.
@@ -452,7 +424,7 @@ func (r *ResourceManager) UpdatePipelineVersion(pipelineVersionID string, displa
452424 if pipelineVersionID == "" {
453425 return nil , util .NewInvalidInputError ("pipeline version id cannot be empty when updating pipeline version" )
454426 }
455- if err := validateTags (tags ); err != nil {
427+ if err := common . ValidateTags (tags ); err != nil {
456428 return nil , err
457429 }
458430 // Update fields and tags in a single transaction to prevent deadlocks.
@@ -474,7 +446,7 @@ func (r *ResourceManager) CreatePipeline(p *model.Pipeline) (*model.Pipeline, er
474446 p .DisplayName = p .Name
475447 }
476448
477- if err := validateTags (p .Tags ); err != nil {
449+ if err := common . ValidateTags (p .Tags ); err != nil {
478450 return nil , err
479451 }
480452
@@ -498,10 +470,10 @@ func (r *ResourceManager) CreatePipeline(p *model.Pipeline) (*model.Pipeline, er
498470// Creates a pipeline and a pipeline version.
499471// This is used when two resources need to be created in a single DB transaction.
500472func (r * ResourceManager ) CreatePipelineAndPipelineVersion (p * model.Pipeline , pv * model.PipelineVersion ) (* model.Pipeline , * model.PipelineVersion , error ) {
501- if err := validateTags (p .Tags ); err != nil {
473+ if err := common . ValidateTags (p .Tags ); err != nil {
502474 return nil , nil , err
503475 }
504- if err := validateTags (pv .Tags ); err != nil {
476+ if err := common . ValidateTags (pv .Tags ); err != nil {
505477 return nil , nil , err
506478 }
507479
@@ -1909,7 +1881,7 @@ func (r *ResourceManager) CreatePipelineVersion(pv *model.PipelineVersion) (*mod
19091881 pv .Status = model .PipelineVersionCreating
19101882 pv .PipelineSpec = model .LargeText (string (tmpl .Bytes ()))
19111883
1912- if err := validateTags (pv .Tags ); err != nil {
1884+ if err := common . ValidateTags (pv .Tags ); err != nil {
19131885 return nil , err
19141886 }
19151887
0 commit comments