get.porter.sh/porter@v1.3.0/pkg/signing/plugins/cosign/plugin.go (about)

     1  package cosign
     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.cosign"
    15  
    16  var _ plugins.SigningProtocol = &Plugin{}
    17  
    18  type PluginConfig struct {
    19  	//theses are paths
    20  	PublicKey        string `mapstructure:"publickey,omitempty"`
    21  	PrivateKey       string `mapstructure:"privatekey,omitempty"`
    22  	RegistryMode     string `mapstructure:"registrymode,omitempty"`
    23  	Experimental     bool   `mapstructure:"experimental,omitempty"`
    24  	InsecureRegistry bool   `mapstructure:"insecureregistry,omitempty"`
    25  }
    26  
    27  // Plugin is the plugin wrapper for accessing secrets from a local filesystem.
    28  type Plugin struct {
    29  	signing.Signer
    30  }
    31  
    32  func NewPlugin(c *portercontext.Context, rawCfg interface{}) (plugin.Plugin, error) {
    33  	cfg := PluginConfig{}
    34  	if err := mapstructure.Decode(rawCfg, &cfg); err != nil {
    35  		return nil, fmt.Errorf("error reading plugin configuration: %w", err)
    36  	}
    37  
    38  	impl := NewSigner(c, cfg)
    39  	return pluginstore.NewPlugin(c, impl), nil
    40  }