From cbcebcdfe80fa6b60caf69d4e77c25ec5a68520e Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Tue, 6 Nov 2018 16:20:28 -0800 Subject: [PATCH 1/2] Reuse the same path spec --- vault/logical_system_paths.go | 43 +---------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/vault/logical_system_paths.go b/vault/logical_system_paths.go index a2321064e68b..499ec23b7748 100644 --- a/vault/logical_system_paths.go +++ b/vault/logical_system_paths.go @@ -561,48 +561,7 @@ func (b *SystemBackend) sealPaths() []*framework.Path { func (b *SystemBackend) pluginsCatalogPaths() []*framework.Path { return []*framework.Path{ { - Pattern: "plugins/catalog/(?P.+)", - - Fields: map[string]*framework.FieldSchema{ - "name": &framework.FieldSchema{ - Type: framework.TypeString, - Description: strings.TrimSpace(sysHelp["plugin-catalog_name"][0]), - }, - "type": &framework.FieldSchema{ - Type: framework.TypeString, - Description: strings.TrimSpace(sysHelp["plugin-catalog_type"][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]), - }, - "command": &framework.FieldSchema{ - Type: framework.TypeString, - Description: strings.TrimSpace(sysHelp["plugin-catalog_command"][0]), - }, - "args": &framework.FieldSchema{ - Type: framework.TypeStringSlice, - Description: strings.TrimSpace(sysHelp["plugin-catalog_args"][0]), - }, - "env": &framework.FieldSchema{ - Type: framework.TypeStringSlice, - Description: strings.TrimSpace(sysHelp["plugin-catalog_env"][0]), - }, - }, - - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: b.handlePluginCatalogUpdate, - }, - - HelpSynopsis: strings.TrimSpace(sysHelp["plugin-catalog"][0]), - HelpDescription: strings.TrimSpace(sysHelp["plugin-catalog"][1]), - }, - { - Pattern: "plugins/catalog/(?Pauth|database|secret)/(?P.+)", + Pattern: "plugins/catalog(/(?Pauth|database|secret))?/(?P.+)", Fields: map[string]*framework.FieldSchema{ "name": &framework.FieldSchema{ From c624f9d29a2af994909c2658c2aa0274b1693544 Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Tue, 6 Nov 2018 16:37:52 -0800 Subject: [PATCH 2/2] Re-arrange paths to proper order --- vault/logical_system_paths.go | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/vault/logical_system_paths.go b/vault/logical_system_paths.go index 499ec23b7748..ab97aa04ebbe 100644 --- a/vault/logical_system_paths.go +++ b/vault/logical_system_paths.go @@ -560,6 +560,26 @@ func (b *SystemBackend) sealPaths() []*framework.Path { func (b *SystemBackend) pluginsCatalogPaths() []*framework.Path { return []*framework.Path{ + { + Pattern: "plugins/catalog/(?Pauth|database|secret)/?$", + + Fields: map[string]*framework.FieldSchema{ + "type": &framework.FieldSchema{ + Type: framework.TypeString, + Description: strings.TrimSpace(sysHelp["plugin-catalog_type"][0]), + }, + }, + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.ListOperation: &framework.PathOperation{ + Callback: b.handlePluginCatalogTypedList, + Summary: "List the plugins in the catalog.", + }, + }, + + HelpSynopsis: strings.TrimSpace(sysHelp["plugin-catalog"][0]), + HelpDescription: strings.TrimSpace(sysHelp["plugin-catalog"][1]), + }, { Pattern: "plugins/catalog(/(?Pauth|database|secret))?/(?P.+)", @@ -612,26 +632,6 @@ func (b *SystemBackend) pluginsCatalogPaths() []*framework.Path { HelpSynopsis: strings.TrimSpace(sysHelp["plugin-catalog"][0]), HelpDescription: strings.TrimSpace(sysHelp["plugin-catalog"][1]), }, - { - Pattern: "plugins/catalog/(?Pauth|database|secret)/?$", - - Fields: map[string]*framework.FieldSchema{ - "type": &framework.FieldSchema{ - Type: framework.TypeString, - Description: strings.TrimSpace(sysHelp["plugin-catalog_type"][0]), - }, - }, - - Operations: map[logical.Operation]framework.OperationHandler{ - logical.ListOperation: &framework.PathOperation{ - Callback: b.handlePluginCatalogTypedList, - Summary: "List the plugins in the catalog.", - }, - }, - - HelpSynopsis: strings.TrimSpace(sysHelp["plugin-catalog"][0]), - HelpDescription: strings.TrimSpace(sysHelp["plugin-catalog"][1]), - }, { Pattern: "plugins/catalog/?$",