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.
Move release channels to an authoritative channels.db
262e516e838cfc4b16b5d00fd98d5e4ef135aa85 · Keenan Nemetz · 19d ago · parent 24019cb3
Move release channels to an authoritative channels.db Channels are consumed from the public URL and are server-side publication state, so they no longer live on the vole branch or in the derived index. - forge/channel: authoritative SQLite store with schema, validation, and CRUD - config: data/channels.db, opened and closed with the instance - CLI: release channel set|list|clear over a new vole-channel SSH verb - server: maintain for set/clear, read for list, annotated-tag validation, audit channel.set/channel.clear, JSON list - web: channel page and tree read the store; release badges query it - remove the metadata-branch channel parser/validator, the index-derived channel table, and the hook path rules - backup, instance-data, and architecture docs include channels.db Refs: 01M7BPHANWMSW5HK2GT0PY74QZ
server/web/channels.go +24−38
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | package web | |
| 2 | 2 | ||
| 3 | // Release channels. A channel is a mutable metadata pointer to one annotated | ||
| 3 | // Release channels. A channel is a mutable server-side pointer to one annotated | ||
| 4 | 4 | // tag; the bytes it serves are the target release's attached files. Nothing here | |
| 5 | 5 | // knows a package manager: a channel is a stable file tree, and apt/yum layouts | |
| 6 | 6 | // are directory names in that tree. | |
| @@ -15,38 +15,34 @@ import ( | |||
| 15 | 15 | ||
| 16 | 16 | "rodent.software/vole/core/git" | |
| 17 | 17 | "rodent.software/vole/forge/access" | |
| 18 | "rodent.software/vole/forge/channel" | ||
| 18 | 19 | "rodent.software/vole/forge/repo" | |
| 20 | "rodent.software/vole/internal/artifactpath" | ||
| 19 | 21 | "rodent.software/vole/metadata" | |
| 20 | 22 | ) | |
| 21 | 23 | ||
| 22 | // channelRows returns every channel, or an empty list when the metadata branch | ||
| 23 | // has none. The index answers from the snapshot it was built from; a server | ||
| 24 | // without one reads the branch directly. | ||
| 25 | func (w *Web) channels(r *http.Request, m *repo.Meta) []metadata.Channel { | ||
| 26 | if w.Index != nil { | ||
| 27 | if err := w.ensureIndex(memoOf(r), m); err == nil { | ||
| 28 | if list, err := w.Index.Channels(m.ID); err == nil { | ||
| 29 | return list | ||
| 30 | } | ||
| 31 | } | ||
| 24 | // channels returns every channel for a repository. The store is authoritative and | ||
| 25 | // separate from the derived index, so a channel survives `vole admin index rebuild`. | ||
| 26 | func (w *Web) channels(m *repo.Meta) []channel.Channel { | ||
| 27 | if w.ChannelStore == nil { | ||
| 28 | return nil | ||
| 32 | 29 | } | |
| 33 | list, _ := metadata.LoadChannelsAt(m.Git(), metadata.Ref) | ||
| 30 | list, _ := w.ChannelStore.List(m.ID) | ||
| 34 | 31 | return list | |
| 35 | 32 | } | |
| 36 | 33 | ||
| 37 | func (w *Web) channel(r *http.Request, m *repo.Meta, name string) (metadata.Channel, bool) { | ||
| 38 | for _, ch := range w.channels(r, m) { | ||
| 39 | if ch.Name == name { | ||
| 40 | return ch, true | ||
| 41 | } | ||
| 34 | func (w *Web) channel(m *repo.Meta, name string) (channel.Channel, bool) { | ||
| 35 | if w.ChannelStore == nil { | ||
| 36 | return channel.Channel{}, false | ||
| 42 | 37 | } | |
| 43 | return metadata.Channel{}, false | ||
| 38 | ch, ok, _ := w.ChannelStore.Get(m.ID, name) | ||
| 39 | return ch, ok | ||
| 44 | 40 | } | |
| 45 | 41 | ||
| 46 | 42 | // channelTarget resolves the release a channel names. An annotated tag is | |
| 47 | 43 | // required because a channel is a release alias, and the tag object has to match | |
| 48 | 44 | // the pointer: a rewritten tag is a different release, not a moved channel. | |
| 49 | func (w *Web) channelTarget(g *git.Repo, ch metadata.Channel) (git.Tag, bool) { | ||
| 45 | func (w *Web) channelTarget(g *git.Repo, ch channel.Channel) (git.Tag, bool) { | ||
| 50 | 46 | t, err := g.Tag(ch.Release) | |
| 51 | 47 | if err != nil || !t.Annotated || ch.ReleaseObject == "" { | |
| 52 | 48 | return git.Tag{}, false | |
| @@ -58,7 +54,7 @@ func (w *Web) channelTarget(g *git.Repo, ch metadata.Channel) (git.Tag, bool) { | |||
| 58 | 54 | } | |
| 59 | 55 | ||
| 60 | 56 | type channelRow struct { | |
| 61 | metadata.Channel | ||
| 57 | channel.Channel | ||
| 62 | 58 | Target string | |
| 63 | 59 | Dangling bool | |
| 64 | 60 | Body template.HTML | |
| @@ -71,7 +67,7 @@ func (w *Web) Channels(rw http.ResponseWriter, r *http.Request) { | |||
| 71 | 67 | if !ok { | |
| 72 | 68 | return | |
| 73 | 69 | } | |
| 74 | list := w.channels(r, m) | ||
| 70 | list := w.channels(m) | ||
| 75 | 71 | rows := make([]channelRow, 0, len(list)) | |
| 76 | 72 | for _, ch := range list { | |
| 77 | 73 | _, ok := w.channelTarget(m.Git(), ch) | |
| @@ -97,7 +93,7 @@ func (w *Web) ChannelView(rw http.ResponseWriter, r *http.Request) { | |||
| 97 | 93 | if !ok { | |
| 98 | 94 | return | |
| 99 | 95 | } | |
| 100 | ch, ok := w.channel(r, m, r.PathValue("channel")) | ||
| 96 | ch, ok := w.channel(m, r.PathValue("channel")) | ||
| 101 | 97 | if !ok { | |
| 102 | 98 | w.notFound(rw, r) | |
| 103 | 99 | return | |
| @@ -118,7 +114,7 @@ func (w *Web) ChannelFile(rw http.ResponseWriter, r *http.Request) { | |||
| 118 | 114 | if !ok { | |
| 119 | 115 | return | |
| 120 | 116 | } | |
| 121 | ch, ok := w.channel(r, m, r.PathValue("channel")) | ||
| 117 | ch, ok := w.channel(m, r.PathValue("channel")) | ||
| 122 | 118 | if !ok { | |
| 123 | 119 | w.notFound(rw, r) | |
| 124 | 120 | return | |
| @@ -129,7 +125,7 @@ func (w *Web) ChannelFile(rw http.ResponseWriter, r *http.Request) { | |||
| 129 | 125 | return | |
| 130 | 126 | } | |
| 131 | 127 | name := r.PathValue("path") | |
| 132 | if err := metadata.ValidArtifactPath(name); err != nil { | ||
| 128 | if err := artifactpath.Valid(name); err != nil { | ||
| 133 | 129 | w.notFound(rw, r) | |
| 134 | 130 | return | |
| 135 | 131 | } | |
| @@ -178,20 +174,10 @@ func (w *Web) channelCacheControl(m *repo.Meta) string { | |||
| 178 | 174 | } | |
| 179 | 175 | ||
| 180 | 176 | // channelsForTag is the release page's badge list. | |
| 181 | func (w *Web) channelsForTag(r *http.Request, m *repo.Meta, tag string) []string { | ||
| 182 | if w.Index != nil { | ||
| 183 | if err := w.ensureIndex(memoOf(r), m); err == nil { | ||
| 184 | if names, err := w.Index.ChannelsForTag(m.ID, tag); err == nil { | ||
| 185 | return names | ||
| 186 | } | ||
| 187 | } | ||
| 188 | } | ||
| 189 | list, _ := metadata.LoadChannelsAt(m.Git(), metadata.Ref) | ||
| 190 | var names []string | ||
| 191 | for _, ch := range list { | ||
| 192 | if ch.Release == tag { | ||
| 193 | names = append(names, ch.Name) | ||
| 194 | } | ||
| 177 | func (w *Web) channelsForTag(m *repo.Meta, tag string) []string { | ||
| 178 | if w.ChannelStore == nil { | ||
| 179 | return nil | ||
| 195 | 180 | } | |
| 181 | names, _ := w.ChannelStore.ForTag(m.ID, tag) | ||
| 196 | 182 | return names | |
| 197 | 183 | } | |