MCPcopy Create free account
hub / github.com/conforma/cli / initializeRoot

Function initializeRoot

acceptance/tuf/tuf.go:86–112  ·  view source on GitHub ↗

initializeRoot populates the TUF_ROOT from a previously initialized origin TUF.

(ctx context.Context)

Source from the content-addressed store, hash-verified

84
85// initializeRoot populates the TUF_ROOT from a previously initialized origin TUF.
86func 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

Callers

nothing calls this directly

Calls 7

InfofMethod · 0.95
LoggerForFunction · 0.92
originRootFunction · 0.85
RootFunction · 0.85
StubFunction · 0.85
setupNewTUFClientCacheFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected