Groovy web console

subscribe to the feed Subscribe
to this
site

t

Published 1 month ago by t with tags t
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def resolveDatabaseType() {
    def databaseEngine = "${DATABASE_ENGINE}"
    switch(databaseEngine){
        case ~/aws-rds-aurora-postgres|aws-rds-postgres/:
            DATABASE_TYPE = "postgres"
            break
        case "aws-rds-oracle":
            DATABASE_TYPE = "oracle"
            break
        case {!it && "${DATABASE_TYPE}".toLowerCase() == "oracle"}:
            DATABASE_ENGINE = "aws-rds-oracle"
            break
        case {!it && "${DATABASE_TYPE}".toLowerCase() == "postgres"}:
            DATABASE_ENGINE = "aws-rds-postgres"
            break
    }
    return "${DATABASE_TYPE}"
}


DATABASE_ENGINE = ""
DATABASE_TYPE = "postgres"
resolveDatabaseType()
println("DATABASE_TYPE=${DATABASE_TYPE}, DATABASE_ENGINE=${DATABASE_ENGINE}")

DATABASE_ENGINE = ""
DATABASE_TYPE = "oracle"
resolveDatabaseType()
println("DATABASE_TYPE=${DATABASE_TYPE}, DATABASE_ENGINE=${DATABASE_ENGINE}")

DATABASE_ENGINE = "aws-rds-postgres"
DATABASE_TYPE = ""
resolveDatabaseType()
println("DATABASE_TYPE=${DATABASE_TYPE}, DATABASE_ENGINE=${DATABASE_ENGINE}")

DATABASE_ENGINE = "aws-rds-aurora-postgres"
DATABASE_TYPE = ""
resolveDatabaseType()
println("DATABASE_TYPE=${DATABASE_TYPE}, DATABASE_ENGINE=${DATABASE_ENGINE}")

DATABASE_ENGINE = "aws-rds-oracle"
DATABASE_TYPE = ""
resolveDatabaseType()
println("DATABASE_TYPE=${DATABASE_TYPE}, DATABASE_ENGINE=${DATABASE_ENGINE}")