carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "context"
5 "database/sql"
6 "github.com/carlosframework/platform/internal/hostbox"
7 "github.com/carlosframework/platform/internal/release"
8 "github.com/carlosframework/platform/internal/rootparticipation"
9 "testing"
10)
11
12func openLegacyInventory(t *testing.T, path string) (*hostbox.StopInventoryDB, error) {
13 t.Helper()
14 j, err := hostbox.OpenLaunchJournal(path)
15 if err != nil {
16 return nil, err
17 }
18 t.Cleanup(func() { j.Close() })
19 service, err := hostbox.NewJournalService(j)
20 if err != nil {
21 return nil, err
22 }
23 db, err := sql.Open("sqlite", path)
24 if err != nil {
25 return nil, err
26 }
27 defer db.Close()
28 for _, name := range []string{"launches", "journal_requests", "journal_receipt_retention"} {
29 if _, err := db.Exec("DROP TABLE " + name); err != nil {
30 return nil, err
31 }
32 }
33 return service.Inventory, nil
34}
35
36func legacyActivationReady(ctx context.Context) error {
37 l, err := rootparticipation.Open()
38 if err != nil {
39 return err
40 }
41 defer l.State.Close()
42 return l.ActivationReady(ctx)
43}
44func publishHistoryFixture(ctx context.Context, store release.Store, signer release.Signer, key string, grant any) error {
45 raw, err := release.SignRootEnvelope(signer, grant)
46 if err != nil {
47 return err
48 }
49 _, err = store.Put(ctx, key, raw, "")
50 return err
51}
52