Environment variable names for configuration
Description
Documentation mentions: The Cloud SQL Auth Proxy has support for: Configuration with environment variables
However I can't seem to find any details on what exactly the names of environment variables should be?
Potential Solution
No response
Additional Details
No response
If you run ./cloud-sql-proxy --help, there's a section in the message that explains this.
See https://github.com/GoogleCloudPlatform/cloud-sql-proxy/blob/136595b0dbc996b2ed5703e5c2cc4d9d0b80ed40/cmd/root.go#L223-L247 for the message.
@enocom As far as I could find in the docs, there is no available env var for passing auth tokens when using the --auto-iam-authn switch (if it's possible, but missing in the docs, I'll be happy to send a PR).
This would be super useful, specially for Docker scenarios. It could even automatically assume --auto-iam-auth switch if present for extra convenience.
Would this be an acceptable PR to merge? (I can track this by filing a separate issue, if desired)
Do you mean CSQL_PROXY_AUTO_IAM_AUTHN? That is supported. Otherwise, there's not a way to manually provide OAuth2 tokens.
No, not that one, which just maps to --auto-iam-authn.
I had to dig a bit in the repo to confirm that the env var mapped to that switch, as it's not in the docs (fixed by #2264).
What I'd like to pass as env vars are values for --login-token and --token switches, as they're needed when using --auto-iam-authn.
Does CSQL_PROXY_LOGIN_TOKEN and CSQL_PROXY_TOKEN not work? We have tests to ensure that works.
Related to this, I have been looking at the code and docs, and to be honest, I find it a bit confusing. Looking at the GitHub Workflow tests and the .envrc.example file, I see for example for the connection name, it can be defined with a variable per type of database:
- MYSQL_CONNECTION_NAME
- POSTGRES_CONNECTION_NAME
- SQLSERVER_CONNECTION_NAME
but then, in multiple places, the environment variable mentioned is just INSTANCE_CONNECTION_NAME, for example, to be used with the common prefix: CSQL_PROXY_INSTANCE_CONNECTION_NAME.
This is just an example, but in summary, I think it would be nice to document all the different variables and configurations, which are now spread between the README.md, CLI help, and just code.
The best docs we have right now are in the help message -- but agreed that we should surface that better in the README.
Also, by the way, the .envrc.example is only for development of the Proxy -- not for using it.
@hessjcg @enocom thanks for that PR #2264!
Still, I think it could be useful to have all the possible configurations documented somewhere. In the README there are many features explained with their flag, but not all. Ideally, this should be generated from the source code to avoid having to maintain duplicates.
Is there anything against using the automatic Cobra MarkDown docs generator?
If not, may I look into adding it and open a PR? 😃
Still, I think it could be useful to have all the possible configurations documented somewhere. In the README there are many features explained with their flag, but not all. Ideally, this should be generated from the source code to avoid having to maintain duplicates.
This is something we have wanted to fix for a while, I agree there should be one source of truth that generates the README. We actually created an issue for tracking this work but none of us on the team have had the time to get to it yet https://github.com/GoogleCloudPlatform/cloud-sql-proxy/issues/2064
Is there anything against using the automatic Cobra MarkDown docs generator?
I personally don't have anything against the Cobra MarkDown generator but I also don't have any experience with it personally. I will let @enocom and @hessjcg weigh in as well if they are familiar with it.
If not, may I look into adding it and open a PR? 😃
Of course! We absolutely love to take contributions from the community. That would be amazing 👏
@froblesmartin Have you looked at the --help option?
We're working on this same issue for AlloyDB here: https://github.com/GoogleCloudPlatform/alloydb-auth-proxy/issues/709. We'll take a look at the docs generator -- that might be a nice option.
@enocom @jackwotherspoon FYI I have opened https://github.com/GoogleCloudPlatform/cloud-sql-proxy/pull/2336 😉