mirror of
https://github.com/moby/buildkit.git
synced 2026-11-06 05:16:45 +00:00
- Updated multiple instances across various files to replace errors.Errorf with errors.New for error message creation. - This change enhances consistency in error handling throughout the codebase. Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
21 lines
516 B
Go
21 lines
516 B
Go
package executor
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// ValidContainerID validates that id is non-empty and contains only ASCII letters and digits.
|
|
func ValidContainerID(id string) error {
|
|
if id == "" {
|
|
return errors.New("container id must not be empty")
|
|
}
|
|
for i := range len(id) {
|
|
ch := id[i]
|
|
if (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') {
|
|
continue
|
|
}
|
|
return errors.Errorf("invalid container id %q: only letters and numbers are allowed", id)
|
|
}
|
|
return nil
|
|
}
|