Skip to content

Commit 9aaf8bc

Browse files
committed
chore: fix/add deprecation messages
Signed-off-by: Pritesh Bandi <[email protected]>
1 parent bffc9c3 commit 9aaf8bc

File tree

6 files changed

+140
-64
lines changed

6 files changed

+140
-64
lines changed

plugin/proto/algorithm.go

+49-37
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ import (
2222
)
2323

2424
// KeySpec is type of the signing algorithm, including algorithm and size.
25+
//
2526
// Deprecated: KeySpec exists for historical compatibility and should not be used.
26-
// To access KeySpec, use the notation-plugin-framework-go's plugin.KeySpec type.
27+
// To access KeySpec, use the notation-plugin-framework-go's [plugin.KeySpec] type.
2728
type KeySpec = plugin.KeySpec
2829

2930
// one of the following supported key spec names.
3031
//
31-
// https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
32+
// Deprecated: KeySpec exists for historical compatibility and should not be used.
33+
// To access KeySpec, use the notation-plugin-framework-go's [plugin.KeySpec].
34+
//
35+
// [keys spec]: https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
3236
const (
3337
KeySpecRSA2048 = plugin.KeySpecRSA2048
3438
KeySpecRSA3072 = plugin.KeySpecRSA3072
@@ -44,20 +48,20 @@ func EncodeKeySpec(k signature.KeySpec) (plugin.KeySpec, error) {
4448
case signature.KeyTypeEC:
4549
switch k.Size {
4650
case 256:
47-
return KeySpecEC256, nil
51+
return plugin.KeySpecEC256, nil
4852
case 384:
49-
return KeySpecEC384, nil
53+
return plugin.KeySpecEC384, nil
5054
case 521:
51-
return KeySpecEC521, nil
55+
return plugin.KeySpecEC521, nil
5256
}
5357
case signature.KeyTypeRSA:
5458
switch k.Size {
5559
case 2048:
56-
return KeySpecRSA2048, nil
60+
return plugin.KeySpecRSA2048, nil
5761
case 3072:
58-
return KeySpecRSA3072, nil
62+
return plugin.KeySpecRSA3072, nil
5963
case 4096:
60-
return KeySpecRSA4096, nil
64+
return plugin.KeySpecRSA4096, nil
6165
}
6266
}
6367
return "", fmt.Errorf("invalid KeySpec %q", k)
@@ -66,22 +70,22 @@ func EncodeKeySpec(k signature.KeySpec) (plugin.KeySpec, error) {
6670
// DecodeKeySpec parses keySpec name to a signature.keySpec type.
6771
func DecodeKeySpec(k plugin.KeySpec) (keySpec signature.KeySpec, err error) {
6872
switch k {
69-
case KeySpecRSA2048:
73+
case plugin.KeySpecRSA2048:
7074
keySpec.Size = 2048
7175
keySpec.Type = signature.KeyTypeRSA
72-
case KeySpecRSA3072:
76+
case plugin.KeySpecRSA3072:
7377
keySpec.Size = 3072
7478
keySpec.Type = signature.KeyTypeRSA
75-
case KeySpecRSA4096:
79+
case plugin.KeySpecRSA4096:
7680
keySpec.Size = 4096
7781
keySpec.Type = signature.KeyTypeRSA
78-
case KeySpecEC256:
82+
case plugin.KeySpecEC256:
7983
keySpec.Size = 256
8084
keySpec.Type = signature.KeyTypeEC
81-
case KeySpecEC384:
85+
case plugin.KeySpecEC384:
8286
keySpec.Size = 384
8387
keySpec.Type = signature.KeyTypeEC
84-
case KeySpecEC521:
88+
case plugin.KeySpecEC521:
8589
keySpec.Size = 521
8690
keySpec.Type = signature.KeyTypeEC
8791
default:
@@ -92,13 +96,17 @@ func DecodeKeySpec(k plugin.KeySpec) (keySpec signature.KeySpec, err error) {
9296
}
9397

9498
// HashAlgorithm is the type of hash algorithm.
99+
//
95100
// Deprecated: HashAlgorithm exists for historical compatibility and should not be used.
96-
// To access HashAlgorithm, use the notation-plugin-framework-go's plugin.HashAlgorithm type.
101+
// To access HashAlgorithm, use the notation-plugin-framework-go's [plugin.HashAlgorithm] type.
97102
type HashAlgorithm = plugin.HashAlgorithm
98103

99104
// one of the following supported hash algorithm names.
100105
//
101-
// https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
106+
// Deprecated: HashAlgorithm exists for historical compatibility and should not be used.
107+
// To access HashAlgorithm, use the notation-plugin-framework-go's [plugin.HashAlgorithm] type.
108+
//
109+
// [hash algorithm]: https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
102110
const (
103111
HashAlgorithmSHA256 = plugin.HashAlgorithmSHA256
104112
HashAlgorithmSHA384 = plugin.HashAlgorithmSHA384
@@ -111,33 +119,37 @@ func HashAlgorithmFromKeySpec(k signature.KeySpec) (plugin.HashAlgorithm, error)
111119
case signature.KeyTypeEC:
112120
switch k.Size {
113121
case 256:
114-
return HashAlgorithmSHA256, nil
122+
return plugin.HashAlgorithmSHA256, nil
115123
case 384:
116-
return HashAlgorithmSHA384, nil
124+
return plugin.HashAlgorithmSHA384, nil
117125
case 521:
118-
return HashAlgorithmSHA512, nil
126+
return plugin.HashAlgorithmSHA512, nil
119127
}
120128
case signature.KeyTypeRSA:
121129
switch k.Size {
122130
case 2048:
123-
return HashAlgorithmSHA256, nil
131+
return plugin.HashAlgorithmSHA256, nil
124132
case 3072:
125-
return HashAlgorithmSHA384, nil
133+
return plugin.HashAlgorithmSHA384, nil
126134
case 4096:
127-
return HashAlgorithmSHA512, nil
135+
return plugin.HashAlgorithmSHA512, nil
128136
}
129137
}
130138
return "", fmt.Errorf("invalid KeySpec %q", k)
131139
}
132140

133141
// SignatureAlgorithm is the type of signature algorithm
142+
//
134143
// Deprecated: SignatureAlgorithm exists for historical compatibility and should not be used.
135-
// To access SignatureAlgorithm, use the notation-plugin-framework-go's plugin.SignatureAlgorithm type.
144+
// To access SignatureAlgorithm, use the notation-plugin-framework-go's [plugin.SignatureAlgorithm] type.
136145
type SignatureAlgorithm = plugin.SignatureAlgorithm
137146

138-
// one of the following supported signing algorithm names.
147+
// one of the following supported [signing algorithm] names.
148+
//
149+
// Deprecated: SignatureAlgorithm exists for historical compatibility and should not be used.
150+
// To access SignatureAlgorithm, use the notation-plugin-framework-go's [plugin.SignatureAlgorithm] type.
139151
//
140-
// https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
152+
// [signing algorithm]: https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
141153
const (
142154
SignatureAlgorithmECDSA_SHA256 = plugin.SignatureAlgorithmECDSA_SHA256
143155
SignatureAlgorithmECDSA_SHA384 = plugin.SignatureAlgorithmECDSA_SHA384
@@ -152,35 +164,35 @@ const (
152164
func EncodeSigningAlgorithm(alg signature.Algorithm) (plugin.SignatureAlgorithm, error) {
153165
switch alg {
154166
case signature.AlgorithmES256:
155-
return SignatureAlgorithmECDSA_SHA256, nil
167+
return plugin.SignatureAlgorithmECDSA_SHA256, nil
156168
case signature.AlgorithmES384:
157-
return SignatureAlgorithmECDSA_SHA384, nil
169+
return plugin.SignatureAlgorithmECDSA_SHA384, nil
158170
case signature.AlgorithmES512:
159-
return SignatureAlgorithmECDSA_SHA512, nil
171+
return plugin.SignatureAlgorithmECDSA_SHA512, nil
160172
case signature.AlgorithmPS256:
161-
return SignatureAlgorithmRSASSA_PSS_SHA256, nil
173+
return plugin.SignatureAlgorithmRSASSA_PSS_SHA256, nil
162174
case signature.AlgorithmPS384:
163-
return SignatureAlgorithmRSASSA_PSS_SHA384, nil
175+
return plugin.SignatureAlgorithmRSASSA_PSS_SHA384, nil
164176
case signature.AlgorithmPS512:
165-
return SignatureAlgorithmRSASSA_PSS_SHA512, nil
177+
return plugin.SignatureAlgorithmRSASSA_PSS_SHA512, nil
166178
}
167179
return "", fmt.Errorf("invalid algorithm %q", alg)
168180
}
169181

170182
// DecodeSigningAlgorithm parses the signing algorithm name from a given string.
171183
func DecodeSigningAlgorithm(raw plugin.SignatureAlgorithm) (signature.Algorithm, error) {
172184
switch raw {
173-
case SignatureAlgorithmECDSA_SHA256:
185+
case plugin.SignatureAlgorithmECDSA_SHA256:
174186
return signature.AlgorithmES256, nil
175-
case SignatureAlgorithmECDSA_SHA384:
187+
case plugin.SignatureAlgorithmECDSA_SHA384:
176188
return signature.AlgorithmES384, nil
177-
case SignatureAlgorithmECDSA_SHA512:
189+
case plugin.SignatureAlgorithmECDSA_SHA512:
178190
return signature.AlgorithmES512, nil
179-
case SignatureAlgorithmRSASSA_PSS_SHA256:
191+
case plugin.SignatureAlgorithmRSASSA_PSS_SHA256:
180192
return signature.AlgorithmPS256, nil
181-
case SignatureAlgorithmRSASSA_PSS_SHA384:
193+
case plugin.SignatureAlgorithmRSASSA_PSS_SHA384:
182194
return signature.AlgorithmPS384, nil
183-
case SignatureAlgorithmRSASSA_PSS_SHA512:
195+
case plugin.SignatureAlgorithmRSASSA_PSS_SHA512:
184196
return signature.AlgorithmPS512, nil
185197
}
186198
return 0, errors.New("unknown signing algorithm")

plugin/proto/errors.go

+24-8
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,41 @@ import (
2626
type ErrorCode = plugin.ErrorCode
2727

2828
const (
29-
// Any of the required request fields was empty,
30-
// or a value was malformed/invalid.
29+
// ErrorCodeValidation is used when any of the required request fields is empty ormalformed/invalid.
30+
//
31+
// Deprecated: ErrorCodeValidation exists for historical compatibility and should not be used.
32+
// To access ErrorCodeValidation, use the notation-plugin-framework-go's [plugin.ErrorCodeValidation].
3133
ErrorCodeValidation = plugin.ErrorCodeValidation
3234

33-
// The contract version used in the request is unsupported.
35+
// ErrorCodeUnsupportedContractVersion is used when when the contract version used in the request is unsupported.
36+
//
37+
// Deprecated: ErrorCodeUnsupportedContractVersion exists for historical compatibility and should not be used.
38+
// To access ErrorCodeUnsupportedContractVersion, use the notation-plugin-framework-go's [plugin.ErrorCodeUnsupportedContractVersion].
3439
ErrorCodeUnsupportedContractVersion = plugin.ErrorCodeUnsupportedContractVersion
3540

36-
// Authentication/authorization error to use given key.
41+
// ErrorCodeAccessDenied is used when user doesn't have required permission to access the key.
42+
//
43+
// Deprecated: ErrorCodeAccessDenied exists for historical compatibility and should not be used.
44+
// To access ErrorCodeAccessDenied, use the notation-plugin-framework-go's [plugin.ErrorCodeAccessDenied].
3745
ErrorCodeAccessDenied = plugin.ErrorCodeAccessDenied
3846

39-
// The operation to generate signature timed out
40-
// and can be retried by Notation.
47+
// ErrorCodeTimeout is used when an operation to generate signature timed out and can be retried by Notation.
48+
//
49+
// Deprecated: ErrorCodeTimeout exists for historical compatibility and should not be used.
50+
// To access ErrorCodeTimeout, use the notation-plugin-framework-go's [plugin.ErrorCodeTimeout].
4151
ErrorCodeTimeout = plugin.ErrorCodeTimeout
4252

43-
// The operation to generate signature was throttles
53+
// ErrorCodeThrottled is used when an operation to generate signature was throttles
4454
// and can be retried by Notation.
55+
//
56+
// Deprecated: ErrorCodeThrottled exists for historical compatibility and should not be used.
57+
// To access ErrorCodeThrottled, use the notation-plugin-framework-go's [plugin.ErrorCodeThrottled].
4558
ErrorCodeThrottled = plugin.ErrorCodeThrottled
4659

47-
// Any general error that does not fall into any categories.
60+
// ErrorCodeGeneric is used when an general error occurred that does not fall into any categories.
61+
//
62+
// Deprecated: ErrorCodeGeneric exists for historical compatibility and should not be used.
63+
// To access ErrorCodeGeneric, use the notation-plugin-framework-go's [plugin.ErrorCodeGeneric].
4864
ErrorCodeGeneric = plugin.ErrorCodeGeneric
4965
)
5066

plugin/proto/metadata.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ package proto
1616
import "github.com/notaryproject/notation-plugin-framework-go/plugin"
1717

1818
// GetMetadataRequest contains the parameters passed in a get-plugin-metadata request.
19+
//
1920
// Deprecated: GetMetadataRequest exists for historical compatibility and should not be used.
20-
// To access GetMetadataRequest, use the notation-plugin-framework-go's plugin.GetMetadataRequest type.
21+
// To access GetMetadataRequest, use the notation-plugin-framework-go's [plugin.GetMetadataRequest] type.
2122
type GetMetadataRequest = plugin.GetMetadataRequest
2223

2324
// GetMetadataResponse provided by the plugin.
25+
//
2426
// Deprecated: GetMetadataResponse exists for historical compatibility and should not be used.
25-
// To access GetMetadataResponse, use the notation-plugin-framework-go's plugin.GetMetadataResponse type.
27+
// To access GetMetadataResponse, use the notation-plugin-framework-go's [plugin.GetMetadataResponse] type.
2628
type GetMetadataResponse = plugin.GetMetadataResponse

plugin/proto/proto.go

+38-4
Original file line numberDiff line numberDiff line change
@@ -18,69 +18,103 @@ package proto
1818
import "github.com/notaryproject/notation-plugin-framework-go/plugin"
1919

2020
// Prefix is the prefix required on all plugin binary names.
21+
//
2122
// Deprecated: Prefix exists for historical compatibility and should not be used.
22-
// To access Prefix, use the notation-plugin-framework-go's plugin.BinaryPrefix type.
23+
// To access Prefix, use the notation-plugin-framework-go's [plugin.BinaryPrefix] type.
2324
const Prefix = plugin.BinaryPrefix
2425

2526
// ContractVersion is the <major>.<minor> version of the plugin contract.
27+
//
2628
// Deprecated: ContractVersion exists for historical compatibility and should not be used.
27-
// To access ContractVersion, use the notation-plugin-framework-go's plugin.ContractVersion type.
29+
// To access ContractVersion, use the notation-plugin-framework-go's [plugin.ContractVersion] type.
2830
const ContractVersion = plugin.ContractVersion
2931

3032
// Command is a CLI command available in the plugin contract.
33+
//
34+
// Deprecated: Command exists for historical compatibility and should not be used.
35+
// To access Command, use the notation-plugin-framework-go's [plugin.Command] type.
3136
type Command = plugin.Command
3237

3338
// Request defines a plugin request, which is always associated to a command.
39+
//
3440
// Deprecated: Request exists for historical compatibility and should not be used.
35-
// To access Request, use the notation-plugin-framework-go's plugin.Request type.
41+
// To access Request, use the notation-plugin-framework-go's [plugin.Request] type.
3642
type Request = plugin.Request
3743

3844
const (
3945
// CommandGetMetadata is the name of the plugin command
4046
// which must be supported by every plugin and returns the
4147
// plugin metadata.
48+
//
49+
// Deprecated: CommandGetMetadata exists for historical compatibility and should not be used.
50+
// To access CommandGetMetadata, use the notation-plugin-framework-go's [plugin.CommandGetMetadata].
4251
CommandGetMetadata = plugin.CommandGetMetadata
4352

4453
// CommandDescribeKey is the name of the plugin command
4554
// which must be supported by every plugin that has the
4655
// SIGNATURE_GENERATOR.RAW capability.
56+
//
57+
// Deprecated: CommandDescribeKey exists for historical compatibility and should not be used.
58+
// To access CommandDescribeKey, use the notation-plugin-framework-go's [plugin.CommandDescribeKey].
4759
CommandDescribeKey = plugin.CommandDescribeKey
4860

4961
// CommandGenerateSignature is the name of the plugin command
5062
// which must be supported by every plugin that has the
5163
// SIGNATURE_GENERATOR.RAW capability.
64+
//
65+
// Deprecated: CommandGenerateSignature exists for historical compatibility and should not be used.
66+
// To access CommandGenerateSignature, use the notation-plugin-framework-go's [plugin.CommandGenerateSignature].
5267
CommandGenerateSignature = plugin.CommandGenerateSignature
5368

5469
// CommandGenerateEnvelope is the name of the plugin command
5570
// which must be supported by every plugin that has the
5671
// SIGNATURE_GENERATOR.ENVELOPE capability.
72+
//
73+
// Deprecated: CommandGenerateEnvelope exists for historical compatibility and should not be used.
74+
// To access CommandGenerateEnvelope, use the notation-plugin-framework-go's [plugin.CommandGenerateEnvelope].
5775
CommandGenerateEnvelope = plugin.CommandGenerateEnvelope
5876

5977
// CommandVerifySignature is the name of the plugin command
6078
// which must be supported by every plugin that has
6179
// any SIGNATURE_VERIFIER.* capability
80+
//
81+
// Deprecated: CommandVerifySignature exists for historical compatibility and should not be used.
82+
// To access CommandVerifySignature, use the notation-plugin-framework-go's [plugin.CommandVerifySignature].
6283
CommandVerifySignature = plugin.CommandVerifySignature
6384
)
6485

6586
// Capability is a feature available in the plugin contract.
87+
//
6688
// Deprecated: Capability exists for historical compatibility and should not be used.
67-
// To access Capability, use the notation-plugin-framework-go's plugin.Capability type.
89+
// To access Capability, use the notation-plugin-framework-go's [plugin.Capability] type.
6890
type Capability = plugin.Capability
6991

7092
const (
7193
// CapabilitySignatureGenerator is the name of the capability
7294
// for a plugin to support generating raw signatures.
95+
//
96+
// Deprecated: CapabilitySignatureGenerator exists for historical compatibility and should not be used.
97+
// To access CapabilitySignatureGenerator, use the notation-plugin-framework-go's [plugin.CapabilitySignatureGenerator].
7398
CapabilitySignatureGenerator = plugin.CapabilitySignatureGenerator
7499

75100
// CapabilityEnvelopeGenerator is the name of the capability
76101
// for a plugin to support generating envelope signatures.
102+
//
103+
// Deprecated: CapabilityEnvelopeGenerator exists for historical compatibility and should not be used.
104+
// To access CapabilityEnvelopeGenerator, use the notation-plugin-framework-go's [plugin.CapabilityEnvelopeGenerator].
77105
CapabilityEnvelopeGenerator = plugin.CapabilityEnvelopeGenerator
78106

79107
// CapabilityTrustedIdentityVerifier is the name of the
80108
// capability for a plugin to support verifying trusted identities.
109+
//
110+
// Deprecated: CapabilityTrustedIdentityVerifier exists for historical compatibility and should not be used.
111+
// To access CapabilityTrustedIdentityVerifier, use the notation-plugin-framework-go's [plugin.CapabilityTrustedIdentityVerifier].
81112
CapabilityTrustedIdentityVerifier = plugin.CapabilityTrustedIdentityVerifier
82113

83114
// CapabilityRevocationCheckVerifier is the name of the
84115
// capability for a plugin to support verifying revocation checks.
116+
//
117+
// Deprecated: CapabilityRevocationCheckVerifier exists for historical compatibility and should not be used.
118+
// To access CapabilityRevocationCheckVerifier, use the notation-plugin-framework-go's [plugin.CapabilityRevocationCheckVerifier].
85119
CapabilityRevocationCheckVerifier = plugin.CapabilityRevocationCheckVerifier
86120
)

0 commit comments

Comments
 (0)