Add public bundle manifest package

This commit is contained in:
2026-06-01 20:52:23 +00:00
parent e51bc28b05
commit bb68cb6602
17 changed files with 941 additions and 181 deletions

31
pkg/bundle/path.go Normal file
View File

@@ -0,0 +1,31 @@
package bundle
import (
"fmt"
"path"
"strings"
)
const distributorStateName = ".distributor.json"
func ValidateSourcePath(value string) error {
if value == "" {
return fmt.Errorf("source path is required")
}
if strings.Contains(value, "\\") || strings.HasPrefix(value, "/") {
return fmt.Errorf("source path %q must be a clean relative slash-separated path", value)
}
if path.Clean(value) != value {
return fmt.Errorf("source path %q must be a clean relative slash-separated path", value)
}
for _, segment := range strings.Split(value, "/") {
if segment == "" || segment == "." || segment == ".." {
return fmt.Errorf("source path %q must be a clean relative slash-separated path", value)
}
}
switch value {
case ManifestName, distributorStateName:
return fmt.Errorf("%q is reserved", value)
}
return nil
}