| 1 | // Copyright The Notary Project Authors. |
| 2 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | // you may not use this file except in compliance with the License. |
| 4 | // You may obtain a copy of the License at |
| 5 | // |
| 6 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | // |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | |
| 14 | package pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/ |
| 15 | |
| 16 | // GetMetadataRequest contains the parameters passed in a get-plugin-metadata |
| 17 | // request. |
| 18 | type GetMetadataRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataRequest# struct { |
| 19 | PluginConfigscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataRequest#PluginConfig. map[string]string `json:"pluginConfig,omitempty"` |
| 20 | } |
| 21 | |
| 22 | func (GetMetadataRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataRequest#) Commandscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataRequest#Command().() Commandscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Command# { |
| 23 | return CommandGetMetadatascip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CommandGetMetadata. |
| 24 | } |
| 25 | |
| 26 | // Validate validates GetMetadataRequest struct |
| 27 | func (GetMetadataRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataRequest#) Validatescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataRequest#Validate().() error { |
| 28 | return nil |
| 29 | } |
| 30 | |
| 31 | // GetMetadataResponse provided by the plugin. |
| 32 | type GetMetadataResponsescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse# struct { |
| 33 | Namescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Name. string `json:"name"` |
| 34 | Descriptionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Description. string `json:"description"` |
| 35 | Versionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Version. string `json:"version"` |
| 36 | URLscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#URL. string `json:"url"` |
| 37 | SupportedContractVersionsscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#SupportedContractVersions. []string `json:"supportedContractVersions,omitempty"` |
| 38 | Capabilitiesscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Capabilities. []Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability# `json:"capabilities"` |
| 39 | } |
| 40 | |
| 41 | // HasCapability return true if the metadata states that the |
| 42 | // capability is supported. |
| 43 | // Returns true if capability is empty. |
| 44 | func (resp *GetMetadataResponsescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#) HasCapabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#HasCapability().(capability Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#) bool { |
| 45 | if capability == "" { |
| 46 | return true |
| 47 | } |
| 48 | for _, c := range resp.Capabilitiesscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Capabilities. { |
| 49 | if c == capability { |
| 50 | return true |
| 51 | } |
| 52 | } |
| 53 | return false |
| 54 | } |