diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-06-07 17:15:27 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-06-07 19:25:11 +0900 |
| commit | e8bb5a622d0c1895b1768a90d0b422ec084db73f (patch) | |
| tree | 46011917ee77bc70c2f6d473b85cee24dfe3e152 /cmd/mbf/cache.go | |
| parent | 22e508fe17cdf6be6240e6b73ac5b90bc6bfd77e (diff) | |
internal/rosa: mirror service via external cache
This provides an authenticated implementation of the external cache.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf/cache.go')
| -rw-r--r-- | cmd/mbf/cache.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/mbf/cache.go b/cmd/mbf/cache.go index 0452a3e1..b683326f 100644 --- a/cmd/mbf/cache.go +++ b/cmd/mbf/cache.go @@ -2,6 +2,7 @@ package main import ( "context" + "net/http" "os" "path/filepath" "testing" @@ -9,6 +10,7 @@ import ( "hakurei.app/check" "hakurei.app/container" "hakurei.app/internal/pkg" + "hakurei.app/internal/rosa" "hakurei.app/message" ) @@ -30,7 +32,7 @@ type cache struct { // Loaded artifact of [rosa.QEMU]. qemu pkg.Artifact - base string + base, mirror string } // open opens the underlying [pkg.Cache]. @@ -86,6 +88,21 @@ func (cache *cache) open() (err error) { } done <- struct{}{} + if cache.mirror != "" { + var pub []byte + pub, err = os.ReadFile(base.Append("ed25519.pub").String()) + if err != nil { + cache.c.Close() + return + } + var r rosa.Remote + if r, err = rosa.NewRemote(cache.mirror, pub, http.DefaultClient); err != nil { + cache.c.Close() + return err + } + cache.c.SetExternal(r) + } + if cache.qemu != nil { var pathname *check.Absolute pathname, _, err = cache.c.Cure(cache.qemu) |
