Continue on plugin registration error in dev mode (#5791)
* Continue on plugin registration error in dev mode * Continue only on unknown type error * Continue only on unknown type error * Print plugin registration error on exit Co-Authored-By: calvn <cleung2010@gmail.com>
This commit is contained in:
parent
e99957aed9
commit
227a664b06
|
@ -967,7 +967,7 @@ CLUSTER_SYNTHESIS_COMPLETE:
|
|||
return 1
|
||||
}
|
||||
|
||||
var plugins []string
|
||||
var plugins, pluginsNotLoaded []string
|
||||
if c.flagDevPluginDir != "" && c.flagDevPluginInit {
|
||||
|
||||
f, err := os.Open(c.flagDevPluginDir)
|
||||
|
@ -986,8 +986,12 @@ CLUSTER_SYNTHESIS_COMPLETE:
|
|||
for _, name := range list {
|
||||
path := filepath.Join(f.Name(), name)
|
||||
if err := c.addPlugin(path, init.RootToken, core); err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error enabling plugin %s: %s", name, err))
|
||||
return 1
|
||||
if !errwrap.Contains(err, vault.ErrPluginBadType.Error()) {
|
||||
c.UI.Error(fmt.Sprintf("Error enabling plugin %s: %s", name, err))
|
||||
return 1
|
||||
}
|
||||
pluginsNotLoaded = append(pluginsNotLoaded, name)
|
||||
continue
|
||||
}
|
||||
plugins = append(plugins, name)
|
||||
}
|
||||
|
@ -1044,6 +1048,15 @@ CLUSTER_SYNTHESIS_COMPLETE:
|
|||
}
|
||||
}
|
||||
|
||||
if len(pluginsNotLoaded) > 0 {
|
||||
c.UI.Warn("")
|
||||
c.UI.Warn(wrapAtLength(
|
||||
"The following dev plugins FAILED to be registered in the catalog due to unknown type:"))
|
||||
for _, p := range pluginsNotLoaded {
|
||||
c.UI.Warn(fmt.Sprintf(" - %s", p))
|
||||
}
|
||||
}
|
||||
|
||||
c.UI.Warn("")
|
||||
c.UI.Warn(wrapAtLength(
|
||||
"Development mode should NOT be used in production installations!"))
|
||||
|
|
|
@ -26,6 +26,7 @@ var (
|
|||
pluginCatalogPath = "core/plugin-catalog/"
|
||||
ErrDirectoryNotConfigured = errors.New("could not set plugin, plugin directory is not configured")
|
||||
ErrPluginNotFound = errors.New("plugin not found in the catalog")
|
||||
ErrPluginBadType = errors.New("unable to determine plugin type")
|
||||
)
|
||||
|
||||
// PluginCatalog keeps a record of plugins known to vault. External plugins need
|
||||
|
@ -270,7 +271,7 @@ func (c *PluginCatalog) setInternal(ctx context.Context, name string, pluginType
|
|||
|
||||
pluginType, err = c.getPluginTypeFromUnknown(ctx, entryTmp)
|
||||
if err != nil || pluginType == consts.PluginTypeUnknown {
|
||||
return errors.New("unable to determine plugin type")
|
||||
return ErrPluginBadType
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue