* Add ability to specify a plugin dir in dev mode (#3184)

* Change (with backwards compatibility) sha_256 to sha256 for plugin
registration
This commit is contained in:
Jeff Mitchell 2017-08-16 11:17:50 -04:00 committed by GitHub
parent c5918ff79b
commit c34a5b2e93
3 changed files with 16 additions and 4 deletions

View File

@ -74,11 +74,12 @@ type ServerCommand struct {
func (c *ServerCommand) Run(args []string) int {
var dev, verifyOnly, devHA, devTransactional, devLeasedGeneric, devThreeNode bool
var configPath []string
var logLevel, devRootTokenID, devListenAddress string
var logLevel, devRootTokenID, devListenAddress, devPluginDir string
flags := c.Meta.FlagSet("server", meta.FlagSetDefault)
flags.BoolVar(&dev, "dev", false, "")
flags.StringVar(&devRootTokenID, "dev-root-token-id", "", "")
flags.StringVar(&devListenAddress, "dev-listen-address", "", "")
flags.StringVar(&devPluginDir, "dev-plugin-dir", "", "")
flags.StringVar(&logLevel, "log-level", "info", "")
flags.BoolVar(&verifyOnly, "verify-only", false, "")
flags.BoolVar(&devHA, "dev-ha", false, "")
@ -262,6 +263,10 @@ func (c *ServerCommand) Run(args []string) int {
if devLeasedGeneric {
coreConfig.LogicalBackends["generic"] = vault.LeasedPassthroughBackendFactory
}
if devPluginDir != "" {
coreConfig.PluginDirectory = devPluginDir
}
}
if devThreeNode {

View File

@ -806,6 +806,10 @@ func NewSystemBackend(core *Core) *SystemBackend {
Type: framework.TypeString,
Description: strings.TrimSpace(sysHelp["plugin-catalog_name"][0]),
},
"sha256": &framework.FieldSchema{
Type: framework.TypeString,
Description: strings.TrimSpace(sysHelp["plugin-catalog_sha-256"][0]),
},
"sha_256": &framework.FieldSchema{
Type: framework.TypeString,
Description: strings.TrimSpace(sysHelp["plugin-catalog_sha-256"][0]),
@ -939,9 +943,12 @@ func (b *SystemBackend) handlePluginCatalogUpdate(req *logical.Request, d *frame
return logical.ErrorResponse("missing plugin name"), nil
}
sha256 := d.Get("sha_256").(string)
sha256 := d.Get("sha256").(string)
if sha256 == "" {
return logical.ErrorResponse("missing SHA-256 value"), nil
sha256 = d.Get("sha_256").(string)
if sha256 == "" {
return logical.ErrorResponse("missing SHA-256 value"), nil
}
}
command := d.Get("command").(string)

View File

@ -62,7 +62,7 @@ supplied name.
is what is used to look up plugins in the catalog. This is part of the request
URL.
- `sha_256` `(string: <required>)`  This is the SHA256 sum of the plugin's
- `sha256` `(string: <required>)`  This is the SHA256 sum of the plugin's
binary. Before a plugin is run it's SHA will be checked against this value, if
they do not match the plugin can not be run.