JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 20 forks source link

Best practice for multiple environments and the config.toml file #81

Closed kaeedo closed 5 months ago

kaeedo commented 5 months ago

Hello. I've been trying to figure out best practices for dealing with multiple environments and checking in the config.toml file. Specifically, I don't want to expose the postgres connection string with password by checking it into source control. Is there some best practice for reading it in from dotnet user-secrets or env vars, or having an override such as config.local.toml which would get .gitignored?

Thanks

JordanMarr commented 5 months ago

Having a built-in way to hide connection strings that contain a password would be a great feature. There is currently not a built-in way to do this. For a temporary solution, you would probably need to manually add the toml file(s) to your gitignore.

kaeedo commented 5 months ago

Thanks. That's what i've been doing now. Just as another suggestion, maybe you could pass in the connectionString/password via a CLI argument. something like dotnet sqlhydra npgsql --connection-string "My connection string"

JordanMarr commented 5 months ago

That seems like a good approach. Is the idea that you would use a variable in the command line for the password, or do you have another technique in mind?

Like this:

dotnet sqlhydra npgsql --connection-string "Server=localhost,12019;Database=AdventureWorks;User=sa;Password=$(Password);TrustServerCertificate=True"
kaeedo commented 5 months ago

Basically that. Then you can use your favorite CLI tools to pass the connection string via STDOUT or similar

dotnet sqlhydra npgsql --connection-string $CONNSTR

JordanMarr commented 5 months ago

SqlHydra.Cli v2.3.3 is published with new arg:

Input.OptionMaybe<string>(["-cs"; "--connection-string"], "The DB connection string to use. This will override the connection string in the toml file.")
JordanMarr commented 5 months ago

I should probably document the various command line arguments that have been added. But then again, it uses FSharp.SystemCommandLine, so it is kind of self documenting. ¯\(ツ)

kaeedo commented 5 months ago

Cool. Thanks much