From 1e7f22aeecf9bba88f64c9cc2518e0e24daf6e94 Mon Sep 17 00:00:00 2001 From: Ellie Date: Thu, 17 Jul 2025 12:08:27 -0500 Subject: [PATCH] Add DB type consts (#31295) * add necessary consts * add other db plugins * correct ES * Fix consts in test --- builtin/logical/database/backend_test.go | 10 ++++----- helper/pluginconsts/plugin_consts.go | 26 ++++++++++++++++-------- vault/mount.go | 1 + 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/builtin/logical/database/backend_test.go b/builtin/logical/database/backend_test.go index 425c91ef3c..c2dca32c7f 100644 --- a/builtin/logical/database/backend_test.go +++ b/builtin/logical/database/backend_test.go @@ -1665,8 +1665,8 @@ func TestBackend_GetConnectionMetrics(t *testing.T) { cassandraConfig, }, expectedCounts: map[string]int{ - pluginconsts.DbPostgresqlPlugin: 1, - pluginconsts.DbCassandraPlugin: 1, + pluginconsts.DbPostgresqlPluginType: 1, + pluginconsts.DbCassandraPluginType: 1, }, }, { @@ -1675,7 +1675,7 @@ func TestBackend_GetConnectionMetrics(t *testing.T) { postgresConfig, }, expectedCounts: map[string]int{ - pluginconsts.DbPostgresqlPlugin: 1, + pluginconsts.DbPostgresqlPluginType: 1, }, }, { @@ -1692,8 +1692,8 @@ func TestBackend_GetConnectionMetrics(t *testing.T) { cassandraConfigV2, }, expectedCounts: map[string]int{ - pluginconsts.DbPostgresqlPlugin: 2, - pluginconsts.DbCassandraPlugin: 2, + pluginconsts.DbPostgresqlPluginType: 2, + pluginconsts.DbCassandraPluginType: 2, }, }, } diff --git a/helper/pluginconsts/plugin_consts.go b/helper/pluginconsts/plugin_consts.go index cfcdb52d65..dd0e427f10 100644 --- a/helper/pluginconsts/plugin_consts.go +++ b/helper/pluginconsts/plugin_consts.go @@ -26,14 +26,6 @@ const ( AuthTypeSAML = "saml" AuthTypeApprole = "approle" AuthTypeJWT = "jwt" - DbCassandraPlugin = "cassandra" - DbHanaPlugin = "hdb" - DbInfluxDBPlugin = "influxdb" - DbMongoDBPlugin = "mongodb" - DbMsSQLPlugin = "mssql" - DbMySQLPlugin = "mysql" - DbRedshiftPlugin = "redshift" - DbPostgresqlPlugin = "pgx" SecretEngineAD = "ad" SecretEngineAlicloud = "alicloud" SecretEngineAWS = "aws" @@ -71,3 +63,21 @@ const ( // database type for every database. SecretEngineDatabase = "database" ) + +// These DB consts match the type returned from database plugin's Type() method. +const ( + DbCassandraPluginType = "cassandra" + DbCouchbasePluginType = "couchbase" + DbElasticSearchPluginType = "elasticsearch" + DbHanaPluginType = "hdb" + DbInfluxDBPluginType = "influxdb" + DbMongoDBPluginType = "mongodb" + DbMongoAtlasPluginType = "mongodbatlas" + DbMsSQLPluginType = "mssql" + DbMySQLPluginType = "mysql" + DbPostgresqlPluginType = "pgx" + DbRedshiftPluginType = "redshift" + DbRedisPluginType = "redis" + DbRedisElasticachePluginType = "redisElastiCache" + DbSnowflakePluginType = "snowflake" +) diff --git a/vault/mount.go b/vault/mount.go index 1960918fae..93780b82f5 100644 --- a/vault/mount.go +++ b/vault/mount.go @@ -83,6 +83,7 @@ const ( mountTypeNSCubbyhole = "ns_cubbyhole" mountTypeToken = "token" mountTypeNSToken = "ns_token" + mountTypeDatabase = "database" MountTableUpdateStorage = true MountTableNoUpdateStorage = false