feat: Support env replacement for tool.yaml (#462)

Environment variable replacement is needed so that users don't have to
hardcode their secrets in configuring `tools.yaml`.
Both formats `$ENV_NAME` and `${ENV_NAME}` are standard ways to declare
an environment variable.
However, some database statement placeholders that are already using the
`$ENV_NAME` format.
Therefore, we only support env var declaration using `${ENV_NAME}` to
disambiguate it from other usages.

Fixes issue: https://github.com/googleapis/genai-toolbox/issues/431
This commit is contained in:
Wenxin Du
2025-04-23 07:33:02 -04:00
committed by GitHub
parent fc14cbfd07
commit eadb678a7b
21 changed files with 460 additions and 162 deletions

View File

@@ -7,7 +7,7 @@ description: >
---
## About
## About
[SQL Server][mssql-docs] is a relational database management system (RDBMS)
developed by Microsoft that allows users to store, retrieve, and manage large
@@ -20,7 +20,7 @@ amount of data through a structured format.
### Database User
This source only uses standard authentication. You will need to [create a
SQL Server user][mssql-users] to login to the database with.
SQL Server user][mssql-users] to login to the database with.
[mssql-users]: https://learn.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-database-user?view=sql-server-ver16
@@ -29,14 +29,19 @@ SQL Server user][mssql-users] to login to the database with.
```yaml
sources:
my-mssql-source:
kind: "mssql"
host: "127.0.0.1"
port: "1433"
database: "my_db"
user: "my-user"
password: "my-password"
kind: mssql
host: 127.0.0.1
port: 1433
database: my_db
user: ${USER_NAME}
password: ${PASSWORD}
```
{{< notice tip >}}
Use environment variable replacement with the format ${ENV_NAME}
instead of hardcoding your secrets into the configuration file.
{{< /notice >}}
## Reference
| **field** | **type** | **required** | **description** |