Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: Filter builtins by RunningVersion #17816

Merged
merged 5 commits into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/17816.txt
@@ -0,0 +1,3 @@
```release-note:bug
plugins: Only report deprecation status for builtin plugins.
```
2 changes: 1 addition & 1 deletion vault/logical_system.go
Expand Up @@ -956,7 +956,7 @@ func (b *SystemBackend) mountInfo(ctx context.Context, entry *MountEntry) map[st
}

// Add deprecation status only if it exists
builtinType := b.Core.builtinTypeFromMountEntry(ctx, entry)
builtinType := b.Core.builtinTypeFromMountEntry(ctx, entry, entry.RunningVersion)
if status, ok := b.Core.builtinRegistry.DeprecationStatus(entry.Type, builtinType); ok {
info["deprecation_status"] = status.String()
}
Expand Down
11 changes: 8 additions & 3 deletions vault/mount.go
Expand Up @@ -712,13 +712,18 @@ func (c *Core) mountInternal(ctx context.Context, entry *MountEntry, updateStora

// builtinTypeFromMountEntry attempts to find a builtin PluginType associated
// with the specified MountEntry. Returns consts.PluginTypeUnknown if not found.
func (c *Core) builtinTypeFromMountEntry(ctx context.Context, entry *MountEntry) consts.PluginType {
func (c *Core) builtinTypeFromMountEntry(ctx context.Context, entry *MountEntry, version string) consts.PluginType {
mpalmi marked this conversation as resolved.
Show resolved Hide resolved
if c.builtinRegistry == nil || entry == nil {
return consts.PluginTypeUnknown
}

// Builtin plugins should contain the "builtin" string in their RunningVersion
if !strings.Contains(version, "builtin") {
return consts.PluginTypeUnknown
}

builtinPluginType := func(name string, pluginType consts.PluginType) (consts.PluginType, bool) {
plugin, err := c.pluginCatalog.Get(ctx, name, pluginType, "")
plugin, err := c.pluginCatalog.Get(ctx, name, pluginType, version)
if err == nil && plugin != nil && plugin.Builtin {
return plugin.Type, true
}
Expand Down Expand Up @@ -964,7 +969,7 @@ func (c *Core) handleDeprecatedMountEntry(ctx context.Context, entry *MountEntry

// Allow type to be determined from mount entry when not otherwise specified
if pluginType == consts.PluginTypeUnknown {
pluginType = c.builtinTypeFromMountEntry(ctx, entry)
pluginType = c.builtinTypeFromMountEntry(ctx, entry, entry.RunningVersion)
}

// Handle aliases
Expand Down