-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logging and yaml configuration loading
- Loading branch information
Showing
11 changed files
with
414 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
*.png | ||
*.csv | ||
*.env | ||
*.yaml | ||
*.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
elasticSearch: http://localhost:9200 | ||
apacheTika: http://localhost:9998 | ||
|
||
# Path for which you want to index the documents | ||
appConfig: | ||
filePath: ./assets/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package config | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
type Config struct { | ||
config *viper.Viper | ||
} | ||
|
||
func NewConfig() *Config { | ||
c := new(Config) | ||
c.config = readConfig() | ||
return c | ||
} | ||
|
||
func (c *Config) Get() *viper.Viper { | ||
if c.config == nil { | ||
log.Fatal("config not initialized") | ||
} | ||
return c.config | ||
} | ||
|
||
func readConfig() *viper.Viper { | ||
log.Info("reading environment variables") | ||
v := viper.New() | ||
v.SetConfigName("config") | ||
v.AddConfigPath(".") | ||
v.SetConfigType("yaml") | ||
err := v.ReadInConfig() | ||
if err != nil { | ||
log.Fatalf("error reading config file or env variable '%s'", err.Error()) | ||
} | ||
|
||
return v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters