Docker Swarm secrets in config files

It would be really useful is you could set secret values (passwords, API keys…) using the ‘secrets’ feature of Docker Swarm and include them in the config YAML. I see this happening something like:

mqtt:
    broker: mqtt.some.place
    username: homeassistant
    password: !swarm_secret mqtt_password

Which would read the value of /run/secrets/mqtt_password and add it to the config in that place. This doesn’t seem like it would be a hugely complex thing to implement

As of now you can consume docker secrets by modifying the entry point…

    secrets:
      - ha-maria-connection
    entrypoint: /bin/bash -c "export MARIA_CONNECTION=$$(cat /run/secrets/ha-maria-connection) && /init"

In the config file I have

recorder:
  db_url: !env_var MARIA_CONNECTION