initializeRoot populates the TUF_ROOT from a previously initialized origin TUF.
(ctx context.Context)
| 84 | |
| 85 | // initializeRoot populates the TUF_ROOT from a previously initialized origin TUF. |
| 86 | func initializeRoot(ctx context.Context) (context.Context, error) { |
| 87 | var logger log.Logger |
| 88 | logger, ctx = log.LoggerFor(ctx) |
| 89 | |
| 90 | origin, err := originRoot(ctx) |
| 91 | if err != nil { |
| 92 | return ctx, err |
| 93 | } |
| 94 | |
| 95 | newTUFRoot := Root(ctx) |
| 96 | logger.Infof("Copying TUF root from origin %q to %q", origin, newTUFRoot) |
| 97 | if err := copy.Copy(origin, newTUFRoot); err != nil { |
| 98 | return ctx, err |
| 99 | } |
| 100 | |
| 101 | mirror, err := Stub(ctx) |
| 102 | if err != nil { |
| 103 | return ctx, err |
| 104 | } |
| 105 | if err := setupNewTUFClientCache(newTUFRoot, mirror); err != nil { |
| 106 | return ctx, fmt.Errorf("setting up sigstore-go TUF cache: %w", err) |
| 107 | } |
| 108 | |
| 109 | state := testenv.FetchState[state](ctx) |
| 110 | state.initialized = true |
| 111 | return ctx, nil |
| 112 | } |
| 113 | |
| 114 | // setupNewTUFClientCache writes the files that cosign v3's TrustedRoot() |
| 115 | // expects via sigstore-go's TUF client: remote.json with the mirror URL and |
nothing calls this directly
no test coverage detected