package db import ( "context" "log" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) var ( Client *mongo.Client UserCollection, Vclusters_details, Host_cluster_details, Worker_nodes_plan *mongo.Collection ) func InitDB() { clientOptions := options.Client().ApplyURI("mongodb://root:secret123@130.185.77.247:31141/") client, err := mongo.Connect(context.TODO(), clientOptions) if err != nil { log.Fatal(err) } UserCollection = client.Database("vcluster").Collection("users") Vclusters_details = client.Database("vcluster").Collection("vclusters_details") Host_cluster_details = client.Database("vcluster").Collection("hostdetail") Worker_nodes_plan = client.Database("vcluster").Collection("worker_nodes_plans") }