提交 d926e7b4 编写于 作者: Y Yanjun Shi 提交者: LinuxSuRen

fix remove a config (#102)

* fix remove a config

* update remove current Jenkins config

* update error information

* update some information
上级 55f1a69a
......@@ -69,9 +69,9 @@ func setCurrentJenkins(name string) {
}
}
var config Config
var config *Config
func getConfig() Config {
func getConfig() *Config {
return config
}
......
......@@ -30,7 +30,8 @@ var configRemoveCmd = &cobra.Command{
func removeJenkins(name string) (err error) {
current := getCurrentJenkins()
if name == current.Name {
err = fmt.Errorf("You cannot remove current Jenkins")
err = fmt.Errorf("You cannot remove current Jenkins, if you want to remove it, can select other items before")
return
}
index := -1
......@@ -45,10 +46,7 @@ func removeJenkins(name string) (err error) {
if index == -1 {
err = fmt.Errorf("Cannot found by name %s", name)
} else {
config.JenkinsServers[index] = config.JenkinsServers[len(config.JenkinsServers)-1]
config.JenkinsServers[len(config.JenkinsServers)-1] = JenkinsServer{}
config.JenkinsServers = config.JenkinsServers[:len(config.JenkinsServers)-1]
config.JenkinsServers = append(config.JenkinsServers[:index], config.JenkinsServers[index+1:]...)
err = saveConfig()
}
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册