notaryproject / notation-go

A collection of libraries for supporting sign and verify OCI artifacts. Based on Notary Project specifications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refine constructors of package `verifier`

shizhMSFT opened this issue · comments

#186 has refactored the package verifier according to this design where the constructors of notation.Verifier are

func New() (notation.Verifier, error)
func NewVerifier(trustPolicy *trustpolicy.Document, pluginManager plugin.Manager) (notation.Verifier, error)

However, the constructor APIs do not match the original design. The constructors should be updated to

func New(trustPolicy *trustpolicy.Document, trustStore truststore.X509TrustStore, pluginManager plugin.Manager) (notation.Verifier, error)
func NewFromConfig() (notation.Verifier, error)

to match the original design where New() --> NewFromConfig(), NewVerifier() --> New().

Note: The API naming is consistent with #200.

Got it. Will make the change today.

Here's the diagram to help understanding.

classDiagram
direction LR

Verifier ..> TrustPolicy: Dependency
Verifier ..> TrustStore: Dependency
TrustPolicy --> TrustStore

Verifier ..> PluginManager: Dependency

Please also note that the plugin.Manager can be nil but *trustpolicy.Document and truststore.X509TrustStore MUST NOT be nil.