fix
This commit is contained in:
28
.vscode/launch.json
vendored
28
.vscode/launch.json
vendored
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
// Use IntelliSense to learn about possible attributes.
|
// Use IntelliSense to learn about possible attributes.
|
||||||
// Hover to view descriptions of existing attributes.
|
// Hover to view descriptions of existing attributes.
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Launch Package",
|
"name": "Launch Package",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"program": "${workspaceFolder}"
|
"program": "${workspaceFolder}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
BIN
__debug_bin439949312
Normal file
BIN
__debug_bin439949312
Normal file
Binary file not shown.
@@ -70,13 +70,13 @@ func CreateApp(clustername string, ControlPlane string, PlatformVersion string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate unique cluster name with user prefix
|
// Generate unique cluster name with user prefix
|
||||||
uniqueClusterName := "test"
|
uniqueClusterName := clustername
|
||||||
|
|
||||||
app := ApplicationValues{
|
app := ApplicationValues{
|
||||||
Name: uniqueClusterName,
|
Name: uniqueClusterName,
|
||||||
Namespace: "ns-" + generateRandomString(4),
|
Namespace: "ns-" + generateRandomString(4),
|
||||||
Path: "vcluster-0.21.1",
|
Path: "vcluster-0.21.1",
|
||||||
Cluster: "in-cluster",
|
Cluster: "schoobus-onsite",
|
||||||
Server: "https://kubernetes.default.svc",
|
Server: "https://kubernetes.default.svc",
|
||||||
RepoURL: "http://192.168.2.20:8015/root/application.git",
|
RepoURL: "http://192.168.2.20:8015/root/application.git",
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
@@ -110,17 +110,17 @@ func CreateApp(clustername string, ControlPlane string, PlatformVersion string,
|
|||||||
Name: "controlPlane.advanced.defaultImageRegistry",
|
Name: "controlPlane.advanced.defaultImageRegistry",
|
||||||
Value: "192.168.2.43:31898",
|
Value: "192.168.2.43:31898",
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
Name: "controlPlane.distro.k8s.version",
|
// Name: "controlPlane.distro.k8s.version",
|
||||||
Value: ControlPlane,
|
// Value: ControlPlane,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
Name: "controlPlane.distro.k8s.resources.limits.cpu",
|
Name: "controlPlane.distro.k8s.resources.limits.cpu",
|
||||||
Value: Cpu,
|
Value: Cpu,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "controlPlane.distro.k8s.resources.limits.memory",
|
Name: "controlPlane.distro.k8s.resources.limits.memory",
|
||||||
Value: Memory,
|
Value: Memory + "Mi",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "controlPlane.distro.k8s.resources.requests.cpu",
|
Name: "controlPlane.distro.k8s.resources.requests.cpu",
|
||||||
|
|||||||
2
db/db.go
2
db/db.go
@@ -14,7 +14,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func InitDB() {
|
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)
|
client, err := mongo.Connect(context.TODO(), clientOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
@@ -19,4 +19,4 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||||
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
||||||
ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.1.10:27017/
|
ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.2.177:27017/
|
||||||
@@ -5,10 +5,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"main/argohandler"
|
"main/argohandler"
|
||||||
"main/db"
|
"main/db"
|
||||||
"net/http"
|
"net/http"
|
||||||
"log"
|
|
||||||
|
|
||||||
// "github.com/gorilla/mux"
|
// "github.com/gorilla/mux"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
@@ -37,10 +36,6 @@ func CreateClusterHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
var header Header
|
var header Header
|
||||||
header.Authorization = r.Header.Get("Authorization")
|
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)
|
// 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 == "" {
|
if cluster.Name == "" || cluster.ControlPlane == "" || cluster.PlatformVersion == "" || cluster.Cpu == "" || cluster.Memory == "" {
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
|
||||||
"main/db"
|
"main/db"
|
||||||
"main/handler"
|
"main/handler"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -72,6 +71,7 @@ func registerHnadler(w http.ResponseWriter, r *http.Request) {
|
|||||||
_, err := db.UserCollection.InsertOne(context.TODO(), user)
|
_, err := db.UserCollection.InsertOne(context.TODO(), user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, `{"message": "Could not create user"}`, http.StatusInternalServerError)
|
http.Error(w, `{"message": "Could not create user"}`, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
@@ -129,12 +129,12 @@ func main() {
|
|||||||
//handler.RegsiterClusterRoute(router)
|
//handler.RegsiterClusterRoute(router)
|
||||||
// Enable CORS
|
// Enable CORS
|
||||||
c := cors.New(cors.Options{
|
c := cors.New(cors.Options{
|
||||||
AllowedOrigins: []string{"*"}, // Allow all origins
|
AllowedOrigins: []string{"*"}, // Allow all origins
|
||||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||||
AllowedHeaders: []string{"Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin"},
|
AllowedHeaders: []string{"Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin"},
|
||||||
ExposedHeaders: []string{"Content-Length"},
|
ExposedHeaders: []string{"Content-Length"},
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
Debug: true, // Enable debug logging
|
Debug: true, // Enable debug logging
|
||||||
})
|
})
|
||||||
|
|
||||||
http.ListenAndServe("0.0.0.0:8082", c.Handler(router))
|
http.ListenAndServe("0.0.0.0:8082", c.Handler(router))
|
||||||
|
|||||||
Reference in New Issue
Block a user