Skip to content

Commit

Permalink
chore: fix context reference
Browse files Browse the repository at this point in the history
Signed-off-by: Juncheng Zhu <[email protected]>
  • Loading branch information
junczhu committed Dec 6, 2024
1 parent a28f41e commit 7d4137a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pkg/verifier/notation/notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func init() {
}

func (f *notationPluginVerifierFactory) Create(_ string, verifierConfig config.VerifierConfig, pluginDirectory string, namespace string) (verifier.ReferenceVerifier, error) {
logger.GetLogger(context.Background(), logOpt).Debugf("creating Notation verifier with config %v, namespace '%v'", verifierConfig, namespace)
ctx := context.Background()
logger.GetLogger(ctx, logOpt).Debugf("creating Notation verifier with config %v, namespace '%v'", verifierConfig, namespace)
verifierName := fmt.Sprintf("%s", verifierConfig[types.Name])
verifierTypeStr := ""
if _, ok := verifierConfig[types.Type]; ok {
Expand All @@ -105,7 +106,7 @@ func (f *notationPluginVerifierFactory) Create(_ string, verifierConfig config.V
if err != nil {
return nil, re.ErrorCodePluginInitFailure.WithDetail("Failed to create the Notation Verifier").WithError(err)
}
verifyService, err := getVerifierService(conf, pluginDirectory, NewCRLHandler())
verifyService, err := getVerifierService(ctx, conf, pluginDirectory, NewCRLHandler())
if err != nil {
return nil, re.ErrorCodePluginInitFailure.WithDetail("Failed to create the Notation Verifier").WithError(err)
}
Expand Down Expand Up @@ -177,7 +178,7 @@ func (v *notationPluginVerifier) Verify(ctx context.Context,
return verifier.NewVerifierResult("", v.name, v.verifierType, "Notation signature verification success", true, nil, extensions), nil
}

func getVerifierService(conf *NotationPluginVerifierConfig, pluginDirectory string, revocationFactory RevocationFactory) (notation.Verifier, error) {
func getVerifierService(ctx context.Context, conf *NotationPluginVerifierConfig, pluginDirectory string, revocationFactory RevocationFactory) (notation.Verifier, error) {
store, err := newTrustStore(conf.VerificationCerts, conf.VerificationCertStores)
if err != nil {
return nil, err
Expand All @@ -190,7 +191,7 @@ func getVerifierService(conf *NotationPluginVerifierConfig, pluginDirectory stri
// Related File: https://github.com/notaryproject/notation/commits/main/cmd/notation/verify.go5
crlFetcher, err := revocationFactory.NewFetcher()
if err != nil {
logger.GetLogger(context.Background(), logOpt).Warnf("Unable to create CRL fetcher for notation verifier %s with error: %s", conf.Name, err)
logger.GetLogger(ctx, logOpt).Warnf("Unable to create CRL fetcher for notation verifier %s with error: %s", conf.Name, err)
}
revocationCodeSigningValidator, err := revocationFactory.NewValidator(revocation.Options{
CRLFetcher: crlFetcher,
Expand Down
2 changes: 1 addition & 1 deletion pkg/verifier/notation/notation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func TestGetVerifierService(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := getVerifierService(tt.conf, tt.pluginDir, tt.RevocationFactory)
_, err := getVerifierService(context.Background(), tt.conf, tt.pluginDir, tt.RevocationFactory)
if (err != nil) != tt.expectErr {
t.Errorf("error = %v, expectErr = %v", err, tt.expectErr)
}
Expand Down

0 comments on commit 7d4137a

Please sign in to comment.