Files
buildkit/executor/containerid.go
T
Matthieu MOREL 5a96f64d01 Refactor error handling to use errors.New for consistency
- 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>
2026-08-07 10:13:54 +02:00

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
}