net-daemon / netdaemon

An application daemon for Home Assistant written in .NET
MIT License
223 stars 64 forks source link

Add support for dotnet user-secrets in nd-codegen #698

Closed PartemImperium closed 1 year ago

PartemImperium commented 2 years ago

The problem

I use dotnet user-secrets to store my HA host info as I dont want it stored in source control. As such I would need to use the cli parameters to specify the host instead of just letting it grab it automatically.

The proposed solution

Add support for dotnet user-secrets. This can be done by adding the nuget package and a line in the GetConfigurationRoot function (https://github.com/net-daemon/netdaemon/blob/dev/src/HassModel/NetDaemon.HassModel.CodeGenerator/Program.cs#L52) to add the user-secrets provider. This guide outlines the steps to add user-secrets (https://makolyte.com/how-to-add-user-secrets-in-a-dotnetcore-console-app/).

The alternatives

Settings in dotnet user-secrets will not get used and therefore will have to be passed by hand.

Additional context

Thinking about it the user-secrets works with the "UserSecretsId" in the csproj to match to the correct settings. This may make this not feasible.

I would be willing to do the work and make a PR if we decide we like the idea.

helto4real commented 2 years ago

Yea I think this is an good idea. The aim of the new design was to use .NET standard way of handling configuration.