Skip to content

Commit

Permalink
feat: removed unnecesary configurations for mongodb
Browse files Browse the repository at this point in the history
Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>
  • Loading branch information
dipankardas011 authored Apr 2, 2024
1 parent 35d3314 commit 135549b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/storage/external/mongodb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ func getCredentialsFilters(cloud consts.KsctlCloud) bson.M {
func (db *Store) Connect(ctx context.Context) error {
db.context = context.Background()

Username := os.Getenv("MONGODB_USER")
Password := os.Getenv("MONGODB_PASSWORD")
DNSSeedlist := os.Getenv("MONGODB_DNS")
if len(Username) == 0 || len(Password) == 0 || len(DNSSeedlist) == 0 {
return fmt.Errorf("environment vars not set for the storage to work")
connURI := os.Getenv("MONGODB_URI")

if len(connURI) == 0 {
return fmt.Errorf("environment vars not set for the storage to work. Hint: mongodb://${username}:${password}@${domain}:${port} or mongo+atlas mongodb+srv://${username}:${password}@${domain}")
}

db.mongoURI = fmt.Sprintf("mongodb+srv://%s:%s@%s/?retryWrites=true&w=majority", Username, Password, DNSSeedlist)
db.mongoURI = fmt.Sprintf("%s/?retryWrites=true&w=majority", connURI)

opts := mongoOptions.Client().ApplyURI(db.mongoURI)

Expand Down

0 comments on commit 135549b

Please sign in to comment.