get.porter.sh/porter@v1.3.0/pkg/signing/plugin_adapter.go (about) 1 package signing 2 3 import ( 4 "context" 5 "io" 6 7 "get.porter.sh/porter/pkg/signing/plugins" 8 ) 9 10 var _ Signer = PluginAdapter{} 11 12 // PluginAdapter converts between the low-level plugins.SigningProtocol and 13 // the signing.Signer interface. 14 type PluginAdapter struct { 15 plugin plugins.SigningProtocol 16 } 17 18 // NewPluginAdapter wraps the specified storage plugin. 19 func NewPluginAdapter(plugin plugins.SigningProtocol) PluginAdapter { 20 return PluginAdapter{plugin: plugin} 21 } 22 23 func (a PluginAdapter) Close() error { 24 if closer, ok := a.plugin.(io.Closer); ok { 25 return closer.Close() 26 } 27 return nil 28 } 29 30 func (a PluginAdapter) Sign(ctx context.Context, ref string) error { 31 return a.plugin.Sign(ctx, ref) 32 } 33 34 func (a PluginAdapter) Verify(ctx context.Context, ref string) error { 35 return a.plugin.Verify(ctx, ref) 36 } 37 38 func (a PluginAdapter) Connect(ctx context.Context) error { 39 return a.plugin.Connect(ctx) 40 }