fix registry address

This commit is contained in:
behrooz razzaghi
2025-04-05 16:58:47 +03:30
parent fd1e1f1d2e
commit 61a9fbe9f2
8 changed files with 23 additions and 42 deletions

View File

@@ -29,8 +29,8 @@ var (
func InitializeClient() {
once.Do(func() {
argocdServer := "192.168.1.10:31946"
argocdToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjphcGlLZXkiLCJuYmYiOjE3Mzc5NzA4MTksImlhdCI6MTczNzk3MDgxOSwianRpIjoiYjgzODAxZDQtNWNjOC00NTNiLWE0NTYtNTBjNzZjODkyMzcwIn0.9QXrnVeeTnH18YXb9rE7UTWIk16O63a9O03au35SEwk"
argocdServer := "192.168.2.172:32200"
argocdToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjphcGlLZXkiLCJuYmYiOjE3NDM4NTAwNzIsImlhdCI6MTc0Mzg1MDA3MiwianRpIjoiNWZhNmQ5MDgtMzljNi00ZWQ4LWE5YzgtMzI4YzMzYjkyNzk4In0.ZvhJk4L5vBQldtJyReKYXCQCWF8j8gHLZlY8PninSFA"
config := apiclient.ClientOptions{
ServerAddr: argocdServer,
@@ -46,7 +46,7 @@ func InitializeClient() {
})
}
func CreateApp() {
func CreateApp(clustername string) {
InitializeClient()
@@ -57,12 +57,12 @@ func CreateApp() {
}
app := ApplicationValues{
Name: "vc-bhrz-n",
Name: clustername,
Namespace: "vc-bhrz-n",
Path: "vcluster-0.21.1",
Cluster: "in-cluster",
Server: "https://kubernetes.default.svc",
RepoURL: "http://192.168.1.10:3000/admin/applications",
RepoURL: "http://192.168.2.20:8015/root/application.git",
}
// Define the ArgoCD application

View File

@@ -21,4 +21,5 @@ func InitDB() {
}
UserCollection = client.Database("vcluster").Collection("users")
Vclusters_details = client.Database("vcluster").Collection("vclusters_details")
}

View File

@@ -20,34 +20,3 @@ services:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.1.10:27017/
gitea:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=postgres
- DB_HOST=db:5432
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea_password
restart: always
volumes:
- ./gitea/data:/data
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: postgres:15
container_name: gitea_db
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea_password
- POSTGRES_DB=gitea
restart: always
volumes:
- ./postgres/data:/var/lib/postgresql/data

1
go.mod
View File

@@ -6,6 +6,7 @@ require (
github.com/argoproj/argo-cd/v2 v2.13.3
github.com/golang-jwt/jwt/v4 v4.5.1
github.com/gorilla/mux v1.7.3
github.com/rs/cors v1.11.0
golang.org/x/crypto v0.32.0
k8s.io/apimachinery v0.31.0
)

2
go.sum
View File

@@ -413,6 +413,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

View File

@@ -3,6 +3,7 @@ package handler
import (
"context"
"encoding/json"
"main/argohandler"
"main/db"
"net/http"
@@ -25,24 +26,31 @@ type Cluster struct {
func createClusterHandler(w http.ResponseWriter, r *http.Request) {
vclusterCollection := db.Client.Database("vcluster").Collection("vclusters_details")
var cluster Cluster
_ = json.NewDecoder(r.Body).Decode(&cluster)
// 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 == "" {
http.Error(w, "Invalid input", http.StatusBadRequest)
return
}
var existsCluster Cluster
_ = vclusterCollection.FindOne(context.TODO(), bson.M{"name": cluster.Name}).Decode(&existsCluster)
_ = db.Vclusters_details.FindOne(context.TODO(), bson.M{"name": cluster.Name}).Decode(&existsCluster)
if existsCluster.Name == cluster.Name {
http.Error(w, "Cluster name is duplicated", http.StatusBadRequest)
return
}
_, err := db.Vclusters_details.InsertOne(context.TODO(), cluster)
if err != nil {
http.Error(w, `{"message": "Could not create cluster"}`, http.StatusInternalServerError)
}
argohandler.CreateApp(cluster.Name)
response := map[string]string{"message": "Cluster created"}
w.Header().Set("Content-Type", "application/json")

View File

@@ -135,5 +135,5 @@ func main() {
AllowCredentials: true,
})
log.Fatal(http.ListenAndServe(":8080", c.Handler((router))))
log.Fatal(http.ListenAndServe(":8082", c.Handler((router))))
}