From 23a89fe1def8985bea7e3ead901cac9772e46790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A8=D1=83?= =?UTF-8?q?=D0=BB=D1=8C=D0=B3=D0=B0=D1=87=D0=B8=D0=BA?= Date: Mon, 19 Nov 2018 14:49:31 +0300 Subject: [PATCH] Add ability to set DB driver and DB credentials from environment variables --- main.go | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 3b5c1f0..97eea9f 100644 --- a/main.go +++ b/main.go @@ -57,27 +57,32 @@ func main() { Usage: "SSH server bind address", }, cli.StringFlag{ - Name: "db-driver", - Value: "sqlite3", - Usage: "GORM driver (sqlite3)", + Name: "db-driver", + EnvVar: "SSHPORTAL_DB_DRIVER", + Value: "sqlite3", + Usage: "GORM driver (sqlite3)", }, cli.StringFlag{ - Name: "db-conn", - Value: "./sshportal.db", - Usage: "GORM connection string", + Name: "db-conn", + EnvVar: "SSHPORTAL_DATABASE_URL", + Value: "./sshportal.db", + Usage: "GORM connection string", }, cli.BoolFlag{ - Name: "debug, D", - Usage: "Display debug information", + Name: "debug, D", + EnvVar: "SSHPORTAL_DEBUG", + Usage: "Display debug information", }, cli.StringFlag{ - Name: "aes-key", - Usage: "Encrypt sensitive data in database (length: 16, 24 or 32)", + Name: "aes-key", + EnvVar: "SSHPORTAL_AES_KEY", + Usage: "Encrypt sensitive data in database (length: 16, 24 or 32)", }, cli.StringFlag{ - Name: "logs-location", - Value: "./log", - Usage: "Store user session files", + Name: "logs-location", + EnvVar: "SSHPORTAL_LOGS_LOCATION", + Value: "./log", + Usage: "Store user session files", }, }, }, {