From 064c0874e5fd041c4641ef873d1bf72ac98a184d Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 02 六月 2023 16:26:09 +0800
Subject: [PATCH] Merge branch 'master' into fly_develop

---
 src/main/main.go |   59 +++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/src/main/main.go b/src/main/main.go
index db889ec..e3e8f81 100644
--- a/src/main/main.go
+++ b/src/main/main.go
@@ -27,7 +27,7 @@
 )
 
 func rancher_install_test(node rancher.Node) {
-/*	nodes := []Node{
+	/*	nodes := []Node{
 		{
 			Roles:       []string{"etcd", "controlplane", "worker"},
 			IP:          "192.168.20.189",
@@ -61,7 +61,7 @@
 	os.Exit(0)
 }
 
-func cluster_test(clusterName string,rancherClusterConfig rancher.RancherClusterConfig) {
+func cluster_test(clusterName string, rancherClusterConfig rancher.RancherClusterConfig) {
 
 	// Create the cluster
 	// Rancher configuration
@@ -70,9 +70,9 @@
 		BearerToken: "token-nnrsc:w68zdt8s47fnpjd5xqdl5hhzpz4j2d56kt5nx49nsswcbpdzc28kh5",
 	}*/
 
-        fmt.Println(rancherClusterConfig)
-        fmt.Println(rancherClusterConfig.RancherURL)
-        fmt.Println(rancherClusterConfig.BearerToken)
+	fmt.Println(rancherClusterConfig)
+	fmt.Println(rancherClusterConfig.RancherURL)
+	fmt.Println(rancherClusterConfig.BearerToken)
 	//	Deploy clusterId
 	clusterID, err := cluster.GetClusterID(rancherClusterConfig.RancherURL, rancherClusterConfig.BearerToken, clusterName)
 	if err != nil {
@@ -155,38 +155,53 @@
 	}
 
 	if rancherInstallCmd.Parsed() {
-		// 鍒濆鍖栭厤缃В鏋愬簱
-		viper.SetConfigName("config")
-		viper.SetConfigType("yaml")
-		viper.AddConfigPath("./config")
-
-		// 璇诲彇閰嶇疆鏂囦欢
-		err := viper.ReadInConfig()
-		if err != nil {
-			log.Fatalf("Failed to read config file: %v", err)
-		}
+		//// 鍒濆鍖栭厤缃В鏋愬簱
+		//viper.SetConfigName("config")
+		//viper.SetConfigType("yaml")
+		//viper.AddConfigPath("./config")
+		//
+		//// 璇诲彇閰嶇疆鏂囦欢
+		//err := viper.ReadInConfig()
+		//if err != nil {
+		//	log.Fatalf("Failed to read config file: %v", err)
+		//}
 
 		// 瑙f瀽閰嶇疆鏂囦欢涓殑瀛楁
-		var rancherClusterConfig  rancher.RancherClusterConfig
-		err = viper.Unmarshal(&rancherClusterConfig)
-		if err != nil {
-			log.Fatalf("Failed to unmarshal config: %v", err)
+		var rancherClusterConfig rancher.RancherClusterConfig
+		//err = viper.Unmarshal(&rancherClusterConfig)
+		//if err != nil {
+		//	log.Fatalf("Failed to unmarshal config: %v", err)
+		//}
+
+		rancherClusterConfig.Nodes = make([]rancher.Node, 3)
+		rancherClusterConfig.Nodes[0] = rancher.Node{
+			Roles:       []string{"worker"},
+			IP:          "192.168.20.189",
+			SSHUsername: "basic",
+			SSHPassword: "123",
+			SSHPort:     22,
 		}
+
 		rancher_install_test(rancherClusterConfig.Nodes[0])
 		os.Exit(1)
 	}
 
 	// 鎵ц create 鍛戒护
 	if createCmd.Parsed() {
+
 		// 閰嶇疆 Kubernetes 闆嗙兢鐨� kubeconfig 璺緞
 		kubeconfig := flag.String("kubeconfig", filepath.Join(util.HomeDir(), ".kube", "config"), "kubeconfig file")
 		flag.Parse()
+
+		fmt.Println(&kubeconfig)
 
 		// 鍒涘缓 Kubernetes 瀹㈡埛绔�
 		config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
 		if err != nil {
 			panic(err.Error())
 		}
+
+		fmt.Println(&config)
 
 		clientset, err := kubernetes.NewForConfig(config)
 		if err != nil {
@@ -311,13 +326,13 @@
 		}
 
 		// 瑙f瀽閰嶇疆鏂囦欢涓殑瀛楁
-		var rancherClusterConfig  rancher.RancherClusterConfig
+		var rancherClusterConfig rancher.RancherClusterConfig
 		err = viper.Unmarshal(&rancherClusterConfig)
 		if err != nil {
 			log.Fatalf("Failed to unmarshal config: %v", err)
 		}
-        	clusterName := "kubernetus"
-                fmt.Println(rancherClusterConfig)
+		clusterName := "kubernetus"
+		fmt.Println(rancherClusterConfig)
 		cluster_test(clusterName, rancherClusterConfig)
 	}
 

--
Gitblit v1.8.0