You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "abeizn (via GitHub)" <gi...@apache.org> on 2023/06/07 09:54:15 UTC

[GitHub] [incubator-devlake] abeizn opened a new pull request, #5399: feat: add ENV_FILE var

abeizn opened a new pull request, #5399:
URL: https://github.com/apache/incubator-devlake/pull/5399

   ### Summary
   feat: add ENV_FILE var
   
   ### Does this close any open issues?
   Closes #5235 
   
   ### Screenshots
   Include any relevant screenshots here.
   
   ### Other Information
   Any other information that is important to this PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] keon94 commented on a diff in pull request #5399: feat: add ENV_FILE var

Posted by "keon94 (via GitHub)" <gi...@apache.org>.
keon94 commented on code in PR #5399:
URL: https://github.com/apache/incubator-devlake/pull/5399#discussion_r1222095132


##########
backend/core/config/config_viper.go:
##########
@@ -47,15 +47,17 @@ func GetConfig() *viper.Viper {
 func initConfig(v *viper.Viper) {
 	v.SetConfigName(getConfigName())
 	v.SetConfigType("env")
-	envPath := getEnvPath()
-	// AddConfigPath adds a path for Viper to search for the config file in.
-	v.AddConfigPath("./../../../../..")
-	v.AddConfigPath("./../../../..")
-	v.AddConfigPath("./../../..")
-	v.AddConfigPath("./../..")
-	v.AddConfigPath("./../")
-	v.AddConfigPath("./")
-	v.AddConfigPath(envPath)
+
+	if envFile := os.Getenv("ENV_FILE"); envFile != "" {
+		v.SetConfigFile(envFile)
+	} else {
+		v.SetConfigFile("./.env")

Review Comment:
   @abeizn Is there a reason to just default to the current dir? I'd have kept the list of parent paths as before:
   i.e.
   ```go
   v.AddConfigPath("./../../.env")
   v.AddConfigPath("./../.env")
   //etc
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] keon94 commented on a diff in pull request #5399: feat: add ENV_FILE var

Posted by "keon94 (via GitHub)" <gi...@apache.org>.
keon94 commented on code in PR #5399:
URL: https://github.com/apache/incubator-devlake/pull/5399#discussion_r1222095132


##########
backend/core/config/config_viper.go:
##########
@@ -47,15 +47,17 @@ func GetConfig() *viper.Viper {
 func initConfig(v *viper.Viper) {
 	v.SetConfigName(getConfigName())
 	v.SetConfigType("env")
-	envPath := getEnvPath()
-	// AddConfigPath adds a path for Viper to search for the config file in.
-	v.AddConfigPath("./../../../../..")
-	v.AddConfigPath("./../../../..")
-	v.AddConfigPath("./../../..")
-	v.AddConfigPath("./../..")
-	v.AddConfigPath("./../")
-	v.AddConfigPath("./")
-	v.AddConfigPath(envPath)
+
+	if envFile := os.Getenv("ENV_FILE"); envFile != "" {
+		v.SetConfigFile(envFile)
+	} else {
+		v.SetConfigFile("./.env")

Review Comment:
   Is there a reason to just default to the current dir? I'd have kept the list of parent paths as before:
   i.e.
   ```go
   v.AddConfigPath("./../../.env")
   v.AddConfigPath("./../.env")
   //etc
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #5399: feat: add ENV_FILE var

Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn commented on code in PR #5399:
URL: https://github.com/apache/incubator-devlake/pull/5399#discussion_r1222513389


##########
backend/core/config/config_viper.go:
##########
@@ -47,15 +47,17 @@ func GetConfig() *viper.Viper {
 func initConfig(v *viper.Viper) {
 	v.SetConfigName(getConfigName())
 	v.SetConfigType("env")
-	envPath := getEnvPath()
-	// AddConfigPath adds a path for Viper to search for the config file in.
-	v.AddConfigPath("./../../../../..")
-	v.AddConfigPath("./../../../..")
-	v.AddConfigPath("./../../..")
-	v.AddConfigPath("./../..")
-	v.AddConfigPath("./../")
-	v.AddConfigPath("./")
-	v.AddConfigPath(envPath)
+
+	if envFile := os.Getenv("ENV_FILE"); envFile != "" {
+		v.SetConfigFile(envFile)
+	} else {
+		v.SetConfigFile("./.env")

Review Comment:
   @keon94 You are right, according to klesh’s opinion, delete all other paths and only keep the current path, but it seems that it cannot be used so easily



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] mindlesscloud merged pull request #5399: feat: add ENV_FILE var

Posted by "mindlesscloud (via GitHub)" <gi...@apache.org>.
mindlesscloud merged PR #5399:
URL: https://github.com/apache/incubator-devlake/pull/5399


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #5399: feat: add ENV_FILE var

Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn commented on code in PR #5399:
URL: https://github.com/apache/incubator-devlake/pull/5399#discussion_r1222910291


##########
backend/core/config/config_viper.go:
##########
@@ -47,15 +47,17 @@ func GetConfig() *viper.Viper {
 func initConfig(v *viper.Viper) {
 	v.SetConfigName(getConfigName())
 	v.SetConfigType("env")
-	envPath := getEnvPath()
-	// AddConfigPath adds a path for Viper to search for the config file in.
-	v.AddConfigPath("./../../../../..")
-	v.AddConfigPath("./../../../..")
-	v.AddConfigPath("./../../..")
-	v.AddConfigPath("./../..")
-	v.AddConfigPath("./../")
-	v.AddConfigPath("./")
-	v.AddConfigPath(envPath)
+
+	if envFile := os.Getenv("ENV_FILE"); envFile != "" {
+		v.SetConfigFile(envFile)
+	} else {
+		v.SetConfigFile("./.env")

Review Comment:
   updated by #5410 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org