Use database and collection names from env vars

This commit is contained in:
Lauri Võsandi 2021-05-08 20:02:37 +00:00
parent 696e954805
commit d8997550b5

View File

@ -20,6 +20,8 @@ type InventoryItem struct {
}
var mongoUri string = os.Getenv("MONGO_URI")
var databaseName string = os.Getenv("GOREDNS_DATABASE")
var collectionName string = os.Getenv("GOREDNS_COLLECTION")
func appendResults(etype string, name string, m *dns.Msg, cur *mongo.Cursor) int {
count := 0
@ -97,7 +99,7 @@ func main() {
log.Fatal(err)
}
coll := client.Database("kspace_accounting").Collection("inventory")
coll := client.Database(databaseName).Collection(collectionName)
defer client.Disconnect(ctx)
dns.HandleFunc(".", wrapper(coll))
port := 53