wangpengfei
2023-05-31 54f7436e002f1b7fc36ce0caff53b3394acb13b5
src/main/main.go
@@ -155,23 +155,33 @@
   }
   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)
      //}
      // 解析配置文件中的字段
      var rancherClusterConfig  rancher.RancherClusterConfig
      err = viper.Unmarshal(&rancherClusterConfig)
      if err != nil {
         log.Fatalf("Failed to unmarshal config: %v", err)
      //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)
   }