609
// ValidateDeploymentVersionFields is a helper that verifies if the fields within a
610
// Worker Deployment Version are valid
611
>
func ValidateDeploymentVersionFields(fieldName string, field string, maxIDLengthLimit int) error {
worker_versioning.go
612
>
// Length checks
613
>
if field == "" {
614
>
return serviceerror.NewInvalidArgumentf("%v cannot be empty", fieldName)
615
>
}
616
617
// Length of each field should be: (MaxIDLengthLimit - (prefix + delimeter length)) / 2
618
// Note: Using the same initial size for both the fields since they are used together to generate the version workflow's ID
619
>
if len(field) > (maxIDLengthLimit-WorkerDeploymentVersionWorkflowIDInitialSize)/2 {
worker_versioning.go
620
>
return serviceerror.NewInvalidArgumentf("size of %v larger than the maximum allowed", fieldName)
621
>
}
622
623
// deploymentName cannot have "."
624
// TODO: remove this restriction once the old version strings are completely cleaned from external and internal API
625
>
if fieldName == WorkerDeploymentNameFieldName && strings.Contains(field, WorkerDeploymentVersionIDDelimiterV31) {
worker_versioning.go
626
>
return serviceerror.NewInvalidArgumentf("worker deployment name cannot contain '%s'", WorkerDeploymentVersionIDDelimiterV31)
627
>
}
628
// deploymentName cannot have ":"
629
>
if fieldName == WorkerDeploymentNameFieldName && strings.Contains(field, WorkerDeploymentVersionDelimiter) {
worker_versioning.go
630
return serviceerror.NewInvalidArgumentf("worker deployment name cannot contain '%s'", WorkerDeploymentVersionDelimiter)
631
}
632
633
// buildID or deployment name cannot start with "__"
635
>
return serviceerror.NewInvalidArgumentf("%v cannot start with '__'", fieldName)
636
>
}
637
639
}
640