Hi everyone, our dev team uses external config plu...
# questions
j
Hi everyone, our dev team uses external config plugin to isolate database credentials from source code at GitHub. But when any developer need to update some config at application.yml related to dataSource need to connect in the cloud instance machine (we use ECS Fargate) and update instead of commit application.yml changes simply. Is there any solution where we put all dataSource config in the github repository, but the database credentials are merged from local file from cloud instance machine?
m
Hi Joás, you could set the values with environment variables or use https://github.com/sbglasius/external-config to specify files to include in configuration.
j
Ok, but when I use external-config plugin I override all key tree. What I want is merge keys between repository file and external config Repository file:
Copy code
dataSources:
    dataSource:
        dbCreate: update
        url: "jdbc:www.database"
        driverClassName: "com.mysql.cj.jdbc.Driver"
        username: 
        password: 
        type: "com.zaxxer.hikari.HikariDataSource"
        properties:
            connectionTimeout: 30000
            idleTimeout: 600000
            maxLifetime: 1800000
            connectionTestQuery: "SELECT 1"
            maximumPoolSize: 50
            leakDetectionThreshold: 15000
And put only database credentials in external config/local file:
Copy code
dataSources:
    dataSource:
        username: "username"
        password: "password"
What do you suggest @mattias_reichel?
s
I used the bootRun{} section of my build.gradle to set properties like this: systemProperty 'DATABASE_URL', System.getProperty('DATABASE_URL') systemProperty 'DATABASE_PASSWORD', System.getProperty('DATABASE_PASSWORD') And then substituted them into the yaml using '${DATABASE_URL}'.
And property is passed using -DDATABASE_URL=... when launching app
a
We do exactly what you say, we put the base config in the checked in file and just merge in the username/password from a file mapped to a secret in Kubernetes. It works exactly like you want.
j
@Aaron This external file merged was an .properties or another format like yaml?
a
In our case, I think it’s still .groovy, but I’m pretty sure it merges all the config keys together
j
Thanks for helping