From 26ad774fbed929ef8e8b5cee9948e2b429c9f4f4 Mon Sep 17 00:00:00 2001 From: norman_japheth_aberin Date: Wed, 13 Aug 2025 13:08:12 -0500 Subject: [PATCH] Adding Username support for non-Config File approach --- README.md | 5 +++-- collector/config.go | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2d609621..b9980e58 100644 --- a/README.md +++ b/README.md @@ -977,10 +977,11 @@ databases: #### OCI Vault CLI Configuration -If using the default database with CLI parameters, the exporter will read the password from a secret stored in OCI Vault if you set these two environment variables: +If using the default database with CLI parameters, the exporter will read the username and password from a secret stored in OCI Vault if you set these two environment variables: - `OCI_VAULT_ID` should be set to the OCID of the OCI vault that you wish to use -- `OCI_VAULT_SECRET_NAME` should be set to the name of the secret in the OCI vault which contains the database password +- `OCI_VAULT_USERNAME_SECRET` should be set to the name of the secret in the OCI vault which contains the database username +- `OCI_VAULT_PASSWORD_SECRET` should be set to the name of the secret in the OCI vault which contains the database password > Note that the process must be running under a user that has the OCI CLI installed and configured correctly to access the desired tenancy and region. The OCI Profile used is `DEFAULT`. diff --git a/collector/config.go b/collector/config.go index b93f05a2..d6c326dd 100644 --- a/collector/config.go +++ b/collector/config.go @@ -234,10 +234,9 @@ func (m *MetricsConfiguration) defaultDatabase(cfg *Config) DatabaseConfig { if ociVaultID, useOciVault := os.LookupEnv("OCI_VAULT_ID"); useOciVault { dbconfig.Vault = &VaultConfig{ OCI: &OCIVault{ - ID: ociVaultID, - // For the CLI, only the password may be loaded from a secret. If you need to load - // both the username and password from OCI Vault, use the exporter configuration file. - PasswordSecret: os.Getenv("OCI_VAULT_SECRET_NAME"), + ID: ociVaultID, + UsernameSecret: os.Getenv("OCI_VAULT_USERNAME_SECRET"), + PasswordSecret: os.Getenv("OCI_VAULT_PASSWORD_SECRET"), }, } } else if azVaultID, useAzVault := os.LookupEnv("AZ_VAULT_ID"); useAzVault {