Closed arielmoraes closed 5 years ago
Hi - thanks for the feedback, I appreciate it 🙂
Personally, my take on this is that I would rather see a meaningful exception than the NullReferenceException that would result when I forgot to check if it succeeded (I’m a big fan of Fail Early). But for anything that can throw an exception there should be a way to check if one would be thrown - I could maybe add a static property you could use to check if you’re running in K8s or not. Would that be useful?
Thank you for the fast response. Yes that would be very useful, but in my case we are using the Configuration package and the way we were planning to check if we are inside a k8s cluster is to check the env variable KUBERNETES_SERVICE_HOST. The problem is we can't access the env variables on that step because we are on the Builder step yet, so even if we had such parameter we won't be able to tell unless we parse the args[] (very ugly).
Solved it by using the other overload of ConfigureAppConfiguration
that uses the WebHostBuilderContext
, instead of checking the env var, I'm checking if the Environment is Production. That works.
Glad to hear that works for you - I’ll keep thinking about ways the config provider could be registered to see if it could be improved though :)
When using the LoadFromPodAccountService method, an exception is thrown when not running inside a k8s cluster. Isn't it better not to thrown exceptions? By doing that we do not need to catch anything when running on a development machine.