TheAxelander / OpenBudgeteer

OpenBudgeteer is a budgeting app based on the Bucket Budgeting Principle
https://theaxelander.github.io
MIT License
763 stars 43 forks source link

Environment Variable Format #71

Closed tvories closed 2 years ago

tvories commented 2 years ago

I'm trying to create a helm chart for this project so you can run it in a kubernetes cluster. Helm won't allow for the unique way you are setting environment variables like Connection:Provider. Is there another way to pass these values in? I realize it's not your job to support helm, but I am very curious if you have any ideas.

Here's the error I'm getting in helm if you were curious:

Error: INSTALLATION FAILED: ConfigMap "openbudgeteer-config" is invalid: data[Connection:Provider]: Invalid value: "Connection:Provider": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name',  or 'KEY_NAME',  or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')
helm.go:88: [debug] ConfigMap "openbudgeteer-config" is invalid: data[Connection:Provider]: Invalid value: "Connection:Provider": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name',  or 'KEY_NAME',  or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')
TheAxelander commented 2 years ago

I'm aware of that the way how environment variables are the defined is not "state of the art" compared to other projects. It's just the way how .NET handles the appsettings.json file. That would be also my workaround proposal for the meantime:

Bind the appsettings.json like below and configure everything there.

- volumes:
  - ./config/appsettings.json:/app/appsettings.json 

For the future I can maybe change this to get rid of the : character.

tvories commented 2 years ago

@TheAxelander that's perfect! I can easily mount appsettings.json to the container. My only concern is if the app changes, then writing the entire config file may run into versioning issues if you add a new field or something. For now I think I can get this to work, though.

This is the example I have on my setup right now:

{
  "Connection": {
    "Provider" :  "mysql", 
    "Database": "openbudgeteer-dev", <-- these values must be overridden by the environment variables? because this is not my env setting
    "Server": "192.168.178.86",
    "Port": "3306", 
    "User": "openbudgeteer-dev",
    "Password": "openbudgeteer-dev"
  },
  "AppSettings": {
    "Culture": "en-US"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

These values must be overridden by the environment variables? Because this is my live docker deployment and I have different information set in my env's.

TheAxelander commented 2 years ago

Fixed on pre-release