-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathproto.go
76 lines (61 loc) · 2.66 KB
/
proto.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Package proto defines the protocol layer for communication between notation
// and notation external plugin.
package proto
// Prefix is the prefix required on all plugin binary names.
const Prefix = "notation-"
// ContractVersion is the <major>.<minor> version of the plugin contract.
const ContractVersion = "1.0"
// Command is a CLI command available in the plugin contract.
type Command string
// Request defines a plugin request, which is always associated to a command.
type Request interface {
Command() Command
}
const (
// CommandGetMetadata is the name of the plugin command
// which must be supported by every plugin and returns the
// plugin metadata.
CommandGetMetadata Command = "get-plugin-metadata"
// CommandDescribeKey is the name of the plugin command
// which must be supported by every plugin that has the
// SIGNATURE_GENERATOR.RAW capability.
CommandDescribeKey Command = "describe-key"
// CommandGenerateSignature is the name of the plugin command
// which must be supported by every plugin that has the
// SIGNATURE_GENERATOR.RAW capability.
CommandGenerateSignature Command = "generate-signature"
// CommandGenerateEnvelope is the name of the plugin command
// which must be supported by every plugin that has the
// SIGNATURE_GENERATOR.ENVELOPE capability.
CommandGenerateEnvelope Command = "generate-envelope"
// CommandVerifySignature is the name of the plugin command
// which must be supported by every plugin that has
// any SIGNATURE_VERIFIER.* capability
CommandVerifySignature Command = "verify-signature"
)
// Capability is a feature available in the plugin contract.
type Capability string
const (
// CapabilitySignatureGenerator is the name of the capability
// for a plugin to support generating raw signatures.
CapabilitySignatureGenerator Capability = "SIGNATURE_GENERATOR.RAW"
// CapabilityEnvelopeGenerator is the name of the capability
// for a plugin to support generating envelope signatures.
CapabilityEnvelopeGenerator Capability = "SIGNATURE_GENERATOR.ENVELOPE"
// CapabilityTrustedIdentityVerifier is the name of the
// capability for a plugin to support verifying trusted identities.
CapabilityTrustedIdentityVerifier Capability = "SIGNATURE_VERIFIER.TRUSTED_IDENTITY"
// CapabilityRevocationCheckVerifier is the name of the
// capability for a plugin to support verifying revocation checks.
CapabilityRevocationCheckVerifier Capability = "SIGNATURE_VERIFIER.REVOCATION_CHECK"
)
// In returns true if the Capability is present in the given array of
// capabilities.
func (c Capability) In(capabilities []Capability) bool {
for _, capability := range capabilities {
if c == capability {
return true
}
}
return false
}