diff --git a/.vscode/launch.json b/.vscode/launch.json index 0f8103e..97f4a32 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,15 +1,15 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Package", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${workspaceFolder}" - } - ] +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}" + } + ] } \ No newline at end of file diff --git a/__debug_bin439949312 b/__debug_bin439949312 new file mode 100644 index 0000000..eaed445 Binary files /dev/null and b/__debug_bin439949312 differ diff --git a/argohandler/argohandler.go b/argohandler/argohandler.go index 20be6cf..a394371 100644 --- a/argohandler/argohandler.go +++ b/argohandler/argohandler.go @@ -70,13 +70,13 @@ func CreateApp(clustername string, ControlPlane string, PlatformVersion string, } // Generate unique cluster name with user prefix - uniqueClusterName := "test" + uniqueClusterName := clustername app := ApplicationValues{ Name: uniqueClusterName, Namespace: "ns-" + generateRandomString(4), Path: "vcluster-0.21.1", - Cluster: "in-cluster", + Cluster: "schoobus-onsite", Server: "https://kubernetes.default.svc", RepoURL: "http://192.168.2.20:8015/root/application.git", UserID: userID, @@ -110,17 +110,17 @@ func CreateApp(clustername string, ControlPlane string, PlatformVersion string, Name: "controlPlane.advanced.defaultImageRegistry", Value: "192.168.2.43:31898", }, - { - Name: "controlPlane.distro.k8s.version", - Value: ControlPlane, - }, + // { + // Name: "controlPlane.distro.k8s.version", + // Value: ControlPlane, + // }, { Name: "controlPlane.distro.k8s.resources.limits.cpu", Value: Cpu, }, { Name: "controlPlane.distro.k8s.resources.limits.memory", - Value: Memory, + Value: Memory + "Mi", }, { Name: "controlPlane.distro.k8s.resources.requests.cpu", diff --git a/db/db.go b/db/db.go index 7f979ca..0419304 100644 --- a/db/db.go +++ b/db/db.go @@ -14,7 +14,7 @@ var ( ) func InitDB() { - clientOptions := options.Client().ApplyURI("mongodb://root:example@172.20.158.234:27017/") + clientOptions := options.Client().ApplyURI("mongodb://root:example@192.168.2.177:27017/") client, err := mongo.Connect(context.TODO(), clientOptions) if err != nil { log.Fatal(err) diff --git a/docker-compose.yaml b/docker-compose.yaml index c48dc9f..9c9827f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -19,4 +19,4 @@ services: environment: ME_CONFIG_MONGODB_ADMINUSERNAME: root ME_CONFIG_MONGODB_ADMINPASSWORD: example - ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.1.10:27017/ \ No newline at end of file + ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.2.177:27017/ \ No newline at end of file diff --git a/handler/handler.go b/handler/handler.go index f92371c..4817582 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -5,10 +5,9 @@ import ( "encoding/json" "main/argohandler" "main/db" - "net/http" - "log" + "net/http" -// "github.com/gorilla/mux" + // "github.com/gorilla/mux" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) @@ -37,10 +36,6 @@ func CreateClusterHandler(w http.ResponseWriter, r *http.Request) { var header Header header.Authorization = r.Header.Get("Authorization") - log.Fatal("--------------") - log.Fatal(r.Header.Get("Authorization")) - log.Fatal("--------------") - // vclusterCollection := db.Vclusters_details.FindOne(context.TODO(), bson.M{"name": Cluster.Name}).Decode(&existsCluster) if cluster.Name == "" || cluster.ControlPlane == "" || cluster.PlatformVersion == "" || cluster.Cpu == "" || cluster.Memory == "" { diff --git a/main.go b/main.go index 6a0cbb0..d5b09ee 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" - "main/db" "main/handler" "net/http" @@ -72,6 +71,7 @@ func registerHnadler(w http.ResponseWriter, r *http.Request) { _, err := db.UserCollection.InsertOne(context.TODO(), user) if err != nil { http.Error(w, `{"message": "Could not create user"}`, http.StatusInternalServerError) + return } w.WriteHeader(http.StatusCreated) @@ -129,12 +129,12 @@ func main() { //handler.RegsiterClusterRoute(router) // Enable CORS c := cors.New(cors.Options{ - AllowedOrigins: []string{"*"}, // Allow all origins + AllowedOrigins: []string{"*"}, // Allow all origins AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowedHeaders: []string{"Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin"}, ExposedHeaders: []string{"Content-Length"}, AllowCredentials: true, - Debug: true, // Enable debug logging + Debug: true, // Enable debug logging }) http.ListenAndServe("0.0.0.0:8082", c.Handler(router))