1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-01-20 18:52:16 +00:00
kyverno/cmd/internal/tuf.go
2023-09-22 14:32:57 +05:30

31 lines
852 B
Go

package internal
import (
"context"
"fmt"
"github.com/go-logr/logr"
"github.com/sigstore/cosign/v2/pkg/blob"
"github.com/sigstore/sigstore/pkg/tuf"
)
func setupSigstoreTUF(ctx context.Context, logger logr.Logger) {
if !enableTUF {
return
}
logger = logger.WithName("sigstore-tuf").WithValues("tufroot", tufRoot, "tufmirror", tufMirror)
logger.Info("setup tuf client for sigstore...")
var tufRootBytes []byte
var err error
if tufRoot != "" {
tufRootBytes, err = blob.LoadFileOrURL(tufRoot)
if err != nil {
checkError(logger, err, fmt.Sprintf("Failed to read alternate TUF root file %s : %v", tufRoot, err))
}
}
logger.Info("Initializing TUF root")
if err := tuf.Initialize(ctx, tufMirror, tufRootBytes); err != nil {
checkError(logger, err, fmt.Sprintf("Failed to initialize TUF client from %s : %v", tufRoot, err))
}
}