Skip to content

Commit 26ce089

Browse files
authored
docs: fix docs (#498)
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
1 parent e5eef5e commit 26ce089

24 files changed

+188
-132
lines changed

dir/path.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const (
5959
// PathSigningKeys is the signingkeys file relative path.
6060
PathSigningKeys = "signingkeys.json"
6161
// PathTrustPolicy is the OCI trust policy file relative path.
62+
//
6263
// Deprecated: PathTrustPolicy exists for historical compatibility and should not be used.
6364
// To get OCI trust policy path, use PathOCITrustPolicy.
6465
PathTrustPolicy = "trustpolicy.json"

example_localSign_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func Example_localSign() {
4646
// exampleSigner is a notation.Signer given key and X509 certificate chain.
4747
// Users should replace `exampleCertTuple.PrivateKey` with their own private
4848
// key and replace `exampleCerts` with the corresponding full certificate
49-
// chain, following the Notary certificate requirements:
49+
// chain, following the Notary Project certificate requirements:
5050
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
5151
exampleSigner, err := signer.NewGenericSigner(exampleCertTuple.PrivateKey, exampleCerts)
5252
if err != nil {

example_localVerify_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func Example_localVerify() {
7373
}
7474

7575
// createTrustStore creates a trust store directory for demo purpose.
76-
// Users could use the default trust store from Notary and add trusted
77-
// certificates into it following the trust store spec:
76+
// Users could use the default trust store from Notary Project and
77+
// add trusted certificates into it following the trust store spec:
7878
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/trust-store-trust-policy.md#trust-store
7979
if err := createTrustStore(); err != nil {
8080
panic(err) // Handle error
@@ -172,7 +172,7 @@ func createTrustStore() error {
172172
// generate the `exampleSignatureEnvelopePem` above.)
173173
// Users should replace `exampleX509Certificate` with their own trusted
174174
// certificate and add to the trust store, following the
175-
// Notary certificate requirements:
175+
// Notary Project certificate requirements:
176176
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
177177
exampleX509Certificate := `-----BEGIN CERTIFICATE-----
178178
MIIDQDCCAiigAwIBAgIBUTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzEL

example_remoteSign_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Example_remoteSign() {
4545
// exampleSigner is a notation.Signer given key and X509 certificate chain.
4646
// Users should replace `exampleCertTuple.PrivateKey` with their own private
4747
// key and replace `exampleCerts` with the corresponding full certificate
48-
// chain, following the Notary certificate requirements:
48+
// chain, following the Notary Project certificate requirements:
4949
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
5050
exampleSigner, err := signer.NewGenericSigner(exampleCertTuple.PrivateKey, exampleCerts)
5151
if err != nil {

example_remoteVerify_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func generateTrustStore() error {
101101
// an example of a valid X509 self-signed certificate for demo purpose ONLY.
102102
// Users should replace `exampleX509Certificate` with their own trusted
103103
// certificate and add to the trust store, following the
104-
// Notary certificate requirements:
104+
// Notary Project certificate requirements:
105105
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
106106
exampleX509Certificate := `-----BEGIN CERTIFICATE-----
107107
MIIDQDCCAiigAwIBAgIBUTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzEL

example_signBlob_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ import (
2424
"github.com/notaryproject/notation-go/signer"
2525
)
2626

27-
// ExampleSignBlob demonstrates how to use signer.BlobSign to sign arbitrary data.
27+
// ExampleSignBlob demonstrates how to use [notation.SignBlob] to sign arbitrary
28+
// data.
2829
func Example_signBlob() {
29-
//exampleSigner implements notation.Signer and notation.BlobSigner. Given key and X509 certificate chain,
30-
// it provides method to sign OCI artifacts or blobs.
30+
// exampleSigner implements [notation.Signer] and [notation.BlobSigner].
31+
// Given key and X509 certificate chain, it provides method to sign OCI
32+
// artifacts or blobs.
3133
// Users should replace `exampleCertTuple.PrivateKey` with their own private
3234
// key and replace `exampleCerts` with the corresponding certificate chain,
33-
//following the Notary certificate requirements:
34-
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
35+
// following the Notary Project certificate requirements:
36+
// https://github.com/notaryproject/specifications/tree/9c81dc773508dedc5a81c02c8d805de04f65050b/specs/signature-specification.md#certificate-requirements
3537
exampleSigner, err := signer.NewGenericSigner(exampleCertTuple.PrivateKey, exampleCerts)
3638
if err != nil {
3739
panic(err) // Handle error
@@ -42,7 +44,7 @@ func Example_signBlob() {
4244
exampleSignatureMediaType := jws.MediaTypeEnvelope
4345
exampleContentMediaType := "video/mp4"
4446

45-
// exampleSignOptions is an example of notation.SignBlobOptions.
47+
// exampleSignOptions is an example of [notation.SignBlobOptions].
4648
exampleSignOptions := notation.SignBlobOptions{
4749
SignerSignOptions: notation.SignerSignOptions{
4850
SignatureMediaType: exampleSignatureMediaType,
@@ -52,7 +54,8 @@ func Example_signBlob() {
5254
UserMetadata: map[string]string{"buildId": "101"},
5355
}
5456

55-
// exampleReader reads the data that needs to be signed. This data can be in a file or in memory.
57+
// exampleReader reads the data that needs to be signed.
58+
// This data can be in a file or in memory.
5659
exampleReader := strings.NewReader("example blob")
5760

5861
// Upon successful signing, signature envelope and signerInfo are returned.

example_signWithTimestmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Example_signWithTimestamp() {
4545
// exampleSigner is a notation.Signer given key and X509 certificate chain.
4646
// Users should replace `exampleCertTuple.PrivateKey` with their own private
4747
// key and replace `exampleCerts` with the corresponding full certificate
48-
// chain, following the Notary certificate requirements:
48+
// chain, following the Notary Project certificate requirements:
4949
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
5050
exampleSigner, err := signer.NewGenericSigner(exampleCertTuple.PrivateKey, exampleCerts)
5151
if err != nil {

example_verifyBlob_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
"github.com/notaryproject/notation-go/verifier/truststore"
2828
)
2929

30-
// examplePolicyDocument is an example of a valid trust policy document.
31-
// trust policy document should follow this spec:
32-
// https://github.com/notaryproject/notaryproject/blob/v1.1.0/specs/trust-store-trust-policy.md#trust-policy
30+
// exampleBlobPolicyDocument is an example of a valid blob trust policy document.
31+
// blob trust policy document should follow this spec:
32+
// https://github.com/notaryproject/specifications/tree/9c81dc773508dedc5a81c02c8d805de04f65050b/specs/trust-store-trust-policy.md#blob-trust-policy
3333
var exampleBlobPolicyDocument = trustpolicy.BlobDocument{
3434
Version: "1.0",
3535
TrustPolicies: []trustpolicy.BlobTrustPolicy{
@@ -42,8 +42,8 @@ var exampleBlobPolicyDocument = trustpolicy.BlobDocument{
4242
},
4343
}
4444

45-
// ExampleVerifyBlob demonstrates how to use verifier.Verify to verify a
46-
// signature of the blob.
45+
// ExampleVerifyBlob demonstrates how to use [notation.VerifyBlob] to verify a
46+
// signature of an arbitrary blob.
4747
func Example_verifyBlob() {
4848
// Both COSE ("application/cose") and JWS ("application/jose+json")
4949
// signature mediaTypes are supported.
@@ -53,23 +53,24 @@ func Example_verifyBlob() {
5353
exampleSignatureEnvelope := getSignatureEnvelope()
5454

5555
// createTrustStoreForBlobVerify creates a trust store directory for demo purpose.
56-
// Users could use the default trust store from Notary and add trusted
56+
// Users could use the default trust store from Notary Project and add trusted
5757
// certificates into it following the trust store spec:
58-
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/trust-store-trust-policy.md#trust-store
58+
// https://github.com/notaryproject/specifications/tree/9c81dc773508dedc5a81c02c8d805de04f65050b/specs/trust-store-trust-policy.md#trust-store
5959
if err := createTrustStoreForBlobVerify(); err != nil {
6060
panic(err) // Handle error
6161
}
6262

63-
// exampleVerifier implements notation.Verify and notation.VerifyBlob.
63+
// exampleVerifier implements [notation.Verify] and [notation.VerifyBlob].
6464
exampleVerifier, err := verifier.NewVerifier(nil, &exampleBlobPolicyDocument, truststore.NewX509TrustStore(dir.ConfigFS()), nil)
6565
if err != nil {
6666
panic(err) // Handle error
6767
}
6868

69-
// exampleReader reads the data that needs to be verified. This data can be in a file or in memory.
69+
// exampleReader reads the data that needs to be verified.
70+
// This data can be in a file or in memory.
7071
exampleReader := strings.NewReader("example blob")
7172

72-
// exampleVerifyOptions is an example of notation.VerifierVerifyOptions
73+
// exampleVerifyOptions is an example of [notation.VerifyBlobOptions]
7374
exampleVerifyOptions := notation.VerifyBlobOptions{
7475
BlobVerifierVerifyOptions: notation.BlobVerifierVerifyOptions{
7576
SignatureMediaType: exampleSignatureMediaType,
@@ -110,8 +111,8 @@ func createTrustStoreForBlobVerify() error {
110111
// generate the `exampleSignatureEnvelopePem` above.)
111112
// Users should replace `exampleX509Certificate` with their own trusted
112113
// certificate and add to the trust store, following the
113-
// Notary certificate requirements:
114-
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
114+
// Notary Project certificate requirements:
115+
// https://github.com/notaryproject/specifications/tree/9c81dc773508dedc5a81c02c8d805de04f65050b/specs/signature-specification.md#certificate-requirements
115116
exampleX509Certificate := `-----BEGIN CERTIFICATE-----
116117
MIIEbDCCAtSgAwIBAgIBUzANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJVUzEL
117118
MAkGA1UECBMCV0ExEDAOBgNVBAcTB1NlYXR0bGUxDzANBgNVBAoTBk5vdGFyeTEl

example_verifyWithTimestamp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func generateTrustStoreWithTimestamp() error {
115115
// an example of a valid X509 self-signed certificate for demo purpose ONLY.
116116
// Users should replace `exampleX509Certificate` with their own trusted
117117
// certificate and add to the trust store, following the
118-
// Notary certificate requirements:
118+
// Notary Project certificate requirements:
119119
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
120120
exampleX509Certificate := `-----BEGIN CERTIFICATE-----
121121
MIIDQDCCAiigAwIBAgIBUTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzEL
@@ -149,7 +149,7 @@ GLAfj/jSf9OH9VLTPHOS8/N0Ka4=
149149
// an example of a valid TSA root certificate for demo purpose ONLY.
150150
// Users should replace `exampleTSARootCertificate` with their own trusted
151151
// TSA root certificate and add to the trust store, following the
152-
// Notary certificate requirements:
152+
// Notary Project certificate requirements:
153153
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
154154
exampleTSARootCertificate := `-----BEGIN CERTIFICATE-----
155155
MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi

notation.go

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313

1414
// Package notation provides signer and verifier for notation Sign
15-
// and Verification.
15+
// and Verification. It supports both OCI artifact and arbitrary blob.
1616
package notation
1717

1818
import (
@@ -48,7 +48,7 @@ var errDoneVerification = errors.New("done verification")
4848

4949
var reservedAnnotationPrefixes = [...]string{"io.cncf.notary"}
5050

51-
// SignerSignOptions contains parameters for Signer.Sign.
51+
// SignerSignOptions contains parameters for [Signer] and [BlobSigner].
5252
type SignerSignOptions struct {
5353
// SignatureMediaType is the envelope type of the signature.
5454
// Currently, both `application/jose+json` and `application/cose` are
@@ -86,18 +86,21 @@ type Signer interface {
8686
Sign(ctx context.Context, desc ocispec.Descriptor, opts SignerSignOptions) ([]byte, *signature.SignerInfo, error)
8787
}
8888

89-
// SignBlobOptions contains parameters for notation.SignBlob.
89+
// SignBlobOptions contains parameters for [notation.SignBlob].
9090
type SignBlobOptions struct {
9191
SignerSignOptions
92+
9293
// ContentMediaType is the media-type of the blob being signed.
9394
ContentMediaType string
95+
9496
// UserMetadata contains key-value pairs that are added to the signature
9597
// payload
9698
UserMetadata map[string]string
9799
}
98100

99101
// BlobDescriptorGenerator creates descriptor using the digest Algorithm.
100-
// Below is the example of minimal descriptor, it must contain mediatype, digest and size of the artifact
102+
// Below is the example of minimal descriptor, it must contain mediatype,
103+
// digest and size of the artifact.
101104
//
102105
// {
103106
// "mediaType": "application/octet-stream",
@@ -110,8 +113,8 @@ type BlobDescriptorGenerator func(digest.Algorithm) (ocispec.Descriptor, error)
110113
// The interface allows signing with local or remote keys,
111114
// and packing in various signature formats.
112115
type BlobSigner interface {
113-
// SignBlob signs the descriptor returned by genDesc ,
114-
// and returns the signature and SignerInfo
116+
// SignBlob signs the descriptor returned by genDesc, and returns the
117+
// signature and SignerInfo.
115118
SignBlob(ctx context.Context, genDesc BlobDescriptorGenerator, opts SignerSignOptions) ([]byte, *signature.SignerInfo, error)
116119
}
117120

@@ -122,7 +125,7 @@ type signerAnnotation interface {
122125
PluginAnnotations() map[string]string
123126
}
124127

125-
// SignOptions contains parameters for notation.Sign.
128+
// SignOptions contains parameters for [notation.Sign].
126129
type SignOptions struct {
127130
SignerSignOptions
128131

@@ -200,7 +203,8 @@ func Sign(ctx context.Context, signer Signer, repo registry.Repository, signOpts
200203
return targetDesc, nil
201204
}
202205

203-
// SignBlob signs the arbitrary data and returns the signature
206+
// SignBlob signs the arbitrary data from blobReader and returns
207+
// the signature and SignerInfo.
204208
func SignBlob(ctx context.Context, signer BlobSigner, blobReader io.Reader, signBlobOpts SignBlobOptions) ([]byte, *signature.SignerInfo, error) {
205209
// sanity checks
206210
if err := validateSignArguments(signer, signBlobOpts.SignerSignOptions); err != nil {
@@ -325,7 +329,8 @@ func (outcome *VerificationOutcome) UserMetadata() (map[string]string, error) {
325329
return payload.TargetArtifact.Annotations, nil
326330
}
327331

328-
// VerifierVerifyOptions contains parameters for Verifier.Verify used for verifying OCI artifact.
332+
// VerifierVerifyOptions contains parameters for [Verifier.Verify] used for
333+
// verifying OCI artifact.
329334
type VerifierVerifyOptions struct {
330335
// ArtifactReference is the reference of the artifact that is being
331336
// verified against to. It must be a full reference.
@@ -344,17 +349,17 @@ type VerifierVerifyOptions struct {
344349
UserMetadata map[string]string
345350
}
346351

347-
// Verifier is a interface for verifying an OCI artifact.
352+
// Verifier is a generic interface for verifying an OCI artifact.
348353
type Verifier interface {
349354
// Verify verifies the `signature` associated with the target OCI artifact
350-
//with manifest descriptor `desc`, and returns the outcome upon
355+
// with manifest descriptor `desc`, and returns the outcome upon
351356
// successful verification.
352357
// If nil signature is present and the verification level is not 'skip',
353358
// an error will be returned.
354359
Verify(ctx context.Context, desc ocispec.Descriptor, signature []byte, opts VerifierVerifyOptions) (*VerificationOutcome, error)
355360
}
356361

357-
// BlobVerifierVerifyOptions contains parameters for BlobVerifier.Verify.
362+
// BlobVerifierVerifyOptions contains parameters for [BlobVerifier.Verify].
358363
type BlobVerifierVerifyOptions struct {
359364
// SignatureMediaType is the envelope type of the signature.
360365
// Currently only `application/jose+json` and `application/cose` are
@@ -375,7 +380,7 @@ type BlobVerifierVerifyOptions struct {
375380

376381
// BlobVerifier is a generic interface for verifying a blob.
377382
type BlobVerifier interface {
378-
// VerifyBlob verifies the `signature` against the target artifact using the
383+
// VerifyBlob verifies the `signature` against the target blob using the
379384
// descriptor returned by descGenFunc parameter and
380385
// returns the outcome upon successful verification.
381386
VerifyBlob(ctx context.Context, descGenFunc BlobDescriptorGenerator, signature []byte, opts BlobVerifierVerifyOptions) (*VerificationOutcome, error)
@@ -386,7 +391,7 @@ type verifySkipper interface {
386391
SkipVerify(ctx context.Context, opts VerifierVerifyOptions) (bool, *trustpolicy.VerificationLevel, error)
387392
}
388393

389-
// VerifyOptions contains parameters for notation.Verify.
394+
// VerifyOptions contains parameters for [notation.Verify].
390395
type VerifyOptions struct {
391396
// ArtifactReference is the reference of the artifact that is being
392397
// verified against to.
@@ -405,7 +410,7 @@ type VerifyOptions struct {
405410
UserMetadata map[string]string
406411
}
407412

408-
// VerifyBlobOptions contains parameters for notation.VerifyBlob.
413+
// VerifyBlobOptions contains parameters for [notation.VerifyBlob].
409414
type VerifyBlobOptions struct {
410415
BlobVerifierVerifyOptions
411416

@@ -414,9 +419,9 @@ type VerifyBlobOptions struct {
414419
}
415420

416421
// VerifyBlob performs signature verification for a blob using notation supported
417-
// verification types (like integrity, authenticity, etc.) and return the
418-
// successful signature verification outcome. The blob is read using blobReader and
419-
// upon successful verification, it returns the descriptor of the blob.
422+
// verification types (like integrity, authenticity, etc.) and returns the
423+
// successful signature verification outcome. The blob is read using blobReader,
424+
// and upon successful verification, it returns the descriptor of the blob.
420425
// For more details on signature verification, see
421426
// https://github.com/notaryproject/notaryproject/blob/main/specs/trust-store-trust-policy.md#signature-verification
422427
func VerifyBlob(ctx context.Context, blobVerifier BlobVerifier, blobReader io.Reader, signature []byte, verifyBlobOpts VerifyBlobOptions) (ocispec.Descriptor, *VerificationOutcome, error) {

plugin/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Manager interface {
3535
List(ctx context.Context) ([]string, error)
3636
}
3737

38-
// CLIManager implements Manager
38+
// CLIManager implements [Manager]
3939
type CLIManager struct {
4040
pluginFS dir.SysFS
4141
}

plugin/plugin.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,30 @@ const maxPluginOutputSize = 64 * 1024 * 1024 // 64 MiB
4040
var executor commander = &execCommander{} // for unit test
4141

4242
// GenericPlugin is the base requirement to be a plugin.
43+
//
4344
// Deprecated: GenericPlugin exists for historical compatibility and should not be used.
4445
// To access GenericPlugin, use the notation-plugin-framework-go's plugin.GenericPlugin type.
4546
type GenericPlugin = plugin.GenericPlugin
4647

4748
// SignPlugin defines the required methods to be a SignPlugin.
49+
//
4850
// Deprecated: SignPlugin exists for historical compatibility and should not be used.
4951
// To access SignPlugin, use the notation-plugin-framework-go's plugin.SignPlugin type.
5052
type SignPlugin = plugin.SignPlugin
5153

5254
// VerifyPlugin defines the required method to be a VerifyPlugin.
55+
//
5356
// Deprecated: VerifyPlugin exists for historical compatibility and should not be used.
5457
// To access VerifyPlugin, use the notation-plugin-framework-go's plugin.VerifyPlugin type.
5558
type VerifyPlugin = plugin.VerifyPlugin
5659

5760
// Plugin defines required methods to be a Plugin.
61+
//
5862
// Deprecated: Plugin exists for historical compatibility and should not be used.
5963
// To access Plugin, use the notation-plugin-framework-go's plugin.Plugin type.
6064
type Plugin = plugin.Plugin
6165

62-
// CLIPlugin implements Plugin interface to CLI plugins.
66+
// CLIPlugin implements [Plugin] interface to CLI plugins.
6367
type CLIPlugin struct {
6468
name string
6569
path string

0 commit comments

Comments
 (0)