From e7bcb6961178788ceb5a2e63e33388a188b574c9 Mon Sep 17 00:00:00 2001 From: Asra Ali Date: Tue, 31 May 2022 10:04:43 -0500 Subject: [PATCH] pass embedded into initialization Signed-off-by: Asra Ali --- pkg/cosign/tuf/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/cosign/tuf/client.go b/pkg/cosign/tuf/client.go index 37b1fb62bcb..c5df317589f 100644 --- a/pkg/cosign/tuf/client.go +++ b/pkg/cosign/tuf/client.go @@ -228,12 +228,14 @@ func (t *TUF) Close() error { // * mirror: provides a reference to a remote GCS or HTTP mirror. // * root: provides an external initial root.json. When this is not provided, this // defaults to the embedded root.json. +// * embedded: An embedded filesystem that provides a trusted root and pre-downloaded +// targets in a targets/ subfolder. // * forceUpdate: indicates checking the remote for an update, even when the local // timestamp.json is up to date. -func initializeTUF(ctx context.Context, mirror string, root []byte, forceUpdate bool) (*TUF, error) { +func initializeTUF(ctx context.Context, mirror string, root []byte, embedded fs.FS, forceUpdate bool) (*TUF, error) { t := &TUF{ mirror: mirror, - embedded: GetEmbedded(), + embedded: embedded, } t.targets = newFileImpl() @@ -299,12 +301,12 @@ func NewFromEnv(ctx context.Context) (*TUF, error) { } // Initializes a new TUF object from the local cache or defaults. - return initializeTUF(ctx, mirror, nil, false) + return initializeTUF(ctx, mirror, nil, GetEmbedded(), false) } func Initialize(ctx context.Context, mirror string, root []byte) error { // Initialize the client. Force an update. - t, err := initializeTUF(ctx, mirror, root, true) + t, err := initializeTUF(ctx, mirror, root, GetEmbedded(), true) if err != nil { return err }