vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Publish release and run artifacts as file trees
5f2a0b0a7f84ec1bb43af5213e5c788039b72222 · Keenan Nemetz · 20d ago · parent 6d574bec
Publish release and run artifacts as file trees Release pointers and run outputs are now slash-separated paths. A flat name is a one-segment path, so every existing release, pointer, URL, and workflow that uses dist/* keeps working. - metadata validates artifact paths, lists and loads them recursively, and refuses a tag that would make the tag/path boundary ambiguous - vole release attach keeps a directory's relative paths; a plain file keeps its base name - a workflow match is published relative to the declaration's static root, so dist/* stays flat while dist/*/* keeps one directory level - release and run download routes accept nested paths; Content-Disposition still saves the base name - one internal rule is shared by the pointer writer, metadata validator, run record, CLI, and routes so they cannot disagree Refs: 01M7BPH6RRPK2934FCHVJPQNGY
internal/artifactpath/artifactpath.go +54
| @@ -0,0 +1,54 @@ | |||
| 1 | // Package artifactpath is the path rule shared by release attachments and run | ||
| 2 | // outputs. Both are slash-separated paths relative to a root: a flat file is one | ||
| 3 | // segment, and a package layout is a small tree. | ||
| 4 | // | ||
| 5 | // The rule is one place because the pointer writer, the metadata validator, the | ||
| 6 | // runner's artifact report, and the download routes must agree. A path that one | ||
| 7 | // layer accepts and another refuses is a release that cannot be published, or a | ||
| 8 | // link that cannot be served. | ||
| 9 | package artifactpath | ||
| 10 | |||
| 11 | import ( | ||
| 12 | "fmt" | ||
| 13 | "strings" | ||
| 14 | ) | ||
| 15 | |||
| 16 | const ( | ||
| 17 | // MaxSegment is the old flat-name bound. A segment is a filename. | ||
| 18 | MaxSegment = 200 | ||
| 19 | // MaxDepth keeps a pathological tree from turning one release into thousands | ||
| 20 | // of metadata paths. | ||
| 21 | MaxDepth = 32 | ||
| 22 | // MaxPath bounds the whole slash-separated path. | ||
| 23 | MaxPath = 1024 | ||
| 24 | ) | ||
| 25 | |||
| 26 | // Valid checks one artifact path. Empty segments, '.' and '..', backslashes, NUL, | ||
| 27 | // and control characters are refused. A leading or trailing slash is an empty | ||
| 28 | // segment, so it is refused the same way. | ||
| 29 | func Valid(path string) error { | ||
| 30 | if path == "" { | ||
| 31 | return fmt.Errorf("an artifact needs a path") | ||
| 32 | } | ||
| 33 | if len(path) > MaxPath { | ||
| 34 | return fmt.Errorf("artifact path is %d bytes, limit %d", len(path), MaxPath) | ||
| 35 | } | ||
| 36 | if strings.ContainsAny(path, "\\\x00\n\r\t") { | ||
| 37 | return fmt.Errorf("artifact path %q contains a backslash or control character", path) | ||
| 38 | } | ||
| 39 | segments := strings.Split(path, "/") | ||
| 40 | if len(segments) > MaxDepth { | ||
| 41 | return fmt.Errorf("artifact path has %d segments, limit %d", len(segments), MaxDepth) | ||
| 42 | } | ||
| 43 | for _, segment := range segments { | ||
| 44 | switch { | ||
| 45 | case segment == "": | ||
| 46 | return fmt.Errorf("artifact path %q has an empty segment", path) | ||
| 47 | case segment == "." || segment == "..": | ||
| 48 | return fmt.Errorf("artifact path %q must not contain %q", path, segment) | ||
| 49 | case len(segment) > MaxSegment: | ||
| 50 | return fmt.Errorf("artifact path segment is %d bytes, limit %d", len(segment), MaxSegment) | ||
| 51 | } | ||
| 52 | } | ||
| 53 | return nil | ||
| 54 | } | ||