get.porter.sh/porter@v1.3.0/pkg/signing/plugins/notation/plugin.go (about) 1 package notation 2 3 import ( 4 "fmt" 5 6 "get.porter.sh/porter/pkg/portercontext" 7 "get.porter.sh/porter/pkg/signing" 8 "get.porter.sh/porter/pkg/signing/plugins" 9 "get.porter.sh/porter/pkg/signing/pluginstore" 10 "github.com/hashicorp/go-plugin" 11 "github.com/mitchellh/mapstructure" 12 ) 13 14 const PluginKey = plugins.PluginInterface + ".porter.notation" 15 16 var _ plugins.SigningProtocol = &Plugin{} 17 18 type PluginConfig struct { 19 SigningKey string `mapstructure:"key,omitempty"` 20 InsecureRegistry bool `mapstructure:"insecureregistry,omitempty"` 21 } 22 23 // Plugin is the plugin wrapper for accessing secrets from a local filesystem. 24 type Plugin struct { 25 signing.Signer 26 } 27 28 func NewPlugin(c *portercontext.Context, rawCfg interface{}) (plugin.Plugin, error) { 29 cfg := PluginConfig{} 30 if err := mapstructure.Decode(rawCfg, &cfg); err != nil { 31 return nil, fmt.Errorf("error reading plugin configuration: %w", err) 32 } 33 34 impl := NewSigner(c, cfg) 35 return pluginstore.NewPlugin(c, impl), nil 36 }